illestiraqi Posted February 27, 2013 Share Posted February 27, 2013 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
DNL291 Posted February 27, 2013 Share Posted February 27, 2013 (edited) function triggerRespawn() triggerServerEvent( "respawn", localPlayer ) end setTimer(triggerRespawn, 600000, 0) Edited February 27, 2013 by Guest Link to comment
codeluaeveryday Posted February 27, 2013 Share Posted February 27, 2013 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now