Jump to content

Trancar Veículo


Recommended Posts

Posted

Olá queria saber como fazer um script de trancar veículo, e tipo, as pessoas que estiverem dentro do veículo, não poder sair!

Posted
Quote

function lockcar ( thePlayer )
    playervehicle = getPlayerOccupiedVehicle ( thePlayer )   -- 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 isn't locked) 
            setVehicleLocked ( playervehicle, true )         -- lock it
        end
    end
end

function bindLockOnSpawn ( theSpawnpoint )                     -- when a player spawns
    bindKey ( source, "l", "down", lockcar )                   -- bind the 'l' key to the 'lockcar' function
end
addEventHandler ( "onPlayerSpawn", getRootElement(), bindLockOnSpawn )

-- call 'stopVehicleEntry' whenever hunterPlayer is about to enter a vehicle:
function stopVehicleEntry ( theplayer, seat, jacked )
   cancelEvent() -- stop the event, the player will can't enter in vehicle 
end
addEventHandler("onVehicleStartEnter", getRootElement(), stopVehicleEntry)

local policeVehicles = {[598] = true,[596] = true,[597] = true,[599] = true } -- Police vehicle IDs
local policeSkins = {[280] = true,[281] = true,[282] = true,[283] = true,[284] = true,[285] = true,[286] = true } -- Police Skins
 
function exitVehicle ( thePlayer, seat, jacked ) 
   if (policeVehicles[getElementModel (source)]) and (policeSkins[getElementModel(thePlayer)]) then 
      outputChatBox ( "You're the cop! Don't exit the car!", thePlayer )  
      cancelEvent()
   end
end
addEventHandler ( "onVehicleStartExit", getRootElement(), exitVehicle)

Isso?

 

Tentei, mas n deu nd :(

 

  • Other Languages Moderators
Posted
function exitVehicle (thePlayer, seat, jacked)
    if (isVehicleLocked (source)) then 
        outputChatBox ("The door is locked! You can't exit the vehicle!", thePlayer)  
        cancelEvent()
    end
end
addEventHandler ("onVehicleStartExit", root, exitVehicle)

 

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...