ToggleControl: Difference between revisions
Jump to navigation
Jump to search
Dmitry7zip (talk | contribs) m (Fixed arg name in "Required Arguments") |
|||
Line 11: | Line 11: | ||
*'''thePlayer:''' The player you wish to toggle the control ability of. | *'''thePlayer:''' The player you wish to toggle the control ability of. | ||
*'''control:''' The control that you want to toggle the ability of. See [[control names]] for a list of possible controls. | *'''control:''' The control that you want to toggle the ability of. See [[control names]] for a list of possible controls. | ||
*''' | *'''enabled:''' A boolean value representing whether or not the key will be usable or not. | ||
</section> | </section> | ||
<section name="Client" class="client" show="true"> | <section name="Client" class="client" show="true"> | ||
Line 18: | Line 18: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''control:''' The control that you want to toggle the ability of. See [[control names]] for a list of possible controls. | *'''control:''' The control that you want to toggle the ability of. See [[control names]] for a list of possible controls. | ||
*''' | *'''enabled:''' A boolean value representing whether or not the key will be usable or not. | ||
</section> | </section> | ||
Revision as of 10:27, 3 January 2015
This article needs checking. | |
Reason(s): By enabling a control all bindings belonging to it seem to be deleted. (tested clientside) --NeonBlack 16:48, 28 August 2009 (UTC) |
Enables or disables the use of a GTA control for a specific player.
Syntax
Click to collapse [-]
Serverbool 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. See control names for a list of possible controls.
- enabled: A boolean value representing whether or not the key will be usable or not.
Click to collapse [-]
Clientbool toggleControl ( string control, bool enabled )
Required Arguments
- control: The control that you want to toggle the ability of. See control names for a list of possible controls.
- enabled: A boolean value representing whether or not the key will be usable or not.
Returns
This function true if the control was set successfully, false otherwise.
Example
Click to collapse [-]
Example 1This function will disable the use of the vehicle secondary-fire key for anyone in a Hydra, consequently removing the ability to fire rockets.
function disableFireForHydra ( theVehicle, seat, jacked ) if ( getElementModel ( 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 addEventHandler ( "onPlayerVehicleEnter", getRootElement(), disableFireForHydra )
Click to collapse [-]
Example 2This function will disable the use of the vehicle secondary-fire key for anyone in a Hydra, consequently removing the ability to fire rockets.
function disableFireForHydra ( theVehicle, seat ) if ( getElementModel ( theVehicle ) == 520 ) then -- if they entered a hydra toggleControl ( "vehicle_secondary_fire", false ) -- disable their fire key else -- if they entered another vehicle toggleControl ( "vehicle_secondary_fire", true ) -- enable their fire key end end addEventHandler ( "onClientPlayerVehicleEnter", getLocalPlayer(), disableFireForHydra )
See Also
- addCommandHandler
- bindKey
- executeCommandHandler
- getCommandHandlers
- getFunctionsBoundToKey
- getKeyBoundToFunction
- isControlEnabled
- removeCommandHandler
- toggleAllControls
- toggleControl
- unbindKey