guildTitle.lua

main 42 lines · 978 bytes Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1
2
3
4local LoginEvent = CreatureEvent("guildTitle_Login")
5function LoginEvent.onLogin(player)
6 player:registerEvent("guildTitle")
7 return true
8end
9LoginEvent:register()
10local OPCODE_GUILDTITLE = 134
11
12local guildTitle = CreatureEvent("guildTitle")
13guildTitle:type("extendedopcode")
14function guildTitle.onExtendedOpcode(player, opcode, buffer)
15 if opcode and opcode == OPCODE_GUILDTITLE then
16 local json_status, json_data =
17 pcall(
18 function()
19 return json.decode(buffer)
20 end
21 )
22 local creatureID = json_data.creature
23 local creature = Creature(creatureID)
24 if creature and creature:isPlayer() then
25 local guild = creature:getGuild()
26 if guild ~= nil then
27 local data = {
28 response = "SetGuildName",
29 creatureId = creatureID,
30 name = creature:getName(),
31 guildNick = creature:getGuildNick(),
32 guildName = guild:getName(),
33 }
34 player:sendExtendedOpcode(OPCODE_GUILDTITLE,json.encode(data))
35 end
36 end
37 end
38end
39guildTitle:register()
40
41
42
Top