SetTrafficLightsLocked: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with '__NOTOC__ {{Server client function}} Toggles whether you want the traffic lights to be locked. If the lights are locked, it means they won't change unless you do [[setTrafficLigh…')
 
Line 15: Line 15:


==Example==
==Example==
This example doesn't exist
This example toggles traffic lights between 'locked' and 'unlocked'.
 
<syntaxhighlight lang="lua">
function toggleTrafficLights()
    if areTrafficLightsLocked() then -- See if traffic lights are currently locked
setTrafficLightsLocked(false) -- unlock traffic lights if they are currently locked
    else
setTrafficLightsLocked(true) -- lock traffic lights if they are not locked
    end
end
-- add command handler for command which toggles lights
addCommandHandler("toggletrafficlights",toggleTrafficLights)
</syntaxhighlight>


==See Also==
==See Also==

Revision as of 11:54, 12 August 2010

Toggles whether you want the traffic lights to be locked. If the lights are locked, it means they won't change unless you do setTrafficLightState.

Syntax

bool setTrafficLightsLocked ( bool toggle )

Required Arguments

  • toggle: A bool indicating whether you want the traffic lights to change automatically, or not

Returns

Returns true if the successful, false otherwise.

Example

This example toggles traffic lights between 'locked' and 'unlocked'.

function toggleTrafficLights()
    if areTrafficLightsLocked() then -- See if traffic lights are currently locked
	setTrafficLightsLocked(false) -- unlock traffic lights if they are currently locked
    else
	setTrafficLightsLocked(true) -- lock traffic lights if they are not locked
    end
end
-- add command handler for command which toggles lights
addCommandHandler("toggletrafficlights",toggleTrafficLights)

See Also