MatheusGlad 424 Postado Abril 26, 2011 Share Postado Abril 26, 2011 (editado) Bem, a talkaction é a mesma coisa que o !rank que conhecemos, porem voce pode adicionar outros ranks e ela atualiza exatamente na hora que alguem upa. Exemplos de novos ranks: Rank para ver quem morreu mais. Rank para level de players vip. Rank para ver quem matou mais monstros no ot. E varios outros... Bem se alguem quizer implementar um novo rank, peça no topico e mande PM para mim (Nao adianta so pedir no topico porque eu nao irei lembrar de entrar nele). O script está em mod, bem mais facil de instalar. Va na pasta mods do seu ot e adicione o arquivo: RankSystem em formato XML e adicione isso: <?xml version="1.0" encoding="UTF-8"?> <mod name="RankSystem" enabled="yes" author="MatheusMkalo" forum="XTibia.com"> <config name="RankLib"><![CDATA[ ranks = { ["fist"] = 74666, ["club"] = 74667, ["sword"] = 74668, ["axe"] = 74669, ["distance"] = 74670, ["shielding"] = 74671, ["fishing"] = 74672, ["magic"] = 74673, ["level"] = 74674, ["monsters"] = 74675, ["guilds"] = 74676 } function havePlayerInRank(rank, playername) -- Checa se o player ja esta no rank. local rankstr = getGlobalStorageValue(ranks[rank]) local players = string.explode(rankstr, "; ") for i,x in pairs(players) do local a, b = string.find(x, "%[") if b ~= nil then if x:sub(1, b-1):lower() == playername:lower() then return TRUE end end end end function getPlayerLevelInRank(rank, playername) -- Pega o level de algum player no rank (Importante para novos tipos de rank.) local rankstr = getGlobalStorageValue(ranks[rank]) local players = string.explode(rankstr, "; ") for i,x in pairs(players) do local a, b = string.find(x, "%[") local t = string.match(x, "%[(.+)]") if b ~= nil and x:sub(1, b-1):lower() == playername:lower() then return t end end return 0 end function addRankPlayer(rank, playername, rankvalue) -- Adiciona um player ao rank ou muda o valor dele no rank. if not havePlayerInRank(rank, playername) then setGlobalStorageValue(ranks[rank], getGlobalStorageValue(ranks[rank]) .. (playername .. "[" .. rankvalue .. "]; ")) else local a,b = string.find(getGlobalStorageValue(ranks[rank]), playername) local c,d = string.find(getGlobalStorageValue(ranks[rank]), playername .. "%[%d+]") setGlobalStorageValue(ranks[rank], getGlobalStorageValue(ranks[rank]):sub(1, b+1) .. rankvalue .. "]; " .. getGlobalStorageValue(ranks[rank]):sub(d+2)) end end function tablelen(tab) -- By MatheusMkalo local result = 0 for i,x in pairs(tab) do result = result+1 end return result end function getRank(rank, maxplayers) -- Pega a lista de players com maior level do rank local rankstr = getGlobalStorageValue(ranks[rank]) local playerstatus = string.explode(rankstr, "; ") local tab = {} local rankTab = {} local rankStr = "Highscore for " .. rank .. "\n\n" .. (isInArray({"monsters", "guilds"}, rank) and "Number of Kills" or "Rank Level") .. " - " .. (rank == "guilds" and "Guild Name" or "Player Name") .. "\n" table.remove(playerstatus, #playerstatus) for i,x in pairs(playerstatus) do local a, b = string.find(x, "%[") local t = string.match(x, "%[(.+)]") tab[x:sub(1, b-1)] = tonumber(t) end local lastname = "" local lastvalue = 0 for i = 1, maxplayers do if tablelen(tab) <= 0 then break end for s,x in pairs(tab) do if x > lastvalue then lastvalue = x lastname = s end end table.insert(rankTab, lastvalue .. " - " .. lastname) tab[lastname] = nil lastname = "" lastvalue = 0 end for i,x in ipairs(rankTab) do rankStr = rankStr .. (i .. ". ") .. x .. "\n" end return rankStr end ]]></config> <talkaction words="!rank;/rank" event="script"><![CDATA[ domodlib('RankLib') if ranks[param:lower()] then setGlobalStorageValue(ranks[param:lower()], getGlobalStorageValue(ranks[param:lower()]) == -1 and "" or getGlobalStorageValue(ranks[param:lower()])) doShowTextDialog(cid, 6500, getRank(param:lower(), 10)) else return doPlayerSendCancel(cid, "Esse rank nao existe ou voce nao digitou corretamente.") end return TRUE ]]></talkaction> <creaturescript type="advance" name="RankSystem" event="script"><![CDATA[ domodlib('RankLib') if skill == 0 then setGlobalStorageValue(74666, getGlobalStorageValue(74666) == -1 and "" or getGlobalStorageValue(74666)) addRankPlayer("fist", getCreatureName(cid), newLevel) elseif skill == 1 then setGlobalStorageValue(74667, getGlobalStorageValue(74667) == -1 and "" or getGlobalStorageValue(74667)) addRankPlayer("club", getCreatureName(cid), newLevel) elseif skill == 2 then setGlobalStorageValue(74668, getGlobalStorageValue(74668) == -1 and "" or getGlobalStorageValue(74668)) addRankPlayer("sword", getCreatureName(cid), newLevel) elseif skill == 3 then setGlobalStorageValue(74669, getGlobalStorageValue(74669) == -1 and "" or getGlobalStorageValue(74669)) addRankPlayer("axe", getCreatureName(cid), newLevel) elseif skill == 4 then setGlobalStorageValue(74670, getGlobalStorageValue(74670) == -1 and "" or getGlobalStorageValue(74670)) addRankPlayer("distance", getCreatureName(cid), newLevel) elseif skill == 5 then setGlobalStorageValue(74671, getGlobalStorageValue(74671) == -1 and "" or getGlobalStorageValue(74671)) addRankPlayer("shielding", getCreatureName(cid), newLevel) elseif skill == 6 then setGlobalStorageValue(74672, getGlobalStorageValue(74672) == -1 and "" or getGlobalStorageValue(74672)) addRankPlayer("fishing", getCreatureName(cid), newLevel) elseif skill == 7 then setGlobalStorageValue(74673, getGlobalStorageValue(74673) == -1 and "" or getGlobalStorageValue(74673)) addRankPlayer("magic", getCreatureName(cid), newLevel) elseif skill == 8 then setGlobalStorageValue(74674, getGlobalStorageValue(74674) == -1 and "" or getGlobalStorageValue(74674)) addRankPlayer("level", getCreatureName(cid), newLevel) end return TRUE ]]></creaturescript> <creaturescript type="kill" name="KillRank" event="script"><![CDATA[ domodlib('RankLib') setGlobalStorageValue(74675, getGlobalStorageValue(74675) == -1 and "" or getGlobalStorageValue(74675)) if isMonster(target) then addRankPlayer("monsters", getCreatureName(cid), getPlayerLevelInRank("monsters", getCreatureName(cid))+1) end if isPlayer(target) then if getPlayerGuildId(cid) > 0 then if lastHit then if getPlayerGuildId(target) <= 0 or getPlayerGuildId(target) ~= getPlayerGuildId(cid) then addRankPlayer("guilds", getPlayerGuildName(cid), getPlayerLevelInRank("guilds", getPlayerGuildName(cid))+1) end end end end return TRUE ]]></creaturescript> <creaturescript type="login" name="RankEvents" event="script"><![CDATA[ registerCreatureEvent(cid, "KillRank") registerCreatureEvent(cid, "RankSystem") return TRUE ]]></creaturescript> </mod> Alem dos ranks normais, eu inclui um rank para os maiores matadores de monstros, para voces poderem ter uma ideia de como incluir novos ranks. PARA QUE O SCRIPT FUNCIONE RETIRE ESSA LINHA DO TALKACTIONS.XML: <talkaction words="!rank;/rank" event="script" value="ranks.lua"/> OBS: Para usar o rank novo use /rank ou !rank e o nome dos skills que se encontram nessa table: ranks = { ["fist"] = 74666, ["club"] = 74667, ["sword"] = 74668, ["axe"] = 74669, ["distance"] = 74670, ["shielding"] = 74671, ["fishing"] = 74672, ["magic"] = 74673, ["level"] = 74674, ["monsters"] = 74675 } No caso do novo rank seria /rank monsters. Para mudar o numero de players mostrados no rank mude essa linha no mod: doShowTextDialog(cid, 2160, getRank(param:lower(), 10)) 10 eh o numero de players que vai mostrar. Adicionado /rank guilds, que mostra as guilds que mais mataram no ot. Agora com aparencia e frases exatamente iguais ao /rank padrao. È Isso ai comentem! Editado Abril 28, 2011 por MatheusMkalo Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/ Compartilhar em outros sites More sharing options...
TheGODMaX 24 Postado Abril 26, 2011 Share Postado Abril 26, 2011 òtimo script Mkalo, como sempre, fazendo belos trabalhos e ajudando a comunidade! Parabéns ae. ^^' (um rank legal tambem seria de quem morre mais, haha...) Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1028357 Compartilhar em outros sites More sharing options...
Sanf 22 Postado Abril 27, 2011 Share Postado Abril 27, 2011 Cara muito bom o script, já tentei fazer o rank quem matou mais monstros mais não consegui ... Parabens! Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1028562 Compartilhar em outros sites More sharing options...
MatheusGlad 424 Postado Abril 27, 2011 Autor Share Postado Abril 27, 2011 (editado) Adicionado /rank guilds, que mostra as guilds que mais mataram no ot. Agora com aparencia e frases exatamente iguais ao /rank padrao. Editado Abril 28, 2011 por MatheusMkalo Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1028594 Compartilhar em outros sites More sharing options...
deglorio 44 Postado Abril 27, 2011 Share Postado Abril 27, 2011 Mkalo ótimo script, otimo mesmo. Parabéns Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1028602 Compartilhar em outros sites More sharing options...
luizlacerdam 1 Postado Maio 4, 2011 Share Postado Maio 4, 2011 Okay, procurei no server todo a pasta "Mods" e nao a encontrei. Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1030806 Compartilhar em outros sites More sharing options...
Demonbholder 420 Postado Maio 4, 2011 Share Postado Maio 4, 2011 Esta na mesma pasta onde fica a pasta data, o distro e as dlls do seu ot. Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1030958 Compartilhar em outros sites More sharing options...
luizlacerdam 1 Postado Maio 4, 2011 Share Postado Maio 4, 2011 Obrigado pela atencao, demom. Bem, la na pasta do OT so tem as pastas: "data" e "doc" e o resto sao os dlls e o exe do server. Criei uma com o nome "mods" e coloquei o XML mas nada. Alguma surgestao?? Obrigado. Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1030974 Compartilhar em outros sites More sharing options...
Demonbholder 420 Postado Maio 4, 2011 Share Postado Maio 4, 2011 Bom, pelo jeito seu ot é antigo, ou algo do gênero, vamos adicionar "manualmente" então. Seu otserver tem as pastas lib e creaturescripts? Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1030979 Compartilhar em outros sites More sharing options...
luizlacerdam 1 Postado Maio 4, 2011 Share Postado Maio 4, 2011 Pelo contrario. E um OT 8.7 da The Forgotten Server. Nao, so a pasta creaturescript. Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1030989 Compartilhar em outros sites More sharing options...
Demonbholder 420 Postado Maio 5, 2011 Share Postado Maio 5, 2011 Ah sim, então temos o arquivo global.lua Nele adicione: ranks = { ["fist"] = 74666, ["club"] = 74667, ["sword"] = 74668, ["axe"] = 74669, ["distance"] = 74670, ["shielding"] = 74671, ["fishing"] = 74672, ["magic"] = 74673, ["level"] = 74674, ["monsters"] = 74675, ["guilds"] = 74676 } function havePlayerInRank(rank, playername) -- Checa se o player ja esta no rank. local rankstr = getGlobalStorageValue(ranks[rank]) local players = string.explode(rankstr, "; ") for i,x in pairs(players) do local a, b = string.find(x, "%[") if b ~= nil then if x:sub(1, b-1):lower() == playername:lower() then return TRUE end end end end function getPlayerLevelInRank(rank, playername) -- Pega o level de algum player no rank (Importante para novos tipos de rank.) local rankstr = getGlobalStorageValue(ranks[rank]) local players = string.explode(rankstr, "; ") for i,x in pairs(players) do local a, b = string.find(x, "%[") local t = string.match(x, "%[(.+)]") if b ~= nil and x:sub(1, b-1):lower() == playername:lower() then return t end end return 0 end function addRankPlayer(rank, playername, rankvalue) -- Adiciona um player ao rank ou muda o valor dele no rank. if not havePlayerInRank(rank, playername) then setGlobalStorageValue(ranks[rank], getGlobalStorageValue(ranks[rank]) .. (playername .. "[" .. rankvalue .. "]; ")) else local a,b = string.find(getGlobalStorageValue(ranks[rank]), playername) local c,d = string.find(getGlobalStorageValue(ranks[rank]), playername .. "%[%d+]") setGlobalStorageValue(ranks[rank], getGlobalStorageValue(ranks[rank]):sub(1, b+1) .. rankvalue .. "]; " .. getGlobalStorageValue(ranks[rank]):sub(d+2)) end end function tablelen(tab) -- By MatheusMkalo local result = 0 for i,x in pairs(tab) do result = result+1 end return result end function getRank(rank, maxplayers) -- Pega a lista de players com maior level do rank local rankstr = getGlobalStorageValue(ranks[rank]) local playerstatus = string.explode(rankstr, "; ") local tab = {} local rankTab = {} local rankStr = "Highscore for " .. rank .. "\n\n" .. (isInArray({"monsters", "guilds"}, rank) and "Number of Kills" or "Rank Level") .. " - " .. (rank == "guilds" and "Guild Name" or "Player Name") .. "\n" table.remove(playerstatus, #playerstatus) for i,x in pairs(playerstatus) do local a, b = string.find(x, "%[") local t = string.match(x, "%[(.+)]") tab[x:sub(1, b-1)] = tonumber(t) end local lastname = "" local lastvalue = 0 for i = 1, maxplayers do if tablelen(tab) <= 0 then break end for s,x in pairs(tab) do if x > lastvalue then lastvalue = x lastname = s end end table.insert(rankTab, lastvalue .. " - " .. lastname) tab[lastname] = nil lastname = "" lastvalue = 0 end for i,x in ipairs(rankTab) do rankStr = rankStr .. (i .. ". ") .. x .. "\n" end return rankStr end Salve e feche. Agora vá em data/talkaction/script, crie um arquivo .lua e cole isto nele: function onSay(cid, words, param) if ranks[param:lower()] then setGlobalStorageValue(ranks[param:lower()], getGlobalStorageValue(ranks[param:lower()]) == -1 and "" or getGlobalStorageValue(ranks[param:lower()])) doShowTextDialog(cid, 6500, getRank(param:lower(), 10)) else return doPlayerSendCancel(cid, "Esse rank nao existe ou voce nao digitou corretamente.") end return TRUE end Salve, feche e vá em data/talkactions, abra o arquivo talkactions.xml e cole esta tag nele: <talkaction words="!rank;/rank" script="nomeDoArquivo.lua"/> Salve e feche. Agora vamos em creaturescripts, criaremos 2 arquivos .lua. No primeiro cole isto: function onAdvance(cid, skill, oldLevel, newLevel) if skill == 0 then setGlobalStorageValue(74666, getGlobalStorageValue(74666) == -1 and "" or getGlobalStorageValue(74666)) addRankPlayer("fist", getCreatureName(cid), newLevel) elseif skill == 1 then setGlobalStorageValue(74667, getGlobalStorageValue(74667) == -1 and "" or getGlobalStorageValue(74667)) addRankPlayer("club", getCreatureName(cid), newLevel) elseif skill == 2 then setGlobalStorageValue(74668, getGlobalStorageValue(74668) == -1 and "" or getGlobalStorageValue(74668)) addRankPlayer("sword", getCreatureName(cid), newLevel) elseif skill == 3 then setGlobalStorageValue(74669, getGlobalStorageValue(74669) == -1 and "" or getGlobalStorageValue(74669)) addRankPlayer("axe", getCreatureName(cid), newLevel) elseif skill == 4 then setGlobalStorageValue(74670, getGlobalStorageValue(74670) == -1 and "" or getGlobalStorageValue(74670)) addRankPlayer("distance", getCreatureName(cid), newLevel) elseif skill == 5 then setGlobalStorageValue(74671, getGlobalStorageValue(74671) == -1 and "" or getGlobalStorageValue(74671)) addRankPlayer("shielding", getCreatureName(cid), newLevel) elseif skill == 6 then setGlobalStorageValue(74672, getGlobalStorageValue(74672) == -1 and "" or getGlobalStorageValue(74672)) addRankPlayer("fishing", getCreatureName(cid), newLevel) elseif skill == 7 then setGlobalStorageValue(74673, getGlobalStorageValue(74673) == -1 and "" or getGlobalStorageValue(74673)) addRankPlayer("magic", getCreatureName(cid), newLevel) elseif skill == 8 then setGlobalStorageValue(74674, getGlobalStorageValue(74674) == -1 and "" or getGlobalStorageValue(74674)) addRankPlayer("level", getCreatureName(cid), newLevel) end return TRUE end Esta será a tag referente a esse script que você colocará em creaturescripts.xml: <event type="advance" name="RankAdv" event="script" value="nomeDoArquivo.lua"/> O segundo script é esse: function onKill(cid, target) setGlobalStorageValue(74675, getGlobalStorageValue(74675) == -1 and "" or getGlobalStorageValue(74675)) if isMonster(target) then addRankPlayer("monsters", getCreatureName(cid), getPlayerLevelInRank("monsters", getCreatureName(cid))+1) end if isPlayer(target) then if getPlayerGuildId(cid) > 0 then if lastHit then if getPlayerGuildId(target) <= 0 or getPlayerGuildId(target) ~= getPlayerGuildId(cid) then addRankPlayer("guilds", getPlayerGuildName(cid), getPlayerLevelInRank("guilds", getPlayerGuildName(cid))+1) end end end end return TRUE end Esta será a tag referente a esse script que você colocará em creaturescripts.xml: <event type="kill" name="RankKill" script="nomeDoArquivo.lua"/> Agora, por ultimo, vá em data/creaturescripts/script, abra o arquivo login.lua, ache as funções que registram eventos e cole esta entre elas: registerCreatureEvent(cid, "RankAdv") registerCreatureEvent(cid, "RankKill") Testa ai e me diz se funciona. Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1030998 Compartilhar em outros sites More sharing options...
luizlacerdam 1 Postado Maio 5, 2011 Share Postado Maio 5, 2011 (editado) Obrigado mais uma vez por responder. No arquivo global.lua adicionei o que vc pedio no final dele. e fiz o resto como mandou. Nao pegou. Vou mudar para o 8.6 Valeu a atencao demon Editado Maio 5, 2011 por LuizlaM Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1031007 Compartilhar em outros sites More sharing options...
MatheusGlad 424 Postado Maio 5, 2011 Autor Share Postado Maio 5, 2011 Nao da nenhum erro? Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1031076 Compartilhar em outros sites More sharing options...
rhamer 5 Postado Maio 5, 2011 Share Postado Maio 5, 2011 LoL ´Perfeito mas REP merece Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1031081 Compartilhar em outros sites More sharing options...
Lilita 1 Postado Maio 6, 2011 Share Postado Maio 6, 2011 scrtip bom comigo funciona perfeito! Link para o comentário https://xtibia.com/forum/topic/155704-talkaction-de-rank-inovadora/#findComment-1031392 Compartilhar em outros sites More sharing options...
Posts Recomendados