SA-MP Forums Archive
How do I stop a player from sprinting? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How do I stop a player from sprinting? (/showthread.php?tid=563731)



How do I stop a player from sprinting? - Dokins - 16.02.2015

I've looked around in several places and cannot find a resolution, could someone please advise.


Re: How do I stop a player from sprinting? - bigboy81 - 16.02.2015

Use if player holding space and w directly and do someting with that


Re: How do I stop a player from sprinting? - Dokins - 16.02.2015

How do I detect this? I find it a little confusing.


Re: How do I stop a player from sprinting? - bigboy81 - 16.02.2015

Quote:
Originally Posted by Dokins
View Post
How do I detect this? I find it a little confusing.
Something like this

Code:
if(HOLDING(KEY_UP | KEY_SPRINT)
{
    ApplyAnimation(playerid, "PED", "FALL_front", 4.0, 1, 0, 0, 0, 0,1);
}



Re: How do I stop a player from sprinting? - Extremo - 16.02.2015

Alternatively, you could look into the following functions:

GetPlayerVelocity
SetPlayerVelocity

However this would most certainly require a loop and thus may not be desirable because of performance related issues. Up to you.

EDIT:

Speaking of which, you probably should make sure to detect the EXACT speed of sprinting, because I am unaware if car surfing or other sorts of movement are considered velocity.


Re: How do I stop a player from sprinting? - xVIP3Rx - 16.02.2015

Try this
pawn Code:
#define HOLDING(%0) ((newkeys & (%0)) == (%0))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && HOLDING(KEY_SPRINT ))
    {
        SetPlayerVelocity(playerid, 0.0, 0.0, 0.0); // Forces the player to stop
    }
    return 1;
}