Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. Bestiary = {}
  2.  
  3. Bestiary.M_Classes = {
  4. {id = 2048, name = "Amphibic"},
  5. {id = 1792, name = "Aquatic"},
  6. {id = 1024, name = "Bird"},
  7. {id = 2304, name = "Construct"},
  8. {id = 1280, name = "Demon"},
  9. {id = 1536, name = "Dragon"},
  10. {id = 2304, name = "Elemental"},
  11. {id = 4352, name = "Extra Dimensional"},
  12. {id = 768, name = "Fey"},
  13. {id = 1280, name = "Giant"},
  14. {id = 10, name = "Human"},
  15. {id = 10, name = "Humanoid"},
  16. {id = 10, name = "Lycanthrope"},
  17. {id = 10, name = "Magical"},
  18. {id = 10, name = "Mammal"},
  19. {id = 10, name = "Plant"},
  20. {id = 10, name = "Reptile"},
  21. {id = 10, name = "Slime"},
  22. {id = 10, name = "Undead"},
  23. {id = 10, name = "Vermin"}
  24. }
  25.  
  26. Bestiary.S_Packets = {
  27. SendBestiaryData = 0xd5,
  28. SendBestiaryOverview = 0xd6
  29. }
  30.  
  31. Bestiary.C_Packets = {
  32. RequestBestiaryData = 0xe1,
  33. RequestBestiaryOverview = 0xe2
  34. }
  35.  
  36. Bestiary.sendData = function(playerId)
  37. local player = Player(playerId)
  38. if not player then
  39. return true
  40. end
  41. local msg = NetworkMessage()
  42. msg:addByte(Bestiary.S_Packets.SendBestiaryData)
  43. msg:addU16(#Bestiary.M_Classes) -- class count
  44. for k, class in ipairs(Bestiary.M_Classes) do
  45. msg:addString(class.name)
  46. msg:addU16(math.random(30)) -- total
  47. msg:addU16(math.random(15)) -- known
  48. end
  49. msg:sendToPlayer(player)
  50. end
  51.  
  52. -- This function is not completed, only for testing pourposes
  53. Bestiary.overview = function(playerId, msg)
  54. local str = ""
  55. local order = {"u32", "string", "string", "string"}
  56. for k, type in ipairs(order) do
  57. if type == "byte" then
  58. str = str .. " | " .. msg:getByte()
  59. elseif type == "u16" then
  60. str = str .. " | " .. msg:getU16()
  61. elseif type == "string" then
  62. str = str .. " | " .. string.char(msg:getU16())
  63. elseif type == "u32" then
  64. str = str .. " | " .. msg:getU32()
  65. end
  66. end
  67.  
  68.  
  69. print("\n\n Packet: | " .. str .." \n\n")
  70. end
  71.  
  72. function onRecvbyte(player, msg, byte)
  73. if (byte == Bestiary.C_Packets.RequestBestiaryData) then
  74. Bestiary.sendData(player:getId())
  75. elseif (byte == Bestiary.C_Packets.RequestBestiaryOverview) then
  76. Bestiary.overview(player:getId(), msg)
  77. end
  78. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement