ToggleControl
Jump to navigation
Jump to search
Enables or disables the use of a gta control for a specified player.
Syntax
bool toggleControl ( player thePlayer, string control, bool enabled )
Required Arguments
- thePlayer: The player you wish to toggle the control ability of.
- control: The control that you want to toggle the ability of.
- enable: A boolean value representing whether or not the key will be usable or not.
Example
This function will disable the use of the vehicle secondary-fire key for anyone in a hydra, consequently removing the ability to fire rockets.
addEventHandler ( "onPlayerEnterVehicle", root, "onPlayerEnterVehicle" ) function onPlayerEnterVehicle ( theVehicle, seat, jacked ) if ( getVehicleID ( theVehicle ) == 520 ) then -- if they entered a hydra toggleControl ( source, "vehicle_secondary_fire", false ) -- disable their fire key else -- if they entered another vehicle toggleControl ( source, "vehicle_secondary_fire", true ) -- enable their fire key end end
See Also
- addCommandHandler
- bindKey
- executeCommandHandler
- getCommandHandlers
- getFunctionsBoundToKey
- getKeyBoundToFunction
- isControlEnabled
- removeCommandHandler
- toggleAllControls
- toggleControl
- unbindKey