OnPlayerGameKeysChange
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".
Syntax
function onPlayerGameKeysChange( player, oldKey, newKey )
Parameters
- Player player - The player who changes the keys.
- old - Player's old key which was pressed before pressing the new one.
- new - Players new key. recently pressed key.
Example
In This Example, When a player will move "FORWARD", player will receive a message "you are moving forward"...no matter what button player has set to move forward... If "BACKWARDS", player will receive a message "you are moving backward"...no matter what button player has set to move backwards... If "RIGHT", player will receive a message "you are moving to right side" ... no matter what button player has set to move right side... and If "LEFT", player will receive a message "you are moving to left side "... no matter what button player has set to move left side...
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 BACKWARDS 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 to right side" );
}
else if ( newKey == 8192 ) // this is the id of LEFT game key.
{
PrivMessage( player, "you are moving to left side" );
}
}
To Get The Keys ID use this.
function onPlayerGameKeysChange( player, oldKey, newKey )
{
if ( newKey )
{
PrivMessage( player, "recently pressed key's ID: "+newKey );
}
}
here are some constants by Gudio.
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
Notes
Function PrivMessage was used in this example
To know more about this function. visit [here]
Related Functions
- onPlayerJoin( player )
- onPlayerPart( player, reason )
- onPlayerRequestClass( player, classID )
- onPlayerRequestSpawn( player )
- onPlayerSpawn( player )
- onPlayerDeath( player, reason )
- onPlayerKill( killer, player, reason, bodypart )
- onPlayerTeamKill( killer, player, reason, bodypart )
- onPlayerChat( player, message )
- onPlayerCommand( player, command, arguments )
- onPlayerPM( player, playerTo, message )
- onPlayerBeginTyping( player )
- onPlayerEndTyping( player )
- onLoginAttempt( playerName, password, ipAddress )
- onNameChangeable( player ) // Currently can't work.
- onPlayerMove( player, lastX, lastY, lastZ, newX, newY, newZ )
- onPlayerHealthChange( player, lastHP, newHP )
- onPlayerArmourChange( player, lastArmour, newArmour )
- onPlayerWeaponChange( player, oldWep, newWep )
- onKeyDown( player, bindID )
- onKeyUp( player, bindID )
- onPlayerAwayChange( player, newStatus )
- onPlayerSpectate( player, target )
- onPlayerCrashDump( player, crashReport )
- onPlayerNameChange( player, oldName, newName )
- onPlayerActionChange( player, oldAction, newAction )
- onPlayerStateChange( player, oldState, newState )
- onPlayerOnFireChange( player, isOnFireNow )
- onPlayerCrouchChange( player, isCrouchingNow )
- onPlayerGameKeysChange( player, oldKeys, newKeys )