TalkAction [Finished] InGame Highscore

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
101
Location
Germany
Here a working highscore script for TFS 0.3.4(tested).


data/talkactions/scripts/highscore.lua

Code:
function onSay(cid, words, param)

     -- max players on the highscore
     local players = 20 -- The amount of players that is shown in the list

     -- don't touch --
     local str = ""
     local value = ""
     local name = ""
     local player_id = 0
     local result = nil
	if param == "level" or param == "exp" or param == "lvl" then
		str = "# [Level] - Name\n"
		value = "level"
		name = "name"
		result = db.getResult("SELECT `level`, `name` FROM `players` ORDER BY `level` DESC, `name` ASC;")
	elseif param == "magiclevel" or param == "magic" or param == "mlevel" or param == "ml" then
		str = "# [Magic Level] - Name\n"
		value = "maglevel"
		name = "name"
		result = db.getResult("SELECT `name`, `maglevel` FROM `players` ORDER BY `maglevel` DESC, `name` ASC;")
	elseif param == "fist" then
		str = "# [Fist] - Name\n"
		value = "value"
		player_id = "player_id"
		result = db.getResult("SELECT `player_id`, `value` FROM `player_skills`  WHERE `skillid` = 0 ORDER BY `value` DESC, `player_id` ASC;")
	elseif param == "club" then
		str = "# [Club] - Name\n"
		value = "value"
		player_id = "player_id"
		result = db.getResult("SELECT `player_id`, `value` FROM `player_skills`  WHERE `skillid` = 1 ORDER BY `value` DESC, `player_id` ASC;")
	elseif param == "sword" then
		str = "# [Sword] - Name\n"
		value = "value"
		player_id = "player_id"
		result = db.getResult("SELECT `player_id`, `value` FROM `player_skills`  WHERE `skillid` = 2 ORDER BY `value` DESC, `player_id` ASC;")
	elseif param == "axe" then
		str = "# [Axe] - Name\n"
		value = "value"
		player_id = "player_id"
		result = db.getResult("SELECT `player_id`, `value` FROM `player_skills`  WHERE `skillid` = 3 ORDER BY `value` DESC, `player_id` ASC;")
	elseif param == "dist" or param == "distance" then
		str = "# [Distance] - Name\n"
		value = "value"
		player_id = "player_id"
		result = db.getResult("SELECT `player_id`, `value` FROM `player_skills`  WHERE `skillid` = 4 ORDER BY `value` DESC, `player_id` ASC;")
	elseif param == "shield" or param == "shielding" then
		str = "# [Shield] - Name\n"
		value = "value"
		player_id = "player_id"
		result = db.getResult("SELECT `player_id`, `value` FROM `player_skills`  WHERE `skillid` = 5 ORDER BY `value` DESC, `player_id` ASC;")
	elseif param == "fish" or param == "fishing" then
		str = "# [Fishing] - Name\n"
		value = "value"
		player_id = "player_id"
		result = db.getResult("SELECT `player_id`, `value` FROM `player_skills`  WHERE `skillid` = 6 ORDER BY `value` DESC, `player_id` ASC;")
	else
	     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Unbekannter skill: '" .. param .. "'")
	     return TRUE
	end
	if (result:getID() ~= -1) then
		local i = 1
		while TRUE do
			if not(result:next()) or i > players then
				break
			end
			str = str .. "\n " .. i .. ". [" .. result:getDataInt(value) .. "] - " .. (name ~= "" and result:getDataString("name") or getPlayerNameByGUID(result:getDataInt(player_id)))
			i = i+1
		end
		result:free()
	end
	if str ~= "" then
		doPlayerPopupFYI(cid, str)
	end
	return TRUE
end
data/talkactions/talkactions.xml

HTML:
	<talkaction words="!highscore" event="script" value="highscore.lua"/>
