Advertisement
Guest User

Untitled

a guest
Apr 28th, 2020
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. -- (c) jas, wtfpl
  2.  
  3. local regen = {}
  4. local cooldown = {}
  5.  
  6. local function regenerate(player)
  7. local hp = player:get_hp()
  8. if hp < 100 then
  9. local name = player:get_player_name()
  10. if cooldown[name] and cooldown[name] > 0 then
  11. cooldown[name] = cooldown[name] - 1
  12. else
  13. cooldown[name] = nil
  14. if minetest.check_player_privs(name, "godmode") then
  15. player:set_hp(100)
  16. else
  17. player:set_hp(hp + 2)
  18. end
  19. end
  20. end
  21. minetest.after(0.34, regenerate, player)
  22. end
  23.  
  24. minetest.register_privilege("godmode", {
  25. give_to_singleplayer = false,
  26. give_to_admin = false,
  27. })
  28.  
  29. minetest.register_on_joinplayer(function(player)
  30. player:set_properties({hp_max = 100})
  31. end)
  32.  
  33. minetest.register_on_player_hpchange(function(player, hp_change, reason)
  34. if hp_change > 0 then
  35. return
  36. end
  37. local name = player:get_player_name()
  38. if minetest.check_player_privs(name, "godmode") then
  39. return
  40. end
  41. cooldown[name] = 10
  42. end)
  43.  
  44. minetest.register_on_joinplayer(function(player)
  45. regen[player:get_player_name()] = true
  46. regenerate(player)
  47. end)
  48.  
  49. minetest.register_on_leaveplayer(function(player)
  50. regen[player:get_player_name()] = nil
  51. end)
  52. ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement