Improve this slow setplayerspeed
#7

Quote:
Originally Posted by MicroKyrr
Посмотреть сообщение
Oh i see!
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if(
newkeys KEY_WALK) && (newkeys KEY_SPRINT))
        {
            new 
Float:VPOS[3];
            
GetPlayerVelocity(playeridVPOS[0], VPOS[1], VPOS[2]);
            
SetPlayerVelocity(playeridVPOS[0]*0.5VPOS[1]*0.5VPOS[2]*0.5);
        }
    }
    return 
1;

its not work, dont change nothing :S

Quote:
Originally Posted by NaS
Посмотреть сообщение
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);
		}
	}
}
try to fall and jump
and even mode of running is not fluid
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: 3 Guest(s)