Improve this slow setplayerspeed
#6

In OnPlayerUpdate you need to check for the up/down and left/right keys, however that makes it even more slow.
To prevent making you not able to fall you also have to check the z velocity (adjust MAX_Z_VEL).
It might be a bit buggy when jumping, holding jump makes it work.

This works for me, even when sprinting and walking. On a server with a high ping it could be very laggy tho.

Код:
#define SPEED_MUL   0.1
#define MAX_Z_VEL 0.02

public OnPlayerUpdate(playerid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
	{
		new keys, ud, lr;
		GetPlayerKeys(playerid, keys, ud, lr);

		if((ud != 0 || lr != 0) && !(keys & KEY_JUMP))
		{
		    new Float:v0[3];
		    GetPlayerVelocity(playerid, v0[0], v0[1], v0[2]);
		    if(v0[2] >= -MAX_Z_VEL && v0[2] <= MAX_Z_VEL) SetPlayerVelocity(playerid, v0[0] * SPEED_MUL, v0[1] * SPEED_MUL, v0[2] * SPEED_MUL);
		}
	}
}
Reply


Messages In This Thread
Improve this slow setplayerspeed - by gmstrikker - 09.03.2016, 06:53
Re: Improve this slow setplayerspeed - by MicroKyrr - 09.03.2016, 09:07
Re: Improve this slow setplayerspeed - by Sew_Sumi - 09.03.2016, 09:43
Re: Improve this slow setplayerspeed - by MicroKyrr - 09.03.2016, 10:16
Re: Improve this slow setplayerspeed - by Vince - 09.03.2016, 10:35
Re: Improve this slow setplayerspeed - by NaS - 09.03.2016, 12:43
Re: Improve this slow setplayerspeed - by gmstrikker - 09.03.2016, 13:35
Re: Improve this slow setplayerspeed - by DRIFT_HUNTER - 09.03.2016, 14:07
Re: Improve this slow setplayerspeed - by Sew_Sumi - 09.03.2016, 14:14
Re: Improve this slow setplayerspeed - by pdonald - 15.03.2016, 19:28

Forum Jump:


Users browsing this thread: 4 Guest(s)