Postado Fevereiro 16, 2019 6 anos gente estou com um erro no meu real castle, ao iniciar está tudo perfeito, inicia o evento posso entrar para dominar o castelo, só que ao acabar o tempo para, e irem todos os players para fora do evento dar este erro na minha distro tfs 0.4 me ajudem porfavor [3:29:00.510] [Error - GlobalEvent Interface] [3:29:00.572] data/globalevents/scripts/realCastleClose.lua:onTime [3:29:00.572] Description: [3:29:00.572] data/lib/realCastle.lua:80: attempt to call global 'getTomorrowsDate' (a nil value) [3:29:00.572] stack traceback: [3:29:00.588] data/lib/realCastle.lua:80: in function 'close' [3:29:00.588] data/globalevents/scripts/realCastleClose.lua:2: in function <data/globalevents/scripts/realCastleClose.lua:1> [3:29:00.588] [Error - GlobalEvents::timer] Couldn't execute event: Close Castle Arquivo Datata/Lib/realCastle if not RealCastle then RealCastle = { openStorage = 722374, guildStorage = 722375, dateStorages = {722376,722377,722378} } function RealCastle:isInside(cid) local thingPos = getThingPos(cid) local areas = { {{x = 1921, y = 484, z = 6}, {x = 2098, y = 607, z = 6}}, {{x = 2187, y = 396, z = 6}, {x = 2264, y = 511, z = 6}}, {{x = 2442, y = 416, z = 4}, {x = 2604, y = 521, z = 4}}, {{x = 2446, y = 391, z = 5}, {x = 2619, y = 543, z = 5}}, {{x = 2091, y = 449, z = 6}, {x = 2166, y = 508, z = 6}}, {{x = 1907, y = 606, z = 6}, {x = 2099, y = 735, z = 6}}, {{x = 2653, y = 442, z = 6}, {x = 2741, y = 559, z = 6}}, {{x = 2653, y = 442, z = 5}, {x = 2741, y = 559, z = 5}}, {{x = 2653, y = 442, z = 4}, {x = 2741, y = 559, z = 5}}, {{x = 2277, y = 613, z = 7}, {x = 2462, y = 716, z = 7}}, {{x = 2277, y = 613, z = 6}, {x = 2462, y = 716, z = 6}}, {{x = 2277, y = 613, z = 5}, {x = 2462, y = 716, z = 5}}, {{x = 2277, y = 613, z = 4}, {x = 2462, y = 716, z = 4}}, {{x = 2242, y = 723, z = 6}, {x = 2442, y = 894, z = 6}}, {{x = 2255, y = 804, z = 7}, {x = 2282, y = 832, z = 7}}, {{x = 2103, y = 638, z = 6}, {x = 2262, y = 740, z = 6}}, {{x = 2103, y = 638, z = 7}, {x = 2262, y = 740, z = 7}}, {{x = 1899, y = 590, z = 7}, {x = 2102, y = 730, z = 7}}, {{x = 2162, y = 520, z = 6}, {x = 2308, y = 610, z = 6}} } for _, area in next, areas do if isInRange(thingPos, area[1], area[2]) then return true end end if (thingPos.x >= 2288 and thingPos.x <= 2364 and thingPos.y >= 433 and thingPos.y <= 509) or (thingPos.x >= 2148 and thingPos.x <= 2189 and thingPos.y >= 641 and thingPos.y <= 679) or (thingPos.x >= 2229 and thingPos.x <= 622 and thingPos.y >= 2320 and thingPos.y <= 704) then return true end return false end function RealCastle:getAllPlayers() local players = {} for _, pid in next, getPlayersOnline() do if self:isInside(pid) then table.insert(players, pid) end end return players end function RealCastle:removePlayers(messageType, message) local players = self:getAllPlayers() for _, pid in next, players do doPlayerSetPzLocked(pid, false) doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid))) if type(messageType) == "string" and messageType == "popup" then doPlayerPopupFYI(pid, message) else doPlayerSendTextMessage(pid, messageType, message) end end end function RealCastle:open() setGlobalStorageValue(self.openStorage, 1) setGlobalStorageValue(self.guildStorage, EMPTY_STORAGE) self:removePlayers("popup", "[Real Castle] O domínio de sua guild pelo castelo acabou e você foi trazido a seu Templo.") end function RealCastle:close() setGlobalStorageValue(self.openStorage, EMPTY_STORAGE) local tomorrow = getTomorrowsDate() local tomorrowString = tomorrow[1].."/"..tomorrow[2].."/"..tomorrow[3] for i = 1, 3 do setGlobalStorageValue(self.dateStorages, tomorrow) end local guild_id = getGlobalStorageValue(self.guildStorage) local guild_name = "" if guild_id ~= EMPTY_STORAGE then guild_name = getGuildNameByID(guild_id) self:removePlayers(MESSAGE_STATUS_CONSOLE_ORANGE, "[Real Castle] A batalha pelo domínio do castelo se encerrou com vitória da guild "..guild_name.." e você foi trazido a seu Templo.") doBroadcastMessage("[Real Castle] A batalha terminou e a guild vencedora foi "..guild_name.."! Todos os jogadores dessa guild agora podem aproveitar o castelo até amanhã às 19:00!") else guild_name = "Nenhuma GUILD" self:removePlayers(MESSAGE_STATUS_CONSOLE_ORANGE, "[Real Castle] A batalha pelo domínio do castelo se encerrou e "..guild_name.." ficou com o domínio. Você foi trazido a seu Templo.") doBroadcastMessage("[Real Castle] A batalha terminou e nenhuma guild conseguiu dominar o castelo! Amanhã às 19:00 haverá uma nova batalha!") end db.query("DELETE FROM real_castle WHERE world_id = '"..getWorldId().."'") db.query("INSERT INTO real_castle (guild_name, guild_id, tomorrow, world_id) VALUES ('"..guild_name.."', '"..guild_id.."', '"..tomorrowString.."', '"..getWorldId().."')") doSaveServer() end function RealCastle:broadcast(message) for _, pid in next, self:getAllPlayers() do doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, message) end end function RealCastle:domain(cid) setGlobalStorageValue(self.guildStorage, getPlayerGuildId(cid)) self:broadcast("[Real Castle] O jogador "..getPlayerName(cid).." da guild "..getPlayerGuildName(cid).." dominou o castelo! As outras guilds têm até às 20:00 para conseguir tirar o domínio deles, não desistam!") end function RealCastle:isDominating(cid) return getPlayerGuildId(cid) == getGlobalStorageValue(self.guildStorage) end function RealCastle:isOpen() return getGlobalStorageValue(self.openStorage) ~= EMPTY_STORAGE end function RealCastle:checkLogin(cid) if self:isInside(cid) then if not self:isDominating(cid) then doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) doPlayerPopupFYI(cid, "[Real Castle] Você foi removido do castelo pois ele não pertence mais a sua guild.") end end return true end function RealCastle:announce(message, times) if times == 0 then return true end doBroadcastMessage(message) addEvent(self.announce, 5*60000 , self, message, (times - 1)) end function RealCastle:checkOnTime() if self:isOpen() then self:close() else self:open() self:announce("[Real Castle] O acesso à área de dominar do castelo está liberado até às 20:00. Boa sorte a todas as guilds!", 11) for i = 1, 4 do addEvent(doBroadcastMessage, 60000 * i, "[Real Castle] O acesso à área de dominar do castelo está liberado até as 20:00. Boa sorte a todas as guilds!") end end return true end function RealCastle:checkOnUse(cid, item, frompos, item2, topos) if item.uid == 61466 then local guild_id = getGlobalStorageValue(self.guildStorage) local guild = guild_id > 1 and "a guild "..getGuildNameByID(guild_id).." possui o domínio" or "nenhuma guild possui o domínio do castelo" local time = getGlobalStorageValue(self.dateStorages[1]).."/"..getGlobalStorageValue(self.dateStorages[2]).."/"..getGlobalStorageValue(self.dateStorages[3]) local domain = self:isOpen() and "as guilds estão batalhando pelo domínio do castelo" or guild local msg = " ----------[Real Castle]---------\n\n\nAtualmente "..domain..".\n\nPróxima batalha: "..time.." às 19:00." doShowTextDialog(cid,8977,msg) return true end if not self:isOpen() then doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid))) return true end if not self:isDominating(cid) then self:domain(cid) doSendMagicEffect(getThingPos(cid), CONST_ME_CRAPS) else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "[Real Castle] Sua guild já está com o domínio do castelo.") end return true end function RealCastle:checkStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) if item.actionid == 61465 then if self:isOpen() then if getPlayerGuildId(cid) > 0 then if getPlayerLevel(cid) >= 250 then doSendMagicEffect(getThingPos(cid),CONST_ME_MAGIC_BLUE) return true else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "[Real Castle] Somente jogadores com level 250 ou mais podem batalhar pelo castelo.") end else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "[Real Castle] Somente jogadores com guild podem batalhar pelo castelo.") end else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "[Real Castle] O castelo não está aberto para invasões.") end doTeleportThing(cid, fromPosition) doSendMagicEffect(fromPosition, CONST_ME_POFF) elseif item.actionid == 61466 then if self:isDominating(cid) then doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Bem vindo ao Real Castle!") return true end if self:isOpen() then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "[Real Castle] Não é permitido entrar no castelo enquanto as guilds estão batalhando pelo seu domínio.") else local guild_id = getGlobalStorageValue(self.guildStorage) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, guild_id ~= EMPTY_STORAGE and "[Real Castle] Somente membros da guild "..getGuildNameByID(guild_id).." podem entrar." or "[Real Castle] Somente membros da guild dominante podem entrar.") end doTeleportThing(cid, {x = toPosition.x, y = toPosition.y + 2, z = toPosition.z}) doSendMagicEffect({x = toPosition.x, y = toPosition.y + 2, z = toPosition.z}, CONST_ME_FIREAREA) end return true end end -- if not RealCastle Arquivo Data/Globalevents/realcastleclose function onTime() RealCastle:close() return true end
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.