ToggleAllControls: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (typofix)
(15 intermediate revisions by 9 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__
Enables or disables the use of a all gta controls for a specified player.
{{Server client function}}
Enables or disables the use of all GTA controls for a specified player.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">bool toggleAllControls ( player thePlayer, bool enabled ) </syntaxhighlight>  
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">bool toggleAllControls ( player thePlayer, bool enabled, [ bool gtaControls = true, bool mtaControls = true ] ) </syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''thePlayer:''' The player you wish to toggle the control ability of.
*'''thePlayer:''' The player you wish to toggle the control ability of.
*'''enable:''' A boolean value representing whether or not the controls will be usable or not.
*'''enabled:''' A boolean value representing whether or not the controls will be usable.
 
===Optional Arguments===
{{OptionalArg}}
*'''gtaControls:''' A boolean deciding whether the ''enabled'' parameter will affect GTA's internal controls.
*'''mtaControls:''' A boolean deciding whether the ''enabled'' parameter will affect MTA's own controls., e.g. chatbox.
</section>
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">bool toggleAllControls ( bool enabled, [ bool gtaControls = true, bool mtaControls = true ] ) </syntaxhighlight>
 
===Required Arguments===
*'''enabled:''' A boolean value representing whether or not the controls will be usable.
 
===Optional Arguments===
{{OptionalArg}}
*'''gtaControls:''' A boolean deciding whether the ''enabled'' parameter will affect GTA's internal controls.
*'''mtaControls:''' A boolean deciding whether the ''enabled'' parameter will affect MTA's own controls., e.g. chatbox.
</section>
 
===Returns===
This function returns ''true'' if controls were toggled successfully, false otherwise.


==Example==   
==Example==   
This function will disable the use of all controls for a freeze function, which will be used everytime someone enters a vehicle.
<section name="Server" class="server" show="true">
This function will disable the use of all controls in order to freeze a player, which will be used every time someone enters a vehicle.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function freezeThisDude ( player, time )
function freezeThisDude ( thePlayer, freezeTime )
  toggleAllControls ( player, false ) -- disable this players controls
    toggleAllControls ( thePlayer, false )                         -- disable this player's controls
  setTimer ( "toggleAllControls", time, 1, player, true ) -- enable this players controls after the specified time
    setTimer ( toggleAllControls, freezeTime, 1, thePlayer, true ) -- enable this player's controls after the specified time
end
end


addEventHandler ( "onPlayerEnterVehicle", root, "onPlayerEnterVehicle" )
function freezeOnEnterVehicle ( theVehicle, seat, jacked )
function onPlayerEnterVehicle ( vehicle, seat, jacked )
    freezeThisDude ( source, 5000 ) -- 'freeze' him for 5000ms = 5 seconds
  freezeThisDude ( source, 5000 ) -- 'freeze' him for 5000ms/5secs
end
end
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), freezeOnEnterVehicle )
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Input functions}}
{{Input functions}}

Revision as of 13:42, 16 May 2014

Enables or disables the use of all GTA controls for a specified player.

Syntax

Click to collapse [-]
Server
bool toggleAllControls ( player thePlayer, bool enabled, [ bool gtaControls = true, bool mtaControls = true ] ) 

Required Arguments

  • thePlayer: The player you wish to toggle the control ability of.
  • enabled: A boolean value representing whether or not the controls will be usable.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • gtaControls: A boolean deciding whether the enabled parameter will affect GTA's internal controls.
  • mtaControls: A boolean deciding whether the enabled parameter will affect MTA's own controls., e.g. chatbox.
Click to collapse [-]
Client
bool toggleAllControls ( bool enabled, [ bool gtaControls = true, bool mtaControls = true ] ) 

Required Arguments

  • enabled: A boolean value representing whether or not the controls will be usable.

Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.

  • gtaControls: A boolean deciding whether the enabled parameter will affect GTA's internal controls.
  • mtaControls: A boolean deciding whether the enabled parameter will affect MTA's own controls., e.g. chatbox.

Returns

This function returns true if controls were toggled successfully, false otherwise.

Example

Click to collapse [-]
Server

This function will disable the use of all controls in order to freeze a player, which will be used every time someone enters a vehicle.

function freezeThisDude ( thePlayer, freezeTime )
    toggleAllControls ( thePlayer, false )                         -- disable this player's controls
    setTimer ( toggleAllControls, freezeTime, 1, thePlayer, true ) -- enable this player's controls after the specified time
end

function freezeOnEnterVehicle ( theVehicle, seat, jacked )
    freezeThisDude ( source, 5000 ) -- 'freeze' him for 5000ms = 5 seconds
end
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), freezeOnEnterVehicle )

See Also