Jump to content

SetVehicleLocked


dontdo

Recommended Posts

Can't unlock vehicles in the colSphere

function Lock (EnterPerson) 
  
    local car = getPedOccupiedVehicle (EnterPerson) 
    local x,y,z = getElementPosition( EnterPerson )  
    local col = createColSphere ( x,y,z, 10 ) 
    local veh = getElementsWithinColShape (col, "vehicle") 
     
    if isPedInVehicle ( EnterPerson ) then 
    setVehicleLocked (car, true) 
    outputChatBox ("locked", EnterPerson) 
    end 
     
    if isPedInVehicle ( EnterPerson ) == false then  
        setVehicleLocked (veh, false) 
        outputChatBox ("Unlocked", EnterPerson) 
    end 
end 
  
addCommandHandler ("Lock", Lock, false , false) 

Link to comment
'getElementsWithinColShape' - Returns a table containing all the elements inside the colshape, of the specified type. Returns an empty table if there are no elements inside. Returns false if the colshape is invalid.
Link to comment
    function Lock (EnterPerson) 
      
        local car = getPedOccupiedVehicle (EnterPerson) 
        local x,y,z = getElementPosition( EnterPerson ) 
        local col = createColSphere ( x,y,z, 10 ) 
        local veh = getElementsWithinColShape (col, "vehicle") 
        
        if isPedInVehicle ( EnterPerson ) then 
        setVehicleLocked (car, true) 
        outputChatBox ("locked", EnterPerson) 
        end 
        
        if isPedInVehicle ( EnterPerson ) == false then 
            for i,v in pairs(veh) do 
            setVehicleLocked (v, false) 
            outputChatBox ("Unlocked", EnterPerson) 
        end 
    end 
      
    addCommandHandler ("Lock", Lock, false , false) 

Link to comment

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...