Jump to content

How to respawn car [Help]


slotman

Recommended Posts

c

function triggerRespawn() 
triggerServerEvent ( "respawn", getLocalPlayer() )  
end 
addCommandHandler("vhrespawn",triggerRespawn) 

s

-------------------------------------------------------------------- 
--* Command vh respawn system *------------------------------------- 
--* main_s.lua *---------------------------------------------------- 
--* Made by kimmis *------------------------------------------------ 
--* Do not fuckin remove this box *--------------------------------- 
-------------------------------------------------------------------- 
  
function respawn() 
local accountname = getAccountName (getPlayerAccount(source)) 
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then 
outputChatBox("15 min") 
setTimer(function () 
local vehicles = getElementsByType ( "vehicle" )  
for k, vehicle in ipairs ( vehicles ) do 
if checkEmpty( vehicle ) then 
local seats = getVehicleMaxPassengers(vehicle) 
resetVehicleIdleTime ( vehicle )  
respawnVehicle ( vehicle ) 
end 
end 
end, 15000, 1) 
end  
end 
addEvent( "respawn", true ) 
addEventHandler( "respawn", getRootElement(), respawn ) 
  
function checkEmpty( vehicle ) 
local passengers = getVehicleMaxPassengers( vehicle ) 
if type( passengers ) == 'number' then 
for seat = 0, passengers do 
if getVehicleOccupant( vehicle, seat ) then 
return false 
end 
end 
end 
return true 
end 
  
  

*Edit no command to respawn Auto 1 hr

Link to comment
No onVehicleExplode . respawn car all .

I'm not sure if there's a function to respawn a vehicle to it originally was, i haven't really checked for it. Although, if there isn't you can just store the original coordinates in setElementData, then once an hour loop threw the vehicles and use getElementData and setElementPosition to put them where they originally were.

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