GetControlState: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
Gets a state of a specified player's control. | Gets a state of a specified player's control.<br/> | ||
Note: Only works for the keys MTA synchronises between clients. | Note: Only works for the keys MTA synchronises between clients. | ||
Revision as of 17:46, 8 July 2006
Gets a state of a specified player's control.
Note: Only works for the keys MTA synchronises between clients.
Syntax
bool getControlState ( player thePlayer, string control )
Required Arguments
- thePlayer: The player you wish to get the control state of.
- control: The control that you want to get the state of.
Returns
Returns the state of the control if found, 'false' otherwise.
Example
This example starts a repeating check when a player spawns, if a player presses the fire key, they'll be killed.
addEventHandler ( "onPlayerSpawn", root, "onPlayerSpawn" ) function onPlayerSpawn ( theSpawnpoint ) killPlayerIfTheyPressThisKey ( source, "fire" ) -- start a repeating check end function killPlayerIfTheyPressThisKey ( thePlayer, key ) if ( getControlState ( thePlayer, key ) ) then -- if they're pressing the fire key killPlayer ( thePlayer ) -- kill them else -- otherwise.. setTimer ( "killPlayerIfTheyPressThisKey", 500, 1, thePlayer, key ) -- call this function again in 500ms end end
See Also
- addCommandHandler
- bindKey
- executeCommandHandler
- getCommandHandlers
- getFunctionsBoundToKey
- getKeyBoundToFunction
- isControlEnabled
- removeCommandHandler
- toggleAllControls
- toggleControl
- unbindKey