Commands:
•!highscore level
-> shows level highscore
•!highscore magiclevel
-> shows magiclevel highscore
•!highscore fist
-> shows fist highscore
•!highscore club
-> shows club highscore
•!highscore sword
-> shows sword highscore
•!highscore axe
-> shows axe highscore
•!highscore distance
-> shows distance highscore
•!highscore shielding
-> shows shielding highscore
•!highscore fishing
-> shows fishing highscore

Sorry but i can't post screens.

I hope you like it ;).

Regards,
Shawak
 
Last edited:
OP
Shawak

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
101
Location
Germany
35 Views, 2 Comments :(

@TriWear
No Problem ^_^

Regards,
Shawak
 
OP
Shawak

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
101
Location
Germany
~100 views, 3 Comments? :(

Bump??

Regards,
Shawak
 

SasirO

Banned User
Joined
Apr 30, 2009
Messages
559
Best answers
0
Reaction score
0
So far i remember it was lagging my server as hell, i had 500 players online, and if half of them wrote this command server gets crashed :p
 

Stunner

New Member
Joined
Feb 4, 2009
Messages
22
Best answers
0
Reaction score
0
Location
So-Cal
One thing is wrong though, It shows GM+ Levels too. So if a gm is like lvl 1k and the highest level person is 200 the gm is #1
 

vDk

Member
Joined
Jul 22, 2007
Messages
795
Best answers
0
Reaction score
14
Location
Poland, Kraków
One thing is wrong though, It shows GM+ Levels too. So if a gm is like lvl 1k and the highest level person is 200 the gm is #1
PHP:
 result = db.getResult("SELECT `level`, `name` FROM `players` WHERE `name` != 'GamemasterNick' ORDER BY `level` DESC,
or

PHP:
 result = db.getResult("SELECT `level`, `name` FROM `players` WHERE `group_id` < '4' ORDER BY `level` DESC,
 
Last edited:
OP
Shawak

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
101
Location
Germany
So far i remember it was lagging my server as hell, i had 500 players online, and if half of them wrote this command server gets crashed :p
This script lagging your server? :confused:


@All they said thx:
No Problem :thumbup:

Regards,
Shawak
 

life4me

Don't dream it, be it.
Joined
Jun 27, 2009
Messages
928
Best answers
0
Reaction score
15
Location
Otland
Works really fine for me :S no crashes, maybe because i changed things ^^
 

QuaS

Cykotitan Pwned =/
Joined
Sep 11, 2008
Messages
833
Best answers
0
Reaction score
26
Location
Poland/ Wroclaw
250 real time queries in 1 time could crash server. (make mysql not responding. if it is liek it then ot is crashing)_.
 

vDk

Member
Joined
Jul 22, 2007
Messages
795
Best answers
0
Reaction score
14
Location
Poland, Kraków
Hmm nvm : P
Lua:
function onThink(interval, lastExecution)
     local players = 5 -- The amount of players that is shown in the list
     -- don't touch --
     local str = ""
     local value = ""
     local name = ""
     local player_id = 0
     local result = nil
        str = "# [Frags] - Name\n"
        value = "frags"
        name = "name"
        result = db.getResult("SELECT `frags`, `name` FROM `players`  WHERE `name` != 'Druid' AND `name` != 'Paladin' AND `name` != 'Sorcerer' AND `name` != 'Knight' ORDER BY `frags` DESC, `name` ASC;")
    if (result:getID() ~= -1) then
        local i = 1
        while TRUE do
            str = str .. "\n " .. i .. ". [" .. result:getDataInt(value) .. "] - " .. (name ~= "" and result:getDataString("name") or getPlayerNameByGUID(result:getDataInt(player_id)))
            i = i+1
            if not(result:next()) or i > players then
                break
            end
        end
        result:free()
    end
    if str ~= "" then
        doBroadcastMessage(str)
    end
    return TRUE
end
 
OP
Shawak

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
101
Location
Germany
You see, it's possible :).

Regards,
Shawak
 
Top