SA-MP Forums Archive
Weird key detecting - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Weird key detecting (/showthread.php?tid=172034)



Weird key detecting - Vince - 28.08.2010

Ok, I'm having some weird problems with OnPlayerKeyStateChange here ..

For some reason, it calls KEY_SPRINT when I press the forward key, but only when in a vehicle. The Wiki clearly states that OnPlayerKeyStateChange doesn't get called for updown and leftright. And, on top of that, KEY_UP is defined as 128 ...

pawn Код:
#define PRESSED(%0) \
        (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

    if(PRESSED(KEY_SPRINT))
    {
        printf("[debug] Found: KEY_SPRINT - %d", KEY_SPRINT);
        ClearAnimations(playerid);
        SetPlayerSpecialAction(playerid, 0);
        return 1;
    }
Output from console:
Код:
[21:09:18] [debug] Found: KEY_SECONDARY_ATTACK - 16 // I enter a vehicle
[21:09:22] [debug] Found: KEY_SPRINT - 8 // I press the accelerate key
Note that I got the defines from the wiki as well!


Re: Weird key detecting - Mike_Peterson - 28.08.2010

maybe you changed the keys of the gta sa so Menu > Options > Keyboard > redefine keys.. did u change keys?


Re: Weird key detecting - Vince - 28.08.2010

Yes, I use the arrow keys to steer (instead of WASD), but that shouldn't have anything to do with it.
The server is not dependent on the key configuration of the client. KEY_SPRINT is KEY_SPRINT, no matter if you assign KEY_SPRINT to control, or shift, or whatever.