Postado Julho 15, 2014 10 anos Olá pessoal eu tinha visto este topico aqui outro dia na area de actions e afins... E estou tentando colocar no server mais estou tendo algumas dificuldades conforme segue a imagem abaixo. Segue abaixo o arquivo lib em spoiler: configCW = {timetostart = 10, -- tempo para iniciar o evento em segundos by Absolute telpos = {x=32366, y=32238, z=7}, -- onde aparecerá o teleport stats = 201201201701, kill = 201201201702, death = 201201201703, ostime = 201201201704, evttime = 20, -- quanto tempo irá rolar o evento topleftPos = {x=32310, y=31770, z=7}, -- canto esquerdo superior botrightPos = {x=32316, y=31776, z=7}, -- canto direito inferior templepos = {x=32369, y=32241, z=7}, -- posição do templo principal arenapos = {{x=32313, y=31770, z=7}, {x=32309, y=31773, z=7}, {x=32313, y=31776, z=7}, {x=32316, y=31773, z=7}}, -- posição dos 4 tronos times = 8, -- não precisa mexer finaltime = 300 -- não precisa mexer } function configCW:new() local newevt = {} setmetatable(newevt, self) self.__index = self broadcastMessage("The City War will be open in " .. self.timetostart .. " seconds.") setGlobalStorageValue(self.stats, 0) addEvent(function () newevt:start() end, self.timetostart*1000) end function configCW:start() if getGlobalStorageValue(self.stats) == 0 then setGlobalStorageValue(self.ostime, os.time()) local teleport = doCreateTeleport(1387, self.telpos) doItemSetAttribute(teleport, "aid", 5540) setGlobalStorageValue(self.stats, 1) broadcastMessage("The City War is starting...") for _, posi in pairs(self.arenapos) do local item = getTileItemById(posi, 1387) if(item.uid ~= 0) then doRemoveItem(item.uid) end end addEvent(function () self:preclose() end, self.evttime*1000*60) addEvent(function () self:announce(0) end, (self.evttime/self.times)*1000*60) end end function configCW:announce(times) if times < self.times then if #self:getTopFrags(true) >= 1 then broadcastMessage("Top City War fraggers: " .. self:getTopFrags()) end addEvent(function () self:announce(times+1) end, (self.evttime/self.times)*1000*60) end end function configCW:preclose() if getGlobalStorageValue(self.stats) == 1 then setGlobalStorageValue(self.stats, 2) broadcastMessage("The City War will end in " .. self.finaltime .. " seconds.") addEvent(function () self:close() end, self.finaltime*1000) local item = getTileItemById(self.telpos, 1387) if(item.uid ~= 0) then doRemoveItem(item.uid) end end end function configCW:close() if getGlobalStorageValue(self.stats) == 2 then if #self:getTopFrags(true) >= 1 then broadcastMessage("The City War has ended. The winners are: " .. self:getTopFrags()) else broadcastMessage("The City War has ended. There were no winners.") end doRemovePlayersFromArea(self.topleftPos, self.botrightPos, self.templepos) for _, posi in pairs(self.arenapos) do doCreateTeleport(1387, self.templepos, posi) end for place, info in ipairs(self:getTopFrags(true)) do if place > 5 then break end local cid = getPlayerByName(info) doPlayerSendTextMessage(cid, 4, "Congratulations, you were the " .. place .. "º place in the City War.") doPlayerAddItem(cid, 6571, 1) end setGlobalStorageValue(self.stats, -1) end end function configCW:isPlayerInEvent(cid) if getPlayerStorageValue(cid, self.stats) == -1 or getPlayerStorageValue(cid, self.stats) - os.time() <= -5 or getGlobalStorageValue(self.stats) < 1 then return false end return true end function configCW:getTopFrags(tab) local frag = {} for _, pid in pairs(getPlayersOnline()) do if (getPlayerStorageValue(pid, self.kill) ~= -1 or getPlayerStorageValue(pid, self.death) ~= -1) and self:isPlayerInEvent(pid) then local kill = getPlayerStorageValue(pid, self.kill)+1 local death = getPlayerStorageValue(pid, self.death)+1 print(getCreatureName(pid), kill-death) table.insert(frag, {getCreatureName(pid), kill-death}) end end print(#frag) local frag, str, n = doOrderTab(frag, 0), nil, 5 print(#frag) if tab then return frag else if #frag < 5 then n = #frag end for i = 1, n do local cid = getPlayerByName(frag) local kill = getPlayerStorageValue(cid, self.kill)+1 local death = getPlayerStorageValue(cid, self.death)+1 str = str and str .. ", " .. frag .. "[" .. kill .. "/" .. death .. "]" or frag .. "[" .. kill .. "/" .. death .. "]" end end return str end function doOrderTab(tabela, value) local max, index = {}, nil for i = 1, #tabela do valor = value for a, b in ipairs(tabela) do if b[2] > valor then valor = b[2] valor2 = b[1] index = a end end table.remove(tabela, index) if valor ~= value then table.insert(max, valor2) end end return max end Se alguem poder me ajuda ganha +REP, Melhor respota e o meu sincero agradecimento >.<! Trimera Tibia Old 7.4
Postado Julho 16, 2014 10 anos seu server não tem a função doCreateTeleport, vc vai ter que adicionar ela manualmente pelas sources OU trocar essa função por uma outra equivalente do seu server Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá! "Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda (obg ao @Beeny por fazer essa linda sign <3)
Postado Julho 16, 2014 10 anos Autor seu server não tem a função doCreateTeleport, vc vai ter que adicionar ela manualmente pelas sources OU trocar essa função por uma outra equivalente do seu server Agradeço muito a ajuda, mais qual a função amigo ? Editado Julho 16, 2014 10 anos por TioSlash (veja o histórico de edições) Trimera Tibia Old 7.4
Postado Julho 16, 2014 10 anos Então, a função com problema é a doCreateTeleport(itemid, topos, createpos).. perceba que os parametros que ela usa são: iddoteleport, posição que vai ser levado e posição que será criado. Você precisa substituir por alguma função que crie um item em determinada posição e que seja capaz de setar uma posição que será teleportado ao subir naquilo. Não sei oque dá pra ser utilizado porque sempre usei doCreateTeleport já que ela foi feita justamente pra isso haha. Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá! "Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda (obg ao @Beeny por fazer essa linda sign <3)
Postado Julho 16, 2014 10 anos Autor cara, entendo pouquissimo de funções, tem como você desenrolar pra mim ? Trimera Tibia Old 7.4
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.