ò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...)
Por MatheusGlad, 26 de abr. de 2011 em Actions e Talkactions
info
Grupo: Cavaleiro
Registrado: 20/07/09
Posts: 161
Reputação: +24
Char no Tibia: Max of Catanduva

ò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...)
info
Grupo: Campones
Registrado: 12/01/09
Posts: 87
Reputação: +22
Char no Tibia: Creepbreed

Cara muito bom o script, já tentei fazer o rank quem matou mais monstros mais não consegui
...
Parabens!
info
Grupo: Conde
Registrado: 09/09/09
Posts: 528
Reputação: +424
Char no Tibia: Emekalo Makalo

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 por MatheusMkalo
Mkalo ótimo script, otimo mesmo.
Parabéns
info
Grupo: Campones
Registrado: 29/08/10
Posts: 21
Reputação: +1

Okay, procurei no server todo a pasta "Mods" e nao a encontrei.
info
Grupo: Infante
Registrado: 13/10/08
Posts: 1.6k
Reputação: +420
Char no Tibia: Demonbholder

Esta na mesma pasta onde fica a pasta data, o distro e as dlls do seu ot.
info
Grupo: Campones
Registrado: 29/08/10
Posts: 21
Reputação: +1

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.
info
Grupo: Infante
Registrado: 13/10/08
Posts: 1.6k
Reputação: +420
Char no Tibia: Demonbholder

Bom, pelo jeito seu ot é antigo, ou algo do gênero, vamos adicionar "manualmente" então.
Seu otserver tem as pastas lib e creaturescripts?
info
Grupo: Campones
Registrado: 29/08/10
Posts: 21
Reputação: +1

Pelo contrario. E um OT 8.7 da The Forgotten Server.
Nao, so a pasta creaturescript.
info
Grupo: Infante
Registrado: 13/10/08
Posts: 1.6k
Reputação: +420
Char no Tibia: Demonbholder

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.
info
Grupo: Campones
Registrado: 29/08/10
Posts: 21
Reputação: +1

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 4 por LuizlaM
info
Grupo: Conde
Registrado: 09/09/09
Posts: 528
Reputação: +424
Char no Tibia: Emekalo Makalo

Nao da nenhum erro?
LoL ´Perfeito mas REP merece
info
Grupo: Conde
Registrado: 09/09/09
Posts: 528
Reputação: +424
Char no Tibia: Emekalo Makalo
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:
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:
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 por MatheusMkalo