GetPlayerKeys
Description:
Function GetPlayerKeys check which keys a player is pressing.
|
Parameters:
(playerid, &keys, &updown, &leftright)
int | playerid | The ID of the player to get the keys of. |
int | keys | A set of bits containing the player's key states. This value is what is called a bit mask. Click here for a list of keys. |
int | updown | Up/down state. |
int | leftright | Left/right state. |
Return Values:
This function does not return any specific values.
- The keys are stored in the specified variables.
Examples:
// The following example shows how you can regularly check the up/down/left/right values using OnPlayerUpdate. public OnPlayerUpdate(playerid) { new Keys,ud,lr; GetPlayerKeys(playerid,Keys,ud,lr); if(ud == KEY_UP) SendClientMessage(playerid, -1, "UP"); else if(ud == KEY_DOWN) SendClientMessage(playerid, -1, "DOWN"); if(lr == KEY_LEFT) SendClientMessage(playerid, -1, "LEFT"); else if(lr == KEY_RIGHT) SendClientMessage(playerid, -1, "RIGHT"); return 1; }
Related Callbacks
The following callbacks might be useful as well, as they are related to this callback in one way or another.
- OnPlayerKeyStateChange: Called when a player's keystate change.