Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Bestiary = {}
- Bestiary.M_Classes = {
- {id = 2048, name = "Amphibic"},
- {id = 1792, name = "Aquatic"},
- {id = 1024, name = "Bird"},
- {id = 2304, name = "Construct"},
- {id = 1280, name = "Demon"},
- {id = 1536, name = "Dragon"},
- {id = 2304, name = "Elemental"},
- {id = 4352, name = "Extra Dimensional"},
- {id = 768, name = "Fey"},
- {id = 1280, name = "Giant"},
- {id = 10, name = "Human"},
- {id = 10, name = "Humanoid"},
- {id = 10, name = "Lycanthrope"},
- {id = 10, name = "Magical"},
- {id = 10, name = "Mammal"},
- {id = 10, name = "Plant"},
- {id = 10, name = "Reptile"},
- {id = 10, name = "Slime"},
- {id = 10, name = "Undead"},
- {id = 10, name = "Vermin"}
- }
- Bestiary.S_Packets = {
- SendBestiaryData = 0xd5,
- SendBestiaryOverview = 0xd6
- }
- Bestiary.C_Packets = {
- RequestBestiaryData = 0xe1,
- RequestBestiaryOverview = 0xe2
- }
- Bestiary.sendData = function(playerId)
- local player = Player(playerId)
- if not player then
- return true
- end
- local msg = NetworkMessage()
- msg:addByte(Bestiary.S_Packets.SendBestiaryData)
- msg:addU16(#Bestiary.M_Classes) -- class count
- for k, class in ipairs(Bestiary.M_Classes) do
- msg:addString(class.name)
- msg:addU16(math.random(30)) -- total
- msg:addU16(math.random(15)) -- known
- end
- msg:sendToPlayer(player)
- end
- -- This function is not completed, only for testing pourposes
- Bestiary.overview = function(playerId, msg)
- local str = ""
- local order = {"u32", "string", "string", "string"}
- for k, type in ipairs(order) do
- if type == "byte" then
- str = str .. " | " .. msg:getByte()
- elseif type == "u16" then
- str = str .. " | " .. msg:getU16()
- elseif type == "string" then
- str = str .. " | " .. string.char(msg:getU16())
- elseif type == "u32" then
- str = str .. " | " .. msg:getU32()
- end
- end
- print("\n\n Packet: | " .. str .." \n\n")
- end
- function onRecvbyte(player, msg, byte)
- if (byte == Bestiary.C_Packets.RequestBestiaryData) then
- Bestiary.sendData(player:getId())
- elseif (byte == Bestiary.C_Packets.RequestBestiaryOverview) then
- Bestiary.overview(player:getId(), msg)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement