SetVehicleLocked: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
[[Category:Incomplete]]
__NOTOC__  
__NOTOC__  
This fake function is for use with blah & blah and does blahblahblabhalbhl
This function can be used to set a vehicle to be locked or unlocked


==Syntax==  
==Syntax==  
Line 10: Line 8:


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''vehicle:''' The vehicle which you wish to change the lock status of
 
*'''locked:''' Boolean for the status you wish to set. Set ''true'' to lock, ''false'' to unlock
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns ''true'' if the operation was successful, ''false'' otherwise.


==Example==  
==Example==  
This example does...
This example allows a player to lock is vehicle when he is inside it.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
addEventHandler ( "onPlayerSpawn", root, "onPlayerSpawn" ) --add an event handler for onPlayerSpawn
blabhalbalhb --abababa
function onPlayerSpawn ( spawnpoint ) --when a player spawns
--This line does this...
    bindKey ( source, "l", down, "lockcar", source ) --bind the 'l' key to the 'lockcar' function
mooo
end
 
function lockcar ( player )
    playervehicle = getPlayerOccupiedVehicle ( player ) --define 'playervehicle' as the vehicle the player is in
    if ( playervehicle ) then --if a player is in a vehicle
        if isVehicleLocked ( playervehicle ) then --and if the vehicle is already locked
            setVehicleLocked ( playervehicle, false ) --unlock it
        else --otherwise (if it isnt locked)
            setVehicleLocked ( playervehicle, true ) --lock it
        end
    end
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{Vehicle functions}}

Revision as of 20:15, 13 August 2006

This function can be used to set a vehicle to be locked or unlocked

Syntax

bool setVehicleLocked ( element vehicle, bool locked )            

Required Arguments

  • vehicle: The vehicle which you wish to change the lock status of
  • locked: Boolean for the status you wish to set. Set true to lock, false to unlock

Returns

Returns true if the operation was successful, false otherwise.

Example

This example allows a player to lock is vehicle when he is inside it.

addEventHandler ( "onPlayerSpawn", root, "onPlayerSpawn" ) --add an event handler for onPlayerSpawn
function onPlayerSpawn ( spawnpoint ) --when a player spawns
    bindKey ( source, "l", down, "lockcar", source ) --bind the 'l' key to the 'lockcar' function
end

function lockcar ( player )
    playervehicle = getPlayerOccupiedVehicle ( player ) --define 'playervehicle' as the vehicle the player is in
    if ( playervehicle ) then --if a player is in a vehicle
        if isVehicleLocked ( playervehicle ) then --and if the vehicle is already locked
            setVehicleLocked ( playervehicle, false ) --unlock it
        else --otherwise (if it isnt locked) 
            setVehicleLocked ( playervehicle, true ) --lock it
        end
    end
end

See Also