Jump to content

[HELP] Vehicles respawning after 10mins with message alert


Brolis

Recommended Posts

Hi all, today, I would like to ask you guys, how to make, from where to get, how to get and blah... a resource, that something would be look like that:

If players is not in vehicles, after 10mins all server unused vehicles will be respawned to their positions with a alert messages:

INFO: Attention! Unused server vehicles will be respawned after 10mins!

INFO: Server vehicles successfully respawned!

If you are in vehicle, that vehicle won't be spawned, just others unused vehicles.

I know that that resource is existing, please help me, thanks a lot!

Link to comment

Please, fix this code, it doesn't writes all messages, it should write that all server unused vehicles will respawn in 15secs, in 10secs in 5secs and also all vehicles were respawned!

function respawn() 
local accountname = getAccountName (getPlayerAccount(source)) 
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then 
outputChatBox("* Respawning all empty vehicles in 5sec, get to your car to keep it!") 
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, 5000, 1) 
end 
end 
addEvent( "respawn", true ) 
addEventHandler( "respawn", getRootElement(), respawn ) 
  
function respawn60() 
local accountname = getAccountName (getPlayerAccount(source)) 
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then 
outputChatBox("* Respawning all empty vehicles in 15 secs, get to your car to keep it!") 
setTimer(function () 
triggerServerEvent ( "respawn10", getLocalPlayer() ) 
end, 15000, 1) 
end 
end 
addEvent( "respawn60", true ) 
addEventHandler( "respawn60", getRootElement(), respawn60 ) 
  
function respawn10() 
local accountname = getAccountName (getPlayerAccount(source)) 
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then 
outputChatBox("* Respawning all empty vehicles in 10 secs, get to your car to keep it!") 
setTimer(function () 
triggerServerEvent ( "respawn", getLocalPlayer() ) 
end, 10000, 1) 
end 
end 
addEvent( "respawn10", true ) 
addEventHandler( "respawn10", getRootElement(), respawn10 ) 
  
  
  
  
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 

I gess, you know what I mean to create, when you write a commands, it calls a timer to another function to do, after it calls that function other function calls other to respawn vehicles finally :D.

Help me, thanks a lot!

Edited by Guest
Link to comment

This?

function respawn() 
local accountname = getAccountName (getPlayerAccount(source)) 
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then 
outputChatBox("* Respawning ALL Empty Vehicles In 5sec, get to your car to keep it!") 
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, 5000, 1) 
end 
end 
addEvent( "respawn", true ) 
addEventHandler( "respawn", getRootElement(), respawn ) 
  
function respawn60() 
local accountname = getAccountName (getPlayerAccount(source)) 
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then 
outputChatBox("* Respawning all empty vehicles in 10 mins, get to your car to keep it!") 
setTimer(function () 
triggerServerEvent ( "respawn10", getLocalPlayer() ) 
end, 600000, 1) 
end 
end 
addEvent( "respawn60", true ) 
addEventHandler( "respawn60", getRootElement(), respawn60 ) 
  
function respawn10() 
local accountname = getAccountName (getPlayerAccount(source)) 
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then 
outputChatBox("* Respawning all empty vehicles in 10 secs, get to your car to keep it!") 
setTimer(function () 
triggerServerEvent ( "respawn", getLocalPlayer() ) 
end, 10000, 1) 
end 
end 
addEvent( "respawn10", true ) 
addEventHandler( "respawn10", getRootElement(), respawn10 ) 
  
  
  
  
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 

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