ToggleAllControls: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__
{{Server client function}}
Enables or disables the use of all GTA controls for a specified player.
Enables or disables the use of all GTA controls for a specified player.


Line 13: Line 14:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function freezeThisDude ( thePlayer, time )
function freezeThisDude ( thePlayer, time )
  toggleAllControls ( thePlayer, false ) -- disable this players controls
    toggleAllControls ( thePlayer, false ) -- disable this players controls
  setTimer ( "toggleAllControls", time, 1, thePlayer, true ) -- enable this players controls after the specified time
    setTimer ( toggleAllControls, time, 1, thePlayer, true ) -- enable this players controls after the specified time
end
end


addEventHandler ( "onPlayerEnterVehicle", root, "onPlayerEnterVehicle" )
function onPlayerEnterVehicle ( theVehicle, seat, jacked )
function onPlayerEnterVehicle ( theVehicle, seat, jacked )
  freezeThisDude ( source, 5000 ) -- 'freeze' him for 5000ms/5secs
    freezeThisDude ( source, 5000 ) -- 'freeze' him for 5000ms/5secs
end
end
addEventHandler ( "onPlayerEnterVehicle", root, onPlayerEnterVehicle )
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 17:01, 15 August 2007

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

Syntax

bool toggleAllControls ( player thePlayer, bool enabled, [bool gtaContols=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.

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, time )
    toggleAllControls ( thePlayer, false ) -- disable this players controls
    setTimer ( toggleAllControls, time, 1, thePlayer, true ) -- enable this players controls after the specified time
end

function onPlayerEnterVehicle ( theVehicle, seat, jacked )
    freezeThisDude ( source, 5000 ) -- 'freeze' him for 5000ms/5secs
end
addEventHandler ( "onPlayerEnterVehicle", root, onPlayerEnterVehicle )

See Also