Apo Posted June 1, 2016 Posted June 1, 2016 hi please help me how to make shot down safe command for stop all resource my server and shot down server only god (الله) اشهد ان لا اله الا الله واشهد ان محمد رسول الله
tosfera Posted June 1, 2016 Posted June 1, 2016 you can use stopResource to stop all your resources, you should do it 1 by 1 so they get shut down normally and the event onResourceStop will be called. Save all your data in there, if needed. After that use shutdown to turn the server off. If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]
Apo Posted June 1, 2016 Author Posted June 1, 2016 my code not work local resourcesToWaitFor = { "admin","account" } local waitingForResources = {} local doShutdown = false addCommandHandler("safeshutdown", function(thePlayer) outputChatBox("Safely shutting down the server...") for k, resourceName in ipairs(resourcesToWaitFor) do local resource = getResourceFromName(resourceName) if(resource)then waitingForResources[resource] = true end end doShutdown = true for resource, resourceWaitState in pairs(waitingForResources) do stopResource(resource) end end, true, false) addEventHandler("onResourceStop", root, function(stoppedResource) if(doShutdown and waitingForResources[stoppedResource])then waitingForResources[stoppedResource] = false for resource, resourceState in pairs(waitingForResources) do if(resourceWaitState)then return false end end shutdown("The server has safely been shutdown.") end end) only god (الله) اشهد ان لا اله الا الله واشهد ان محمد رسول الله
Gravestone Posted June 6, 2016 Posted June 6, 2016 First, add a code to every resource to save the data onResourceStop. When you're done, then add this code to a resource which has the right to command.shutdown: addCommandHandler ( "safeshutdown", function ( player, command, ... ) if ( hasObjectPermissionTo ( player, "function.shutdown" ) ) then local reason = table.concat({...}," ") local resources = getResources() for i,v in ipairs(resources) do stopResource(v) shutdown ( reason or "" ) end end end ) Clan war system http://sh.st/7r4nI
ViRuZGamiing Posted June 6, 2016 Posted June 6, 2016 First, add a code to every resource to save the data onResourceStop. When you're done, then add this code to a resource which has the right to command.shutdown: addCommandHandler ( "safeshutdown", function ( player, command, ... ) if ( hasObjectPermissionTo ( player, "function.shutdown" ) ) then local reason = table.concat({...}," ") local resources = getResources() for i,v in ipairs(resources) do stopResource(v) shutdown ( reason or "" ) end end end ) You're shutting down the server every iteration (so 1 resource would stop and then the server would stop) "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Gravestone Posted June 6, 2016 Posted June 6, 2016 I've tried the code, it works fine. Clan war system http://sh.st/7r4nI
Apo Posted June 7, 2016 Author Posted June 7, 2016 how to First, add a code to every resource to save the data onResourceStop? only god (الله) اشهد ان لا اله الا الله واشهد ان محمد رسول الله
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