toggleAllControls | Multi Theft Auto: Wiki Skip to content

toggleAllControls

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


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

Syntax

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.

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

Returns

  • bool: value

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

Code Examples

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", root, freezeOnEnterVehicle )