zombienation Posted March 10, 2012 Share Posted March 10, 2012 Hello, Is there a way to make it possible for resources to restart automaticly after a amount of time? Thx Link to comment
Castillo Posted March 10, 2012 Share Posted March 10, 2012 Of course, use: setTimer + restartResource Link to comment
drk Posted March 10, 2012 Share Posted March 10, 2012 (edited) setTimer ( function ( ) for k, v in ipairs ( getResources ( ) ) do -- get all resources restartResource ( v ) -- restart all resources end -- end the for-loop end, 3600000, 0 ) -- time and times to run 3600000 = 1 hour Code updated. Edited March 10, 2012 by Guest Link to comment
Castillo Posted March 10, 2012 Share Posted March 10, 2012 The spaces on the milliseconds won't let it work. Link to comment
bandi94 Posted March 10, 2012 Share Posted March 10, 2012 you need to add admin rights to the resource ResourceName={} --here put your resource names like ResourceName={"resource1","reasource2"} local tim=60000 -- time when to restart (1min) local amount= 1 -- how many time to restart ( 0 for infinit ) function restart() for i,v in pairs">pairs(ResourceName) do restartResource( getResourceFromName(v)) outputChatBox("Resource: "..v.." was restarted" end end setTimer(restart,tim,amount) LUA bug ResourceName={} --here put your resource names like ResourceName={"resource1","reasource2"} local tim=60000 -- time when to restart (1min) local amount= 1 -- how many time to restart ( 0 for infinit ) function restart() for i,v in pairs(ResourceName) do restartResource( getResourceFromName(v)) outputChatBox("Resource: "..v.." was restarted" end end setTimer(restart,tim,amount) Link to comment
drk Posted March 10, 2012 Share Posted March 10, 2012 (edited) local resources = { 'myResource', 'myResource2' } local time = 60000 local timesToRun = 0 setTimer ( function ( ) for k, v in pairs ( resources ) do restartResource ( getResourceFromName ( v ) ) end end, time,timesToRun) Please tabulate your code properly. And as you said, you need to put your resource in ACL Group "Admin" if you want to script restart resources else you will get error Acess Denied. Edited March 10, 2012 by Guest Link to comment
Castillo Posted March 10, 2012 Share Posted March 10, 2012 local resourcesToRestart = { "test_resource", "test_resource2" } -- Resource names to restart. local timeInterval = 60000 -- The number of milliseconds that should elapse before the function is called. (the minimum is 50) (1000 milliseconds = 1 second) local timesToExecute = 1 -- The number of times you want the timer to execute, or 0 for infinite repetitions function restartResources() for index, resourceName in ipairs ( resourcesToRestart ) do if getResourceFromName ( resourceName ) then restartResource( getResourceFromName ( resourceName ) ) outputDebugString ( "Resource: ".. resourceName .." was restarted") end end end setTimer( restartResources, timeInterval, timesToExecute ) 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