Bah, I can't figure out what's wrong here. It started out as a clean looking script, but I had to add quite a few extra checks. Anyway, this is what I have now. Sometimes I am able to jump fine, other times it's a short jump. And sometimes when I land, I bounce, or go below the ground. I thought I had it all checked out. I don't want a free script, just tell me what I'm missing with this one
PHP Code:
// NPC made by Excalibur
//GS2 Grav
//#CLIENTSIDE
function onCreated()
{
client.no_wep=1;
player.dir=3;
this.direction=player.dir;
this.speed=.05;
settimer(.05);
}
function onTimeout()
{
//set the jump
if(keydown(0) && this.jump==0 && onwall(player.x+1, player.y+3.5))
{
this.speed=.05;
this.jump=1;
this.count=50;
}
//force fall
if(keydown(2))
{
if(!onwall(player.x+1, player.y+3.5))
{
this.speed+=.5;
}
}
//move
if(player.dir==0 || player.dir==2)
{
player.dir=this.direction;
}
this.direction=player.dir;
if(this.jump==1)
{
if(!onwall(playerx+1,playery-.5) && this.count>0)
{
player.y-=.5;
}
else
{
this.count=0;
}
this.count--;
if(this.count<=0)
{
this.jump=0;
}
}
if(!onwall(player.x+1, player.y+3.5))
{
player.y+=this.speed;
if(this.speed<5)
{
this.speed+=.05;
}
}
else if(onwall(player.x+1, player.y+3.5))
{
this.speed=.05;
}
settimer(.05);
}