How do I stop a player from sprinting?
#1

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

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

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

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);
}
Reply
#5

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.
Reply
#6

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;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)