GetPlayerKeys
From SA-MP Wiki
| Revision as of 09:28, 30 November 2010 Simon (Talk | contribs) ← Previous diff |
Revision as of 18:34, 19 October 2011 Garsino (Talk | contribs) Next diff → |
||
| Line 35: | Line 35: | ||
| === Special Keys === | === Special Keys === | ||
| - | OnPlayerKeyStateChange will be called each time a key state is changed. It will never be called for up, down, left and right. | + | OnPlayerKeyStateChange will be called each time a key state is changed. It will never be called for up, down, left, right, KEY_YES (Y), KEY_NO (N) and KEY_CTRL_BACK (H). |
| {{Key|'''Define'''|'''Value'''|'''Gametext-Key on Foot'''|'''Gametext-Key in Vehicle'''}} | {{Key|'''Define'''|'''Value'''|'''Gametext-Key on Foot'''|'''Gametext-Key in Vehicle'''}} | ||
| Line 58: | Line 58: | ||
| [*] Key not defined in SA:MP includes. You must define this yourself. | [*] Key not defined in SA:MP includes. You must define this yourself. | ||
| + | [**] Support for this key was added in 0.3d. It will not be detectable in earlier versions. | ||
| Line 69: | Line 70: | ||
| {{Key|KEY_LEFT|-128|~k~~GO_LEFT~|~k~~VEHICLE_STEERLEFT~}} | {{Key|KEY_LEFT|-128|~k~~GO_LEFT~|~k~~VEHICLE_STEERLEFT~}} | ||
| {{Key|KEY_RIGHT|128|~k~~GO_RIGHT~|~k~~VEHICLE_STEERRIGHT~}} | {{Key|KEY_RIGHT|128|~k~~GO_RIGHT~|~k~~VEHICLE_STEERRIGHT~}} | ||
| + | |||
| + | === Keys Since 0.3d === | ||
| + | {{Key|'''Define'''|'''Value'''|'''Gametext-Key on Foot'''|'''Gametext-Key in Vehicle'''}} | ||
| + | {{Key|KEY_YES**|65536||}} | ||
| + | {{Key|KEY_NO**|131072||}} | ||
| + | {{Key|KEY_CTRL_BACK**|262144||}} | ||
| + | |||
| == Links == | == Links == | ||
Revision as of 18:34, 19 October 2011
| 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, right, KEY_YES (Y), KEY_NO (N) and KEY_CTRL_BACK (H).
~k~~PED_FIREWEAPON_ALT~
~k~~VEHICLE_FIREWEAPON_ALT~
[*] Key not defined in SA:MP includes. You must define this yourself.
[**] Support for this key was added in 0.3d. It will not be detectable in earlier versions.
Up/Down-Keys
Left/Right-Keys
Keys Since 0.3d
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.
