• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Top 5 PVP kills

Hello again...

New script to share! Top 5 kills per Class


THX Foereaper for optmize my code.

DfrmfKW.jpg









Thanks to "philippovitch" for Top 5 Class c++
 

Attachments

  • wow.jpg
    wow.jpg
    59.8 KB · Views: 62
Last edited:

Foereaper

Founder
The only thing I could suggest is to use a prepared statement for the queries and variables for classes. That way you would cut down the amount of code to only one function handling everything :)

I can make you an example of this later if you want me to :)
 
Can you do this ? I think i know what u mean, but i don't know how to use this in lua , i started a few hours ago.
 

Tommy

Founder
The only thing I could suggest is to use a prepared statement for the queries and variables for classes. That way you would cut down the amount of code to only one function handling everything :)

I can make you an example of this later if you want me to :)

Thanks for sharing this!

I do agree with Foereaper though. You could also update the table every 10-15 minutes (reload everything) so it will stay updated w/o a restart/reload. That will go along with the prepared statement.
 

Foereaper

Founder
Untested but should work :)

Code:
----------------------------------------------
-- TOP 5 per class                          //
-- Script by Renatokeys(emudevs)            //
-- http://emudevs.com                       //
----------------------------------------------
 
local NPC_ID = 1

local ClassLocale = { 
	[1] = {"Warrior", "660000"},
	[2] = {"Paladin", "FF0099"},
	[3] = {"Hunter", "CC6611"},
	[4] = {"Rogue", "CCFF00"},
	[5] = {"Priest", "FFFFFF"},
	[6] = {"Death Knight", "4D4D51"},
	[7] = {"Shaman", "0000CC"},
	[8] = {"Mage", "33FFFF"},
	[9] = {"Warlock", "660099"},
	[11] = {"Druid", "FF6600"}
};
 
function clica(event, plr, unit)
	plr:GossipMenuAddItem(0, "Choose the class : ", 0, 0)
	
	for k, v in pairs(T) do
		plr:GossipMenuAddItem(0, "TOP 5 |cff"..v[2]..v[1], 0, k)
	end
	
	plr:GossipSendMenu(1, unit)
end
 
function seleciona(event, plr, unit, arg2, intid)
    if (intid > 0) then
        plr:SendBroadcastMessage("|cff"..T[intid][2]..T[intid][1])
		
		local resultado = CharDBQuery("SELECT name,totalKills FROM characters WHERE class='"..intid.."' ORDER BY totalKills DESC LIMIT 5")
        repeat
			local playername = resultado:GetString(0);
			local kills = resultado:GetUInt32(1);
			plr:SendBroadcastMessage("|cFF33CCFFPlayer : |r ".. playername .." ,  |cFF33CCFFwith : |r" .. kills .. " Kills")
        until not resultado:NextRow()
    end
end
RegisterCreatureGossipEvent(NPC_ID, 1, clica)
RegisterCreatureGossipEvent(NPC_ID, 2, seleciona)

Decided to not use a prepared statement function and just go with a variable SQL query instead
 

susumakusu

Enthusiast
Code:
----------------------------------------------
-- TOP 5 per class                          //
-- Script by Renatokeys(emudevs)            //
-- http://emudevs.com                       //
----------------------------------------------

local NPC_ID = 60096

local ClassLocale = {
        [1] = {"Warrior", "660000"},
        [2] = {"Paladin", "FF0099"},
        [3] = {"Hunter", "CC6611"},
        [4] = {"Rogue", "CCFF00"},
        [5] = {"Priest", "FFFFFF"},
        [6] = {"Death Knight", "4D4D51"},
        [7] = {"Shaman", "0000CC"},
        [8] = {"Mage", "33FFFF"},
        [9] = {"Warlock", "660099"},
        [11] = {"Druid", "FF6600"}
};

function clica(event, plr, unit)
        plr:GossipMenuAddItem(0, "Choose the class : ", 0, 0)

        for k, v in pairs(ClassLocale) do
                plr:GossipMenuAddItem(0, "TOP 5 |cff"..v[2]..v[1], 0, k)
        end

        plr:GossipSendMenu(1, unit)
end

function seleciona(event, plr, unit, arg2, intid)
    if (intid > 0) then
        plr:SendBroadcastMessage("|cff"..ClassLocale[intid][2]..ClassLocale[intid][1])

                local resultado = CharDBQuery("SELECT name,totalKills FROM characters WHERE class='"..intid.."' ORDER BY totalKills DESC LIMIT 5")
        repeat
                        local playername = resultado:GetString(0);
                        local kills = resultado:GetUInt32(1);
                        plr:SendBroadcastMessage("|cFF33CCFFPlayer : |r ".. playername .." ,  |cFF33CCFFwith : |r" .. kills .. " Kills")
        until not resultado:NextRow()
        plr:GossipComplete()
    end
end
RegisterCreatureGossipEvent(NPC_ID, 1, clica)
RegisterCreatureGossipEvent(NPC_ID, 2, seleciona)

[MENTION=7]Foereaper[/MENTION] Here you are I fix some errors (name variables, simple stuff). Also close gossip windows when choose an option.

A question: Anybody knows how not to show GMs players? A sql statment for not to show players which are in GM accounts?
 
Top