onPlayerGameKeysChange

Description

This function detects the players "Game Key". for example: To move FORWARD we usually use "W" or "UP_ARROW" key. But since its a game key & its ID is "32768". It will detect that the player is moving forward. No matter what key/button player has set to move forward. Even if the player set the key "X".

NameDescription
playerThe pointer of the player
oldKeyPlayer's old key which was pressed before pressing the new one.
newKeyPlayers new key - recently pressed key

Example

In this example, when a player pressed move "FORWARD", player will receive a message "you are moving forward"... no matter what button player has set to move forward.

function onPlayerGameKeysChange(player, oldKey, newKey) {
if(newKey == 32768) // this is the id of FORWARD game key
{
PrivMessage(player, "You are moving forward");
} else if(newKey == 16384) // this is the id of BACKWARD game key
{
PrivMessage(player, "You are moving backward");
} else if(newKey == 4096) // this is the id of RIGHT game key
{
PrivMessage(player, "You are moving right side");
} else if(newKey == 8192) // this is the id of LEFT game key
{
PrivMessage(player, "You are moving left side");
}
if(newKey)
{
PrivMessage(player, "Recently pressed key ID: " + newKey);
}
}

Notes

Here are some constants of gamekeys:

  • KEY_ONFOOT_FORWARD
  • KEY_ONFOOT_BACKWARD
  • KEY_ONFOOT_LEFT
  • KEY_ONFOOT_RIGHT
  • KEY_ONFOOT_JUMP
  • KEY_ONFOOT_CROUCH
  • KEY_ONFOOT_PUNCH
  • KEY_ONFOOT_AIM
  • KEY_ONFOOT_FIRE
  • KEY_ONFOOT_NEXTWEP
  • KEY_ONFOOT_PREVWEP
  • KEY_INCAR_FORWARD
  • KEY_INCAR_BACKWARD
  • KEY_INCAR_LEFT
  • KEY_INCAR_RIGHT
  • KEY_INCAR_LOOKLEFT
  • KEY_INCAR_LOOKRIGHT
  • KEY_INCAR_LEANUP
  • KEY_INCAR_LEANDOWN