Postado Agosto 26, 2021 3 anos .Olá pessoal bom dia, Gostaria de pedir uma ajuda a vocês, possuo um sistema de Castle War que funciona perfeito, porem gostaria de fazer uma modificação nele. Que quando finalizar o evento somente o líder da guild ganhadora ganhasse um item que seria o id 10091. Alguém poderia me ajudar ?? Utilizo TFS 0.4 - 8.6 Segue abaixo o código. Spoiler realCastle = { open_storage = 100005, guild_storage = 100006, dateStorages = {100007,100008,100009}, frompos = {x = 2189, y = 522, z = 6}, topos = {x = 2282, y = 614, z = 6}, storages = { -- só modifique os storages se necessário accessTime = 100010, running = 100013 } } realCastle.open = function() setGlobalStorageValue(realCastle.open_storage,1) setGlobalStorageValue(realCastle.guild_storage,-1) setGlobalStorageValue(realCastle.storages.running, 1) end realCastle.close = function() setGlobalStorageValue(realCastle.open_storage,-1) local tomorrow = getTomorrowsDate() local tomorrowString = tomorrow[1].."/"..tomorrow[2].."/"..tomorrow[3] for i = 1, 3 do setGlobalStorageValue(realCastle.dateStorages[i], tomorrow[i]) end local players = getPlayersInArea(realCastle.frompos, realCastle.topos) if players then for _, pid in pairs(players) do doTeleportThing(pid,getTownTemplePosition(1)) end end if getGlobalStorageValue(realCastle.guild_storage) == -1 then doBroadcastMessage("[Real Castle] A batalhar terminou e nenhuma guild conseguiu dominar o castelo!") else doBroadcastMessage("[Real Castle] A batalha terminou e a guild vencedora foi "..getGuildNameByID(getGlobalStorageValue(realCastle.guild_storage)).."! Todos os jogadores dessa guild agora tem 30% a + de experiencia!") end local func = db.query or db.executeQuery func("DELETE FROM real_castle WHERE world_id = '"..getWorldId().."'") func("INSERT INTO real_castle (guild_name, guild_id, tomorrow, world_id) VALUES ('"..getGuildNameByID(getGlobalStorageValue(realCastle.guild_storage)).."', '"..getGlobalStorageValue(realCastle.guild_storage).."', '"..tomorrowString.."', '"..getWorldId().."')") setGlobalStorageValue(realCastle.storages.running, -1) doSaveServer() end realCastle.broadcast = function(message) local players = getPlayersInArea(realCastle.frompos, realCastle.topos) if players then for _, pid in pairs(players) do doPlayerSendTextMessage(pid,MESSAGE_STATUS_WARNING,message) end end end realCastle.domain = function(cid) local guild_id = getPlayerGuildId(cid) setGlobalStorageValue(realCastle.guild_storage,guild_id) doBroadcastMessage("[Real Castle] O jogador "..getPlayerName(cid).." da guild "..getPlayerGuildName(cid).." dominou o castelo! As outras guilds têm até às 22:00 para conseguir tirar o domínio deles, não desistam!") end realCastle.isDominating = function(cid) local guild_id = getPlayerGuildId(cid) return guild_id == getGlobalStorageValue(realCastle.guild_storage) end realCastle.isOpen = function() return getGlobalStorageValue(realCastle.open_storage) == 1 end --- Config by Dwarfer realCastle.isRunning = function() return getGlobalStorageValue(realCastle.storages.running) ~= -1 end
Postado Agosto 26, 2021 3 anos posta o resto do sistema, principalmente o código onde os players recebem as rewards. [*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*] DISCORD: vodkart#6090
Postado Agosto 27, 2021 3 anos Autor 15 horas atrás, Vodkart disse: posta o resto do sistema, principalmente o código onde os players recebem as rewards. Esse arquivo que postei é lib do sistema. Segue a action. Spoiler function onUse(cid, item, frompos, item2, topos) if item.uid == 61466 then local guild = getGlobalStorageValue(realCastle.guild_storage) > 1 and "a guild "..getGuildNameByID(getGlobalStorageValue(realCastle.guild_storage)).." possui o domínio" or "nenhuma guild possui o domínio do castelo" local sto = realCastle.dateStorages local gsto = getGlobalStorageValue local time = gsto(sto[1]).."/"..gsto(sto[2]).."/"..gsto(sto[3]) local domain = realCastle.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 21:00." doShowTextDialog(cid,8977,msg) return true end if not realCastle.isOpen() then doTeleportThing(cid,getTownTemplePosition(1)) return true end if not realCastle.isDominating(cid) then realCastle.domain(cid) doSendMagicEffect(getThingPos(cid), CONST_ME_CRAPS) else doPlayerSendCancel(cid,"Sua guild já está com o domínio do castelo.") end return true end
Postado Agosto 27, 2021 3 anos @DigoleraZica eu estava achando que todos da guild ganhassem o item, por isso estava procurando essa parte no código, mas pelo que vi, só estavam ganhando 30% a mais de exp... realCastle = { itemid = 10091, open_storage = 100005, guild_storage = 100006, dateStorages = {100007,100008,100009}, frompos = {x = 2189, y = 522, z = 6}, topos = {x = 2282, y = 614, z = 6}, storages = { -- só modifique os storages se necessário accessTime = 100010, running = 100013 } } function getGuildLeaderName(GuildName) -- function by vodkart local leader = db.getResult("SELECT `players`.`name` FROM `players` WHERE `players`.`id` = (SELECT `guilds`.`ownerid` FROM `guilds` WHERE `guilds`.`name` = ".. db.escapeString(GuildName) .. ")") if(leader:getID() ~= -1) then return leader:getDataString("name") end return nil end realCastle.open = function() setGlobalStorageValue(realCastle.open_storage,1) setGlobalStorageValue(realCastle.guild_storage,-1) setGlobalStorageValue(realCastle.storages.running, 1) end realCastle.close = function() setGlobalStorageValue(realCastle.open_storage,-1) local tomorrow = getTomorrowsDate() local tomorrowString = tomorrow[1].."/"..tomorrow[2].."/"..tomorrow[3] for i = 1, 3 do setGlobalStorageValue(realCastle.dateStorages[i], tomorrow[i]) end local players = getPlayersInArea(realCastle.frompos, realCastle.topos) if players then for _, pid in pairs(players) do doTeleportThing(pid,getTownTemplePosition(1)) end end if getGlobalStorageValue(realCastle.guild_storage) == -1 then doBroadcastMessage("[Real Castle] A batalhar terminou e nenhuma guild conseguiu dominar o castelo!") else local gname = getGuildNameByID(getGlobalStorageValue(realCastle.guild_storage)) doBroadcastMessage("[Real Castle] A batalha terminou e a guild vencedora foi "..gname.."! Todos os jogadores dessa guild agora tem 30% a + de experiencia!") local leader = getGuildLeaderName(gname) local parcel = doCreateItemEx(ITEM_PARCEL) doAddContainerItem(parcel, realCastle.itemid, 1) doPlayerSendMailByName(leader, parcel) -- manda item para depot do leader end local func = db.query or db.executeQuery func("DELETE FROM real_castle WHERE world_id = '"..getWorldId().."'") func("INSERT INTO real_castle (guild_name, guild_id, tomorrow, world_id) VALUES ('"..getGuildNameByID(getGlobalStorageValue(realCastle.guild_storage)).."', '"..getGlobalStorageValue(realCastle.guild_storage).."', '"..tomorrowString.."', '"..getWorldId().."')") setGlobalStorageValue(realCastle.storages.running, -1) doSaveServer() end realCastle.broadcast = function(message) local players = getPlayersInArea(realCastle.frompos, realCastle.topos) if players then for _, pid in pairs(players) do doPlayerSendTextMessage(pid,MESSAGE_STATUS_WARNING,message) end end end realCastle.domain = function(cid) local guild_id = getPlayerGuildId(cid) setGlobalStorageValue(realCastle.guild_storage,guild_id) doBroadcastMessage("[Real Castle] O jogador "..getPlayerName(cid).." da guild "..getPlayerGuildName(cid).." dominou o castelo! As outras guilds têm até às 22:00 para conseguir tirar o domínio deles, não desistam!") end realCastle.isDominating = function(cid) local guild_id = getPlayerGuildId(cid) return guild_id == getGlobalStorageValue(realCastle.guild_storage) end realCastle.isOpen = function() return getGlobalStorageValue(realCastle.open_storage) == 1 end --- Config by Dwarfer realCastle.isRunning = function() return getGlobalStorageValue(realCastle.storages.running) ~= -1 end ---------------------------------------- OBS: Coloquei para o item ir direto para o Depot, pq pode acontecer de o leader da guild cair ou não estar presente... ai ele recebe tanto online como offline. [*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*] DISCORD: vodkart#6090
Postado Agosto 27, 2021 3 anos Autor @Vodkart Desculpa, confundi o script. Esse que passei era o antigo. Agora estou utilizando esse abaixo. Spoiler if not RealCastle then RealCastle = { itemid = 10091, 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 = 2130, y = 781, z = 7}, {x = 2210, y = 923, z = 7}}, {{x = 2240, y = 835, z = 7}, {x = 2304, y = 916, z = 7}}, {{x = 1927, y = 739, z = 5}, {x = 2043, y = 927, z = 5}} } 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", "[War 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[i], tomorrow[i]) 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, "[War Castle] A batalha pelo domínio do castelo se encerrou com vitória da guild ["..guild_name.."] e você foi trazido a seu Templo.") local gname = getGuildNameByID(getGlobalStorageValue(realCastle.guildStorage)) doBroadcastMessage("[War Castle] A batalha terminou e a guild vencedora foi ["..guild_name.."]! Todos os jogadores dessa guild agora podem aproveitar o castelo até amanhã às 21:00!") local leader = getGuildLeaderName(gname) local parcel = doCreateItemEx(2595) doAddContainerItem(parcel, realCastle.itemid, 1) doPlayerSendMailByName(leader, parcel) else guild_name = "Castelo LIVRE" self:removePlayers(MESSAGE_STATUS_CONSOLE_ORANGE, "[War 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("[War 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("[War Castle] O jogador ["..getPlayerName(cid).."] da guild ["..getPlayerGuildName(cid).."] dominou o castelo! As outras guilds têm até às 22: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, "[War 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("[War 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, "[War 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 = " ----------[War 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), 31) doPlayerSay(cid,"Dominei HaHaHa!! #NoControle.", TALKTYPE_ORANGE_1) else doSendMagicEffect(fromPosition, CONST_ME_POFF) doPlayerSay(cid,"[War Castle] Sua guild já está com o domínio do castelo!", TALKTYPE_ORANGE_1) 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) >= 200 then doSendMagicEffect(getThingPos(cid), 13) return true else doTeleportThing(cid, fromPosition) doSendMagicEffect(fromPosition, CONST_ME_POFF) doPlayerSay(cid,"[War Castle] Somente jogadores com level 200 ou mais podem batalhar pelo castelo!", TALKTYPE_ORANGE_1) end else doTeleportThing(cid, fromPosition) doSendMagicEffect(fromPosition, CONST_ME_POFF) doPlayerSay(cid,"[War Castle] Somente jogadores com guild podem batalhar pelo castelo!", TALKTYPE_ORANGE_1) end else doTeleportThing(cid, fromPosition) doSendMagicEffect(fromPosition, CONST_ME_POFF) doPlayerSay(cid,"[War Castle] O castelo não está aberto para invasões!", TALKTYPE_ORANGE_1) end elseif item.actionid == 61466 then if self:isDominating(cid) then doSendMagicEffect(getThingPos(cid), 14) doPlayerSay(cid,"Bem vindo ao War Castle!", TALKTYPE_ORANGE_1) return true end if self:isOpen() then doTeleportThing(cid, fromPosition) doSendMagicEffect(fromPosition, CONST_ME_POFF) doPlayerSay(cid,"[War Castle] Não é permitido entrar no castelo enquanto as guilds estão batalhando pelo seu domínio.", TALKTYPE_ORANGE_1) else local guild_id = getGlobalStorageValue(self.guildStorage) 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) doPlayerSay(cid, guild_id ~= EMPTY_STORAGE and "[War Castle] Somente membros da guild ["..getGuildNameByID(guild_id).."] podem entrar." or "[War Castle] Somente membros da guild dominante podem entrar.", TALKTYPE_ORANGE_1) end end return true end end Mesmo assim fiz as alterações nesse script com oque você alterou e não funcionou está gerando o seguinte erro na distro.
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.