Jump to content

[HELP] Change Script


illestiraqi

Recommended Posts

I want this script changed to every 10 minutes every vehicle re-respawns as usual but every 10 minutes. Instead of command I want it every 10 minutes please help me change it.

Client:

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

Server:

-------------------------------------------------------------------- 
--* 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("***Respawning ALL Empty Vehicles In 10 Secs, 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, 10000, 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 
  
  

Link to comment

Your way and DNL's is ineffective and can cause lag on the server, use this code:

SERVER ONLY:

-------------------------------------------------------------------- 
--* Command vh respawn system *------------------------------------- 
--* main_s.lua *---------------------------------------------------- 
--* Made by kimmis *------------------------------------------------ 
--* Do not  remove this box *--------------------------------- 
-------------------------------------------------------------------- 
  
function respawn() 
    outputChatBox("***Respawning ALL Empty Vehicles In 10 Secs, 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, 10000, 1) 
end 
  
setTimer(respawn, 600000, 0) 
  
  
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...