PDA

View Full Version : Top 5 PVP kills



renatokeys
03-19-2014, 01:32 PM
Hello again...

New script to share! Top 5 kills per Class


THX Foereaper for optmize my code.

http://i.imgur.com/DfrmfKW.jpg




53tmyyid



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

Foereaper
03-19-2014, 04:08 PM
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 :)

renatokeys
03-19-2014, 07:00 PM
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
03-19-2014, 07:15 PM
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
03-19-2014, 09:55 PM
Untested but should work :)


----------------------------------------------
-- 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
08-21-2016, 08:58 AM
----------------------------------------------
-- 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)


Foereaper 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?