• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TalkAction !ranks rook

mamon_2

Banned User
Joined
Jul 2, 2007
Messages
424
Reaction score
0
Maybe to do a rank about no vocations, because on my OT, the people is leveling on Rook xD
So I added dragons, cycs, tarantulas, giant spiders, dragon lord, demons, and they hunt with a team of 30 people xD
It owns, and the were asking me about a !ranks rook, to see top levels of rook (no vocations), if someone knows how to do this, please help.

Thanks

TFS BETA 2.


--------------------
Credits: Azi

Code:
function onSay(cid, words, param)
    local hs = db.getResult("SELECT `name`, `level`, `experience` FROM `players` WHERE `vocation`=0 ORDER By `experience` DESC LIMIT 30")
    local highscores = {}
    local str="Rookgaard level highscores!\n # Name  Level  Exp\n"
    if(hs:getID() ~= -1) then
        while(true) do
            table.insert(highscores, {hs:getDataString("name"), hs:getDataString("level"), hs:getDataInt("experience")})
            if not(hs:next()) then
                break
            end
        end
    hs:free()
    end
    
    for i=1, #highscores do
        str = str..""..i..". "..highscores[i][1].."  "..highscores[i][2].."  "..highscores[i][3].."\n"
    end
    doPlayerPopupFYI(cid, str)
    return TRUE
end
 
Last edited:
for 0.3b2 ; ) npnp; P
PHP:
function onSay(cid, words, param)
	local hs = db.getResult("SELECT `name`, `level`, `experience` FROM `players` WHERE `voc`=0 ORDER By `experience` ASC LIMIT 30")
	local highscores = {}
	local str=""
	if(hs:getID() ~= -1) then
		while(true) do
			table.insert(highscores, {hs:getDataString("name"), hs:getDataString("level"), hs:getDataInt("experience")})
			if not(hs:next()) then
				break
			end
		end
	end
	hs:free()
	if(str == "")then
		str = "Rookgaard level highscores!\n #\t Name\t Level\t Exp"
	end
	
	for i=1, #highscores do
		str = str..""..i.."\t"..higscores[1].."\t.."higscores[2].."\t"..higscores[3].."\n"
	end
	doPlayerPopupFYI(cid, str)
	return TRUE
end
 
Last edited:
It isnt working, line 19 near ".." :S
Something like that, can you take a look please?
 
Try this one:

PHP:
function onSay(cid, words, param)
    local hs = db.getResult("SELECT `name`, `level`, `experience` FROM `players` WHERE `voc`=0 ORDER By `experience` ASC LIMIT 30")
    local highscores = {}
    local str=""
    if(hs:getID() ~= -1) then
        while(true) do
            table.insert(highscores, {hs:getDataString("name"), hs:getDataString("level"), hs:getDataInt("experience")})
            if not(hs:next()) then
                break
            end
        end
    end
    hs:free()
    if(str == "")then
        str = "Rookgaard level highscores!\n #\t Name\t Level\t Exp"
    end
    
    for i=1, #highscores do
        str = str..""..i.."\t"..higscores[1].."\t.."..higscores[2].."\t"..higscores[3].."\n"
    end
    doPlayerPopupFYI(cid, str)
    return TRUE
end
 
Code:
[17/01/2009 04:43:01] mysql_real_query(): SELECT `name`, `level`, `experience` FROM `players` WHERE `voc`=0 ORDER By `experience` ASC LIMIT 30: MYSQL ERROR: Unknown column 'voc' in 'where clause'

[17/01/2009 04:43:01] Lua Script Error: [TalkAction Interface] 
[17/01/2009 04:43:01] data/talkactions/scripts/mtibia/toprook.lua:onSay

[17/01/2009 04:43:01] data/lib/database.lua:79: [Result:free]: Result not set!
[17/01/2009 04:43:01] stack traceback:
[17/01/2009 04:43:01] 	[C]: in function 'error'
[17/01/2009 04:43:01] 	data/lib/database.lua:79: in function 'free'
[17/01/2009 04:43:01] 	data/talkactions/scripts/mtibia/toprook.lua:13: in function <data/talkactions/scripts/mtibia/toprook.lua:1>

S:?

PD: The column is 'vocation' I changed it but still having errors.
 
Last edited:
move hs:free() up, so it's above the end

I did that but im getting this error:

