OnPlayerUpdate + GetPlayerKey
#1

Hey guys I have a question, I'm trying to make a system that will not allow the player walk fast.

See, when you press "W" even without you to press sprint you gonna walk really fast and you might go to faraway places in few seconds, my idea is to make the player only walk, like if the player hold "Alt", but it's not everybody that will respect and walk slowly.

So the point is, I made this function (thanks to wiki samp) and I wanna make sure that this code will not LAG my GM.


PHP код:
new bool:Andando[MAX_PLAYERS];
public 
OnPlayerUpdate(playerid) {
    new 
Keys,ud,lr;
    
GetPlayerKeys(playerid,Keys,ud,lr);
    if(
ud != || lr != 0) {
        if(
Andando[playerid] == false) {
            
ApplyAnimation(playerid"PED""WALK_civi"4.1111111);
            
Andando[playerid] = true;
        }
    }
    else {
        if(
Andando[playerid] == true) {
            
ApplyAnimation(playerid"CARRY""crry_prtial"4.000000);
            
Andando[playerid] = false;
        }
    }
    return 
1;

Reply
#2

I suggest you to use OnPlayerKeyStateChange callback instead.
Reply
#3

OnPlayerKeyStateChange doesn't "read" KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT.
And I need to see when someone press some key to walk.
Reply
#4

I didn't know that, sorry.
Reply
#5

Pretty sure this won't lag, OnPlayerUpdate isn't that bad anyway
Reply
#6

Thanks Hiddos.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)