ToggleAllControls

From Multi Theft Auto: Wiki
Revision as of 19:34, 29 August 2007 by Talidan (talk | contribs)
Jump to navigation Jump to search

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.
  • enable: A boolean value representing whether or not the controls will be usable or not.

Optional Arguemnts

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: To toggle the control of internal GTA controls.
  • mtaControls: To toggle the control of MTA's controls, e.g. chatbox.
Click to collapse [-]
Client
bool toggleAllControls ( bool enabled, [bool gtaControls=true, bool mtaControls=true] ) 

Required Arguments

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

Optional Arguemnts

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: To toggle the control of internal GTA controls.
  • mtaControls: To toggle the control of MTA's controls, e.g. chatbox.

Returns

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

Example

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 ( "onPlayerEnterVehicle", getRootElement(), freezeOnEnterVehicle )

See Also