[17/01/2009 12:58:38] data/talkactions/scripts/highscores.lua:19: attempt to concatenate field '?' (a table value)
[17/01/2009 12:58:38] stack traceback:
[17/01/2009 12:58:38] data/talkactions/scripts/highscores.lua:19: in function <data/talkactions/scripts/highscores.lua:1>
 
you need to write
higscores[1]

not just higscores[1]
 
Code:
function onSay(cid, words, param)
    local hs = db.getResult("SELECT `name`, `level`, `experience` FROM `players` WHERE `vocation`=0 ORDER By `experience` ASC LIMIT 30")
    local highscores = {}
    local str=""
    if(hs:getID() ~= -1) then
        while(true) do
            table.insert(highscores, {hs:getDataString("name"), hs:getDataString("level"), hs:getDataInt("experience")})
            if not(hs:next()) then
                break
            end
        end
    hs:free()
    end

    if(str == "")then
        str = "Rookgaard level highscores!\n # Name Level Exp\n"
    end
    
    for i=1, #highscores do
        str = str..""..i..". ("..highscores[i][1].." ,"..highscores[i][2]..","..highscores[i][3]..")\n"
    end
    doPlayerPopupFYI(cid, str)
    return TRUE
end

My little modifications, if you still need it =]
 
@tarjei
The one that you posted it says:
1. (God Kito,1,0)
2. (Pitufo,1,0)

It isnt working :S
 
mayby you have only 2 no voc chars? : )
witch 1 lvl and 0 exp? ; )

if no need in () names etc. take:

PHP:
function onSay(cid, words, param)
    local hs = db.getResult("SELECT `name`, `level`, `experience` FROM `players` WHERE `vocation`=0 ORDER By `experience` DESC LIMIT 30")
    local highscores = {}
    local str="Rookgaard level highscores!\n # Name  Level  Exp\n"
    if(hs:getID() ~= -1) then
        while(true) do
            table.insert(highscores, {hs:getDataString("name"), hs:getDataString("level"), hs:getDataInt("experience")})
            if not(hs:next()) then
                break
            end
        end
    hs:free()
    end
    
    for i=1, #highscores do
        str = str..""..i..". "..highscores[i][1].."  "..highscores[i][2].."  "..highscores[i][3].."\n"
    end
    doPlayerPopupFYI(cid, str)
    return TRUE
end

#down
ok look now..
 
Last edited:
I mean.... show 30 chars, in that way.
Not say the top level and exp :S
 
59355441ig4.jpg


The ones that show the script, are not the top levels... My God is level 1 :S
There are levels 40 on rook and doesnt shows :S
 
Edited AZI script and make it so all players are listed less the ones that has no vocation:

PHP:
function onSay(cid, words, param)
    local hs = db.getResult("SELECT `name`, `level`, `experience` FROM `players` WHERE `vocation`>=1 ORDER By `experience` DESC LIMIT 30")
    local highscores = {}
    local str="Rookgaard level highscores!\n # Name  Level  Exp\n"
    if(hs:getID() ~= -1) then
        while(true) do
            table.insert(highscores, {hs:getDataString("name"), hs:getDataString("level"), hs:getDataInt("experience")})
            if not(hs:next()) then
                break
            end
        end
    hs:free()
    end
    
    for i=1, #highscores do
        str = str..""..i..". "..highscores[i][1].."  "..highscores[i][2].."  "..highscores[i][3].."\n"
    end
    doPlayerPopupFYI(cid, str)
    return TRUE
end
 
@Up
It takes the highscores of the ones with vocation(non rooks)
that's scripts was made by someone ago... and most advanced, if he need global stats, he can look on this board.


#2xup

for no show GM's itd.
PHP:
local noShowGroup = 2 --- no showing this and higher groups.
function onSay(cid, words, param)
    local hs = db.getResult("SELECT `name`, `level`, `experience` FROM `players` WHERE `vocation`=0 and `group_id` < " .. noShowGroup .. " ORDER By `experience` DESC LIMIT 30")
    local highscores = {}
    local str="Rookgaard level highscores!\n # Name  Level  Exp\n"
    if(hs:getID() ~= -1) then
        while(true) do
            table.insert(highscores, {hs:getDataString("name"), hs:getDataString("level"), hs:getDataInt("experience")})
            if not(hs:next()) then
                break
            end
        end
    hs:free()
    end
    
    for i=1, #highscores do
        str = str..""..i..". "..highscores[i][1].."  "..highscores[i][2].."  "..highscores[i][3].."\n"
    end
    doPlayerPopupFYI(cid, str)
    return TRUE
end
 
Back
Top