GetPlayerKeys
From SA-MP Wiki
| playerid | The ID of the player to detect the keys of |
| keys | A set of bits containing the player's key/button states |
| updown | Up or Down analog value |
| leftright | Left or Right analog value |
| Returns | This function doesn't return a specific value |
The following example shows how you can regularly check the analog up/down/left/right values using OnPlayerUpdate.
public OnPlayerUpdate(playerid) { new Keys,ud,lr; GetPlayerKeys(playerid,Keys,ud,lr); if(ud > 0) SendClientMessage(playerid, 0xFFFFFFFF, "DOWN"); else if(ud < 0) SendClientMessage(playerid, 0xFFFFFFFF, "UP"); if(lr > 0) SendClientMessage(playerid, 0xFFFFFFFF, "RIGHT"); else if(lr < 0) SendClientMessage(playerid, 0xFFFFFFFF, "LEFT"); return 1; }
Key List
The reference below lists the defines gametext codes for the keys. Gametext codes can be used in text draws and the GameText* functions. The codes will appear as the key configured by the player.
Special Keys
OnPlayerKeyStateChange will be called each time a key state is changed. It will never be called for up, down, left and right.
Note: The Gametext-Key can be used in messages and 3D-Texts since SA-MP 0.3d RC9. They won't work in earlier versions!
~k~~PED_FIREWEAPON_ALT~
~k~~VEHICLE_FIREWEAPON_ALT~
[*] Key not defined in SA:MP includes. You must define this yourself or use KEY_HANDBRAKE.
[**] Support for this key was added in 0.3d. It will not be detectable in earlier versions.
Up/Down-Keys
Left/Right-Keys
Links
Related Callbacks
The following callbacks might be useful as well, as they're related to this callback in one way or another.
- OnPlayerKeyStateChange: Called when a player's keystate change.
