IsControlEnabled: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool isControlEnabled ( player thePlayer, string control ) | bool isControlEnabled ( player thePlayer, string control ) | ||
Line 11: | Line 12: | ||
*'''thePlayer:''' The player you wish the control status of. | *'''thePlayer:''' The player you wish the control status of. | ||
*'''control:''' The control you wish to check. See [[control names]] for a list of possible controls. | *'''control:''' The control you wish to check. See [[control names]] for a list of possible controls. | ||
</section> | |||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua">bool isControlEnabled ( string control ) </syntaxhighlight> | |||
===Required Arguments=== | |||
*'''control:''' The control you wish to check. See [[control names]] for a list of possible controls. | |||
</section> | |||
===Returns=== | ===Returns=== | ||
Line 16: | Line 26: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <section name="Example 1" class="server" show="true"> | ||
-- | This example uses a command handler to allow a player to toggle whether he can use vehicle weapons by disabling or enabling the primary and secondary vehicle fire keys. The command handler is trigged with 'toggleweapons' | ||
<syntaxhighlight lang="lua">function changeWeaponControls ( player, commandName ) | |||
-- | --Check to see if the player can use primary/secondary vehicle fire controls | ||
primaryWeaponControl = isControlEnabled ( player, "vehicle_fire" ) | |||
</syntaxhighlight> | secondaryWeaponControl = isControlEnabled ( player, "vehicle_secondary_fire" ) | ||
--Toggle the use of the primary vehicle fire control ability. | |||
if ( primaryWeaponControl == true ) then | |||
toggleControl ( player, "vehicle_fire", false ) | |||
outputChatBox ( "Disabled your ability to use primary vehicle weapons." ) | |||
else | |||
toggleControl ( player, "vehicle_fire", true ) | |||
outputChatBox ( "Enabled your ability to use primary vehicle weapons." ) | |||
end | |||
--Toggle the use of the secondar vehicle fire control ability. | |||
if ( secondaryWeaponControl == true ) then | |||
toggleControl ( player, "vehicle_secondary_fire", false ) | |||
outputChatBox ( "Disabled your ability to use secondary vehicle weapons." ) | |||
else | |||
toggleControl ( player, "vehicle_secondary_fire", true ) | |||
outputChatBox ( "Enabled your ability to use secondary vehicle weapons." ) | |||
end | |||
end | |||
addCommandHandler ( "toggleweapons", changeWeaponControls )</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{Input functions}} | |||
{{ | |||
Latest revision as of 19:54, 1 April 2013
Checks whether a GTA control is enabled or disabled for a certain player.
Syntax
Click to collapse [-]
Serverbool isControlEnabled ( player thePlayer, string control )
Required Arguments
- thePlayer: The player you wish the control status of.
- control: The control you wish to check. See control names for a list of possible controls.
Click to collapse [-]
Clientbool isControlEnabled ( string control )
Required Arguments
- control: The control you wish to check. See control names for a list of possible controls.
Returns
Returns true if control is enabled, false otherwise.
Example
Click to collapse [-]
Example 1This example uses a command handler to allow a player to toggle whether he can use vehicle weapons by disabling or enabling the primary and secondary vehicle fire keys. The command handler is trigged with 'toggleweapons'
function changeWeaponControls ( player, commandName ) --Check to see if the player can use primary/secondary vehicle fire controls primaryWeaponControl = isControlEnabled ( player, "vehicle_fire" ) secondaryWeaponControl = isControlEnabled ( player, "vehicle_secondary_fire" ) --Toggle the use of the primary vehicle fire control ability. if ( primaryWeaponControl == true ) then toggleControl ( player, "vehicle_fire", false ) outputChatBox ( "Disabled your ability to use primary vehicle weapons." ) else toggleControl ( player, "vehicle_fire", true ) outputChatBox ( "Enabled your ability to use primary vehicle weapons." ) end --Toggle the use of the secondar vehicle fire control ability. if ( secondaryWeaponControl == true ) then toggleControl ( player, "vehicle_secondary_fire", false ) outputChatBox ( "Disabled your ability to use secondary vehicle weapons." ) else toggleControl ( player, "vehicle_secondary_fire", true ) outputChatBox ( "Enabled your ability to use secondary vehicle weapons." ) end end addCommandHandler ( "toggleweapons", changeWeaponControls )
See Also
- addCommandHandler
- bindKey
- executeCommandHandler
- getCommandHandlers
- getFunctionsBoundToKey
- getKeyBoundToFunction
- isControlEnabled
- removeCommandHandler
- toggleAllControls
- toggleControl
- unbindKey