ToggleControl: Difference between revisions

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


==Syntax==  
==Syntax==  
Line 13: Line 14:
This function will disable the use of the vehicle secondary-fire key for anyone in a Hydra, consequently removing the ability to fire rockets.
This function will disable the use of the vehicle secondary-fire key for anyone in a Hydra, consequently removing the ability to fire rockets.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler ( "onPlayerEnterVehicle", root, "onPlayerEnterVehicle" )
function onPlayerEnterVehicle ( theVehicle, seat, jacked )
function onPlayerEnterVehicle ( theVehicle, seat, jacked )
  if ( getVehicleID ( theVehicle ) == 520 ) then -- if they entered a hydra
    if ( getVehicleID ( theVehicle ) == 520 ) then -- if they entered a hydra
    toggleControl ( source, "vehicle_secondary_fire", false ) -- disable their fire key
        toggleControl ( source, "vehicle_secondary_fire", false ) -- disable their fire key
  else -- if they entered another vehicle
    else -- if they entered another vehicle
    toggleControl ( source, "vehicle_secondary_fire", true ) -- enable their fire key
        toggleControl ( source, "vehicle_secondary_fire", true ) -- enable their fire key
  end
    end
end
end
addEventHandler ( "onPlayerEnterVehicle", root, onPlayerEnterVehicle )
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 17:09, 15 August 2007

Enables or disables the use of a GTA control for a specific player.

Syntax

bool toggleControl ( player thePlayer, string control, bool enabled ) 

Required Arguments

  • thePlayer: The player you wish to toggle the control ability of.
  • control: The control that you want to toggle the ability of. See control names for a list of possible controls.
  • enable: A boolean value representing whether or not the key will be usable or not.

Example

This function will disable the use of the vehicle secondary-fire key for anyone in a Hydra, consequently removing the ability to fire rockets.

function onPlayerEnterVehicle ( theVehicle, seat, jacked )
    if ( getVehicleID ( theVehicle ) == 520 ) then -- if they entered a hydra
        toggleControl ( source, "vehicle_secondary_fire", false ) -- disable their fire key
    else -- if they entered another vehicle
        toggleControl ( source, "vehicle_secondary_fire", true ) -- enable their fire key
    end
end
addEventHandler ( "onPlayerEnterVehicle", root, onPlayerEnterVehicle )

See Also