Jump to content

Abandoned vehicle respawn script help.


Stalker157

Recommended Posts

Hello, I'm just trying to make a respawn vehicle script for my server but it's not working.

function isVehicleOccupied(vehicle)
    assert(isElement(vehicle) and getElementType(vehicle) == "vehicle", "Bad argument @ isVehicleOccupied [expected vehicle, got " .. tostring(vehicle) .. "]")
    local _, occupant = next(getVehicleOccupants(vehicle))
    return occupant and true, occupant
end


function respawn(car)
if not isVehicleOccupied(Taxi) then 
respawnVehicle(Taxi)
end
end


function inactive(vehicle)
local car = vehicle
setTimer(respawn, 5000, 1 , car)
end
addEventHandler ("onPlayerVehicleExit", root, inactive)

I wanna make it if a player exited a vehicle he was driving it will respawn after some time(5 seconds for now, just testing), but I always get error

Quote

Bad argument @ isVehicleOccupied [expected vehicle, got nil]

Can anyone help?

Link to comment

In the respawn function you get a variable with "car" name but you use a Taxi named variable. Instead of this

function respawn(car)
if not isVehicleOccupied(Taxi) then 
respawnVehicle(Taxi)
end
end

you should try this

function respawn(car)
if not isVehicleOccupied(car) then 
respawnVehicle(car)
end
end

 

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