Jump to content

idle cars?


villr

Recommended Posts

Posted

this will look nooby beacuse im a noob in scripting but how can i make so a car that nodoy have been in for maybe 20 seconds?

how do i make it respawn?

or else if i can get help so i can do with a command so the idle cars get back?

any tips helps codes? :D

Posted (edited)
addEventHandler("onResourceStart",getRootElement(), 
function() 
    local vehicles = getElementsByType ( "vehicle" ) -- Return all the vehicles in a table 
        for k, vehicle in ipairs ( vehicles ) do -- For every vehicle do the following... 
            resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time 
            setTimer(function() blowVehicle(vehicle ) end,30000,0) 
        end 
end) 

Edited by Guest
Posted

i dont want to blow all cars just the cars that its no peoples in..

and isent there anyway to make it go back without exploding it?

Posted
  
addEventHandler("onResourceStart",getRootElement(), 
function() 
local vehicles = getElementsByType ( "vehicle" ) -- Return all the vehicles in a table 
for k, vehicle in ipairs ( vehicles ) do -- For every vehicle do the following... 
resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time 
setTimer(function() setElementPosition(vehicle,x,y,z)  end,30000,0) 
end 
end) 

Posted
addEventHandler("onResourceStart",resourceRoot, 
function() 
    for k, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
        toggleVehicleRespawn( vehicle, true ) 
        setVehicleIdleRespawnDelay( vehicle, 2000 ) 
    end 
end) 

Posted

have anybody played saes?

they got something so they can make all cars that nobody are in to respawn somehow without blow them i think.

somebody out there that knows how?

castillos script was best but noth enough beacuse u needed to go away veeery long for making it respawn.

i really need this script beacuse we are recreating a big stunt server from samp and we got so many players and they need cars ;)

Posted

i know that they blow up the cars and set the respawn delay to 1 or 10secs...

but I don't know how to check if a player is in a vehicle, so they don't die.

  • MTA Team
Posted

Edit castillo's code, see the setVehicleIdleRespawnDelay, it is set to 2 seconds (2000ms = 2secs), you edit it yourself and try doing it ;)

Posted
Edit castillo's code, see the setVehicleIdleRespawnDelay, it is set to 2 seconds (2000ms = 2secs), you edit it yourself and try doing it ;)

the problem is that you need to get so long away from the car and then it have respawn..

Posted
  
addEventHandler("onResourceStart",getRootElement(), 
function() 
local vehicles = getElementsByType ( "vehicle" ) -- Return all the vehicles in a table 
for k, vehicle in ipairs ( vehicles ) do -- For every vehicle do the following... 
resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time 
setTimer(function() setElementPosition(vehicle,x,y,z)  end,30000,0) 
end 
end) 

your code dident work

it dont have any posiston of the car so it cant set it back.

Posted

you write x,y,z where you wana to put the car if is idle or use random to don't put 2 cars on same place

ex. setElementPosition(vehicle,1600,-2000,5)

Posted

addEventHandler("onResourceStart",getRootElement(),

function()

local vehicles = getElementsByType ( "vehicle" ) -- Return all the vehicles in a table

for k, vehicle in ipairs ( vehicles ) do -- For every vehicle do the following...

resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time

setTimer(function() respawnVehicle(vehicle) end,30000,0)

end

end)

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