Jump to content

[Help]Fix vehicle in position


Recommended Posts

I`m trying to make a vehicle stay in a fixed position. When someone run next to the car it moves, and i don`t want this. Someone know how i can make a car fixed in some position? Script i`m using is in spoiler below.

setElementData(getPlayerFromName("Zanettinho"), "Chief", true, false) 
  
local vehicle = createVehicle(405, 2873.7998046875, 3807.2998046875, 43.799999237061, 0, 0, 83.995971679688)  
setElementData(vehicle, "Chief", true, false)  
  
addEventHandler("onVehicleStartEnter", root, 
    function(thePlayer, seat, jacked, door) 
        local vehicleOwner = getElementData(source, "Chief") 
        local gangGroup = getElementData(thePlayer, "Chief")  
        if (not vehicleOwner) then return end  
        if (gangGroup ~= vehicleOwner) then  
            outputChatBox("Esse carro e apenas para showroom!", thePlayer, 245, 20, 20, false) 
            cancelEvent()  
        end 
    end 
) 

Sorry for my bad english :? I Appreciate any help.

Link to comment
If owner exits the vehicle, just freeze it.

setElementFrozen

Well, i tried something with the link u send, and it works just fine!

Here is the full script if in the future someone need this.

setElementData(getPlayerFromName("Zanettinho"), "Chief", true, false) -- Uncomment this in order to make yourself a chief 
  
local vehicle = createVehicle(405, 2873.7998046875, 3807.2998046875, 43.799999237061, 0, 0, 83.995971679688) -- Create the vehicle 
setElementData(vehicle, "Chief", true, false) -- Give it element data in 'Chief' and make its value a boolean 'true' 
 -- get the new freeze status (the opposite of the previous state) 
        local newFreezeStatus = not currentFreezeStatus 
        -- set the new freeze status 
        setElementFrozen ( vehicle, newFreezeStatus ) 
  
addEventHandler("onVehicleStartEnter", root, 
    function(thePlayer, seat, jacked, door) 
        local vehicleOwner = getElementData(source, "Chief") -- Get the vehicle's element data on 'Chief' 
        local gangGroup = getElementData(thePlayer, "Chief") -- Get the entering player's element data on 'Chief' 
        if (not vehicleOwner) then return end -- If the vehicle doesn't have such data, then cancel 
        if (gangGroup ~= vehicleOwner) then -- If the entering player's data doesn't match the vehicle data, continue 
            outputChatBox("Esse carro e apenas para showroom!", thePlayer, 245, 20, 20, false) -- Display a warning 
            cancelEvent() -- Prevent the player from entering the vehicle 
        end 
    end 
) 

Thanks for your help WhoAmI.

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