Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. corpses = corpses or {}
  2. corpses.list= corpses.list or {}
  3. corpses.count = corpses.count or 0
  4.  
  5. function corpses.init()
  6. local temp = gmcp.Char.Items.List
  7. if temp.location == "inv" then
  8. corpses.list = {}
  9. corpses.count = 0
  10. for k, v in ipairs(temp.items) do
  11. if v.icon == "deadbody" then
  12. table.insert(corpses.list,v.id)
  13. end
  14. end
  15. raiseEvent("corpse_update")
  16. corpses.count = #corpses.list
  17. end
  18. end
  19.  
  20. function corpses.addInv()
  21. local temp = gmcp.Char.Items.Add
  22. if temp.location=="inv" and temp.item.icon =="deadbody" then
  23. table.insert(corpses.list,temp.item.id)
  24. corpses.count= #corpses.list
  25. raiseEvent("corpse_update")
  26. end
  27. end
  28.  
  29. function corpses.removeInv()
  30. temp = gmcp.Char.Items.Remove
  31. if temp.location=="inv" and table.contains(corpses.list,temp.item.id) then
  32. for k, item in ipairs(corpses.list) do
  33. if item==temp.item.id then
  34. table.remove(corpses.list,k)
  35. corpses.count = #corpses.list
  36. raiseEvent("corpse_update")
  37. if temp.item.icon ~="deadbody" then
  38. raiseEvent("respawned",temp.item.name)
  39. end
  40. return
  41. end
  42. end
  43. end
  44. end
  45.  
  46. function corpses.clear()
  47. corpses.list = {}
  48. corpses.count = 0
  49. raiseEvent("corpse_update")
  50. end
  51.  
  52. registerAnonymousEventHandler("gmcp.Char.Items.List", "corpses.init")
  53. registerAnonymousEventHandler("sysDisConnectionEvent","corpses.clear")
  54. registerAnonymousEventHandler("gmcp.Char.Items.Add", "corpses.addInv")
  55. registerAnonymousEventHandler("gmcp.Char.Items.Remove", "corpses.removeInv")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement