hudkit.lua 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. -- HudKit, by rubenwardy
  2. -- License: Either WTFPL or CC0, you can choose.
  3. local function hudkit()
  4. return {
  5. players = {},
  6. add = function(self, player, id, def)
  7. local name = player:get_player_name()
  8. local elements = self.players[name]
  9. if not elements then
  10. self.players[name] = {}
  11. elements = self.players[name]
  12. end
  13. elements[id] = player:hud_add(def)
  14. end,
  15. exists = function(self, player, id)
  16. local elements = self.players[player:get_player_name()]
  17. return elements and elements[id]
  18. end,
  19. change = function(self, player, id, stat, value)
  20. local elements = self.players[player:get_player_name()]
  21. if not elements or not elements[id] then
  22. return false
  23. end
  24. player:hud_change(elements[id], stat, value)
  25. return true
  26. end,
  27. remove = function(self, player, id)
  28. local elements = self.players[player:get_player_name()]
  29. if not elements or not elements[id] then
  30. return false
  31. end
  32. player:hud_remove(elements[id])
  33. elements[id] = nil
  34. return true
  35. end
  36. }
  37. end
  38. return hudkit