Ir para conteúdo
Banner com Efeitos

Featured Replies

Postado

.Qual servidor ou website você utiliza como base? 

Baiak Wake

 

  Citar

Estou com um evento Castle 48hrs com bug Apenas na Hora de fechar o castle. ele não expulsa ninguem, e dar erro na distro, e apois eu clicar na alavanca ela me leva por templo, e quem dominou o castle pode entrar, e quem tentar entrar no castle, sem ser da guild dominante, dar este erro tudo estará nas prints.

 

Pasta/Libs: 

 

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 = 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, 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, "[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.")
            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!")
        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 21: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 21:59 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 22:00. Boa sorte a todas as guilds!", 11)
            for i = 1, 4 do
                addEvent(doBroadcastMessage, 500000 * i, "[War Castle] O acesso à área de dominar do castelo está liberado até as 22: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 21: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
            doSendMagicEffect(cid, item, frompos, item2, topos, 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 
 

 

 

Pasta/Globalevents/realCastleClose: 

function onTime()
    RealCastle:close()
    return true
end

 

 

  

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui. 

 

 

error 2.png

Sem título.png

Editado por Pvp Easy (veja o histórico de edições)

Postado

@Pvp Easy O servidor não tem a função getGuildNameByID adicionada. Vai em lib > 050-function.lua, desce tudo e no final adiciona a função:

function getGuildNameByID(id)
	local Info = db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. id .. ";")
	if Info:getID() ~= LUA_ERROR then
		local Name= Info:getDataString("name")
		Info:free()
		return Name
	end
	return LUA_ERROR
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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo