Ir para conteúdo
  • 0

Rank Frags !


\Mattheus ~*

Pergunta

Posts Recomendados

  • 0

Bom achei esse daqui espero que pegue com você!

Vai no talkactions/scripts e abra seu ranks.lua e substitua por isso:

function getPlayerNameByGUID2(n)
local c = db.getResult("SELECT `name` FROM `players` WHERE `id` = "..n..";")
if c:getID() == -1 then
return "SQL_ERROR["..n.."]"
end
return c:getDataString("name")
end
function onSay(cid, words, param)
local max = 10
local letters_to_next = 20
local skills = {
['fist'] = 0,
['club'] = 1,
['sword'] = 2,
['axe'] = 3,
['distance'] = 4,
['shielding'] = 5,
['fishing'] = 6,
['dist'] = 4,
['shield'] = 5,
['fish'] = 6,
}
local name_now
local name = "Highscores\n"
local rkn = 0
local no_break = 0
param = string.lower(param)
dofile('config.lua')
if param == "" or param == "level" and ( param ~= "magic" and param == "ml") and skills[param] == nil then
name = name.."\n"
name = name.."Ranking Level - Nome do Jogador\n"
local v = db.getResult("SELECT `name`, `level`, `experience` FROM `players` WHERE `group_id` <= 2 ORDER BY `experience` DESC LIMIT 0,"..(max)..";")
repeat
no_break = no_break +1
if v:getID() == -1 then
break
end
rkn = rkn+1
name_now, l = v:getDataString("name"), string.len(v:getDataString("name"))
space = ""
for i=1, letters_to_next-l do
space = space.." "
end
name = name..rkn..". ["..v:getDataInt("level") .."] - "..name_now..space.." ".."\n"
if no_break >= 20 then
break
end
until v:next() == false
elseif param == "magic" or param == "ml" then
name = name.."\n"
name = name.."Ranking Magic - Nome do Jogador\n"
local v = db.getResult("SELECT `name`, `level`, `maglevel` FROM `players` WHERE `group_id` <= 2 ORDER BY `maglevel` DESC LIMIT 0,"..(max)..";")
repeat
if v:getID() == -1 then
break
end
rkn = rkn+1
name_now, l = v:getDataString("name"), string.len(v:getDataString("name"))
space = ""
for i=1, letters_to_next-l do
space = space.." "
end
name = name..rkn..". ["..v:getDataInt("maglevel").."] - "..name_now..space.." ".." ".."".."\n"
until v:next() == false
elseif param == "kills" or param == "killer" or param == "kill" or param == "frag" or param == "frags" then
name = name.."\n"
name = name.."Ranking Frags\n"
local v = db.getResult("SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = 90190 ORDER BY cast(value as INTEGER) DESC;")
local kk = 0
repeat
if kk == max or v:getID() == -1 then
break
end
kk = kk+1
name_now, l = getPlayerNameByGUID2(v:getDataInt("player_id")), string.len(getPlayerNameByGUID2(v:getDataInt("player_id")))
space = ""
for i=1, letters_to_next-l do
space = space.." "
end
if name_now == nil then
name_now = 'sql error['..v:getDataInt("player_id")..']'
end
name = name..kk..". ["..v:getDataInt("value").."] - "..name_now..space.." \n"
until v:next() == false
elseif skills[param] ~= nil then
name = name.."\n"
name = name.."Ranking "..param.." fighting - Nome do Jogador\n"
local v = db.getResult("SELECT `player_id`, `value` FROM `player_skills` WHERE `skillid` = "..skills[param].." ORDER BY `value` DESC;")
local kk = 0
repeat
if kk == max or v:getID() == -1 then
break
end
kk = kk+1
name_now, l = getPlayerNameByGUID2(v:getDataInt("player_id")), string.len(getPlayerNameByGUID2(v:getDataInt("player_id")))
space = ""
for i=1, letters_to_next-l do
space = space.." "
end
if name_now == nil then
name_now = 'sql error['..v:getDataInt("player_id")..']'
end
name = name..kk..". ["..v:getDataInt("value").."] - "..name_now..space.." \n"
until v:next() == false
end
if name ~= "Highscore\n" then
doPlayerPopupFYI(cid, name)
end
return TRUE
end

 

Esse script é só você pegar esse código e colocar no lugar do seu Rank e assim vai ter !rank magic,sword,frags etc...

Link para o comentário
Compartilhar em outros sites

  • 0

este aki funciono !

 

va em data / scripts / talkactions / e crie um arquivo ranks.lua e adicione isto la

 

-- Original script edited by MaxLinux or Sciter -- Ranking Frags --
function getPlayerNameByGUID2(n)
local c = db.getResult("SELECT `name` FROM `players` WHERE `id` = "..n..";")
if c:getID() == -1 then
return "SQL_ERROR["..n.."]"
end
return c:getDataString("name")
end
function onSay(cid, words, param)
local max = 10
local letters_to_next = 20
local skills = {
['fist'] = 0,
['club'] = 1,
['sword'] = 2,
['axe'] = 3,
['distance'] = 4,
['shielding'] = 5,
['fishing'] = 6,
['dist'] = 4,
['shield'] = 5,
['fish'] = 6,
}
local name_now
local name = "Highscores\n"
local rkn = 0
local no_break = 0
param = string.lower(param)
dofile('config.lua')
if param == "" or param == "level" and ( param ~= "magic" and param == "ml") and skills[param] == nil then
name = name.."\n"
name = name.."Ranking Level - Nome do Jogador\n"
local v = db.getResult("SELECT `name`, `level`, `experience` FROM `players` WHERE `group_id` <= 2 ORDER BY `experience` DESC LIMIT 0,"..(max)..";")
repeat
no_break = no_break +1
if v:getID() == -1 then
break
end
rkn = rkn+1
name_now, l = v:getDataString("name"), string.len(v:getDataString("name"))
space = ""
for i=1, letters_to_next-l do
space = space.." "
end
name = name..rkn..". ["..v:getDataInt("level") .."] - "..name_now..space.." ".."\n"
if no_break >= 20 then
break
end
until v:next() == false
elseif param == "magic" or param == "ml" then
name = name.."\n"
name = name.."Ranking Magic - Nome do Jogador\n"
local v = db.getResult("SELECT `name`, `level`, `maglevel` FROM `players` WHERE `group_id` <= 2 ORDER BY `maglevel` DESC LIMIT 0,"..(max)..";")
repeat
if v:getID() == -1 then
break
end
rkn = rkn+1
name_now, l = v:getDataString("name"), string.len(v:getDataString("name"))
space = ""
for i=1, letters_to_next-l do
space = space.." "
end
name = name..rkn..". ["..v:getDataInt("maglevel").."] - "..name_now..space.." ".." ".."".."\n"
until v:next() == false
elseif param == "kills" or param == "killer" or param == "kill" or param == "frag" or param == "frags" then
name = name.."\n"
name = name.."Ranking Frags\n"
local v = db.getResult("SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = 90190 ORDER BY cast(value as INTEGER) DESC;")
local kk = 0
repeat
if kk == max or v:getID() == -1 then
break
end
kk = kk+1
name_now, l = getPlayerNameByGUID2(v:getDataInt("player_id")), string.len(getPlayerNameByGUID2(v:getDataInt("player_id")))
space = ""
for i=1, letters_to_next-l do
space = space.." "
end
if name_now == nil then
name_now = 'sql error['..v:getDataInt("player_id")..']'
end
name = name..kk..". ["..v:getDataInt("value").."] - "..name_now..space.." \n"
until v:next() == false
elseif skills[param] ~= nil then
name = name.."\n"
name = name.."Ranking "..param.." fighting - Nome do Jogador\n"
local v = db.getResult("SELECT `player_id`, `value` FROM `player_skills` WHERE `skillid` = "..skills[param].." ORDER BY `value` DESC;")
local kk = 0
repeat
if kk == max or v:getID() == -1 then
break
end
kk = kk+1
name_now, l = getPlayerNameByGUID2(v:getDataInt("player_id")), string.len(getPlayerNameByGUID2(v:getDataInt("player_id")))
space = ""
for i=1, letters_to_next-l do
space = space.." "
end
if name_now == nil then
name_now = 'sql error['..v:getDataInt("player_id")..']'
end
name = name..kk..". ["..v:getDataInt("value").."] - "..name_now..space.." \n"
until v:next() == false
end
if name ~= "Highscore\n" then
doPlayerPopupFYI(cid, name)
end
return TRUE
end

 

OBS : Este e um talk de rank normal so que com o do frag

 

dps em talkactions.xml

 

<talkaction words="!rank" script="ranks.lua"/>

Link para o comentário
Compartilhar em outros sites

  • 0

pessoal só quer copiar script e ainda acha que vai funcionar como mágica

 

os dois são MODS

 

----------------

 

 

Por Storage:

 

rank frag.xml

<?xml version="1.0" encoding="UTF-8"?>  
<mod name="rank frag" version="1.0" author="Vodkart" contact="xtibia.com" enabled="yes">  
<config name="rankf_func"><![CDATA[
storage = 824544
function getPlayerFrags(cid)
   local time = os.time()
   local times = {today = (time - 86400), week = (time - (7 * 86400))}
   local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
   if(result:getID() ~= -1) then
       repeat
           local content = {date = result:getDataInt("date")}
           if(content.date > times.today) then
               table.insert(contents.day, content)
           elseif(content.date > times.week) then
               table.insert(contents.week, content)
           else
               table.insert(contents.month, content)
           end
       until not result:next()
       result:free()
   end
   local size = {day = table.maxn(contents.day),week = table.maxn(contents.week),month = table.maxn(contents.month)} 
   return size.day + size.week + size.month
end
function setFrags(cid)
setPlayerStorageValue(cid, storage, getPlayerFrags(cid))
doPlayerSave(cid)
end
function getRankStorage(cid, value, max, RankName) -- by vodka
local str =""
str = "--[".. (RankName == nil and "RANK STORAGE" or ""..RankName.."") .."]--\n\n"
local query = db.getResult("SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = "..value.." ORDER BY cast(value as INTEGER) DESC;")
if (query:getID() ~= -1) then k = 1 repeat if k > max then break end
str = str .. "\n " .. k .. ". "..getPlayerNameByGUID(query:getDataString("player_id")).." - [" .. query:getDataInt("value") .. "]"
k = k + 1 until not query:next() end return doPlayerPopupFYI(cid, str)
end
]]></config>
<talkaction words="/rankfrags;!rankfrags" event="buffer"><![CDATA[
domodlib('rankf_func')
return getRankStorage(cid, storage, 20, "Rank Frag")
]]></talkaction>  
<event type="login" name="RankfLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "RankfKill")
registerCreatureEvent(cid, "RankfLogin")
setFrags(cid)
return true
end]]></event>      
<event type="kill" name="RankfKill" event="script"><![CDATA[
domodlib('rankf_func')
function onKill(cid, target, lastHit)
if (isPlayer(cid) == true) and (isPlayer(target) == true) then
addEvent(setFrags, 100, cid)
end
return true
end]]></event>
</mod>

 

 

----------------------------------

 

Por DB:

 

executa essa query na sua db

 

ALTER TABLE `players` ADD `frags` INT NOT NULL DEFAULT '0'

 

 

Rank Frags.xml

<?xml version="1.0" encoding="UTF-8"?>  
<mod name="rank frag" version="1.0" author="Vodkart" contact="xtibia.com" enabled="yes">  
<config name="rankf_func"><![CDATA[
function getPlayerFrags(cid)
   local time = os.time()
   local times = {today = (time - 86400), week = (time - (7 * 86400))}
   local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
   if(result:getID() ~= -1) then
       repeat
           local content = {date = result:getDataInt("date")}
           if(content.date > times.today) then
               table.insert(contents.day, content)
           elseif(content.date > times.week) then
               table.insert(contents.week, content)
           else
               table.insert(contents.month, content)
           end
       until not result:next()
       result:free()
   end
   local size = {day = table.maxn(contents.day),week = table.maxn(contents.week),month = table.maxn(contents.month)} 
   return size.day + size.week + size.month
end
function setFrags(cid)
return db.executeQuery("UPDATE `players` SET `frags` = "..getPlayerFrags(cid).." WHERE `id` = "..getPlayerGUID(cid)) 
end
]]></config>
<talkaction words="/rankfrags;!rankfrags" event="buffer"><![CDATA[
domodlib('rankf_func')
local max_players,str = 20,""
str = "--[ RANK FRAGS ]--\n\n"
local query = db.getResult("SELECT `name`, `frags` FROM `players` WHERE `frags` > 0 AND `id` > 6 AND `group_id` < 2 ORDER BY `frags` DESC, `name` ASC;")
               if (query:getID() ~= -1) then k = 1 while true do
str = str .. "\n " .. k .. ". " .. query:getDataString("name") .. " - [" .. query:getDataInt("frags") .. "]"
k = k + 1
if not(query:next()) or k > max_players then break end end query:free()end
return doShowTextDialog(cid,6500, str)
]]></talkaction>  
<event type="login" name="RankfLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "RankfKill")
registerCreatureEvent(cid, "RankfLogin")
setFrags(cid)
return true
end]]></event>      
<event type="kill" name="RankfKill" event="script"><![CDATA[
domodlib('rankf_func')
function onKill(cid, target, lastHit)
if isPlayer(cid) and isPlayer(target) then
addEvent(setFrags, 50, cid)
end
return true
end]]></event>
</mod>

Link para o comentário
Compartilhar em outros sites

  • 0

não leu o meu post? eu havia dito que era MODS lol

 

são dois, a diferença é que um é por storage e o outro é por DB

 

ai você escolhe qual o melhor pra vc

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...