local titleFont = "verdana-11px-rounded" local OPCODE = 134 function init() connect(Creature, { onAppear = requestData, }) ProtocolGame.registerExtendedOpcode(OPCODE, handleData) end function terminate() disconnect(Creature, { onAppear = requestData, }) ProtocolGame.unregisterExtendedOpcode(OPCODE, handleData) end function requestData(creature) if creature:isPlayer() then local tbl = { creature = creature:getId() } local protocolGame = g_game.getProtocolGame() if protocolGame then protocolGame.sendExtendedOpcode(protocolGame,OPCODE, json.encode(tbl)) end end end function handleData(protocol, code, buffer) local json_status, json_data = pcall(function () return json.decode(buffer) end) if not json_status then g_logger.error("JSON error: " .. json_data) return false end local data = json_data local response = json_data.response if data ~= nil then if response == "SetGuildNick" then updateTitle(data.creatureId, data.guildNick) elseif response == "SetGuildName" then updateTitle(data.creatureId, data.guildName) end end return end function updateTitle(creatureId, guildName) local target = g_map.getCreatureById(creatureId) if target then target:setTitle(guildName, titleFont,"#fdf3cd") end return end