Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. function displayAdminM(message)
  2. for k, arrayPlayer in ipairs(getElementsByType('player')) do
  3. local logged = getElementData(arrayPlayer, "loggedin")
  4. if (logged) then
  5. if getElementData(arrayPlayer, "admin_level") >= 1 then
  6. outputChatBox("ResWarn: " .. message, arrayPlayer, 255, 194, 14)
  7. end
  8. end
  9. end
  10. end
  11.  
  12. local attempts = { 0, 0 }
  13. local count = 0
  14. function checkRes(res)
  15. for i, res in ipairs(mainRes) do
  16. local resName = getResourceFromName(res)
  17. if (resName) then
  18. local cState = getResourceState(resName)
  19. if (cState ~= "running") then
  20. displayAdminM("Resource '" .. res .. "' was not running. Attempting to start missing resource.")
  21. local startingRes = startResource(resName, true)
  22. if (attempts[i] < 4) then
  23. if not (startingRes) then
  24. displayAdminM("Fail to load Resource '" .. res .. "'.")
  25. local nreasonRes = getResourceLoadFailureReason(resName)
  26. --displayAdminM("Reason: " .. nreasonRes)
  27. attempts[i] = attempts[i] + 1
  28. else
  29. displayAdminM("Resource '" .. res .. "' started successfully.")
  30. end
  31. end
  32. end
  33. count = count + 1
  34.  
  35. if count == #mainRes then
  36. count = 0
  37. end
  38. end
  39. end
  40. end
  41. addEventHandler("onResourceStart", getResourceRootElement(),
  42. function()
  43. setTimer(checkRes, 60000, 0)
  44. end
  45. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement