EZ Server

General Category => General Discussion => Topic started by: Hunter on April 11, 2013, 09:01:10 am



Title: Leaderboards
Post by: Hunter on April 11, 2013, 09:01:10 am
Now that I have more experience in certain areas like writing perl quest using DBI, starting to realize how we could make leader boards both on website and in game.

Would probably require a custom table to speed things up, rather than query the entire character and inventory table each time someone wanted to see for example the Top Ten Warriors via HP. Custom table would probably have CharID, Name, Race, Class, Level, HP, AC, Money, Time Played, and a few other things.

Maybe update the table when player logs in or connects? Some variables already available without having to do any queries, like $name, $race, $class and maybe some others in there to find $Client->HP or whatever the functions are.

Looking for ideas for Leader Board Categories such as HP, Time Played, Etc, and for how to implement it. Maybe even a server wide announcement when someone breaks the record, for example when someone sets a new record for highest HP, it would message to everyone about it, the players name, their hp, etc.

Anyways, just an idea I woke up thinking about a few minutes ago. Any feed back, help, and ideas welcome :)


Title: Re: Leaderboards
Post by: Tankzilla on April 11, 2013, 09:34:57 am
This would be awesome, but the tops would be from Rage - and Magister. thats pretty much it  ( Atleast i think so unless theres unknown bad a$$es out there)


Title: Re: Leaderboards
Post by: Fugitive on April 11, 2013, 09:54:50 am
The Vets of Magister are badass they not super vocal bit don't undercut them. There are a few sleepers that are geared out and rock too. So a lot of /shock for players if leaders go active.

BTW Gear doesn't make you a good player it helps most people.. Look at half the F'd up gimps in T7 still figuring out EZ basics
......

..


Title: Re: Leaderboards
Post by: Hunter on April 11, 2013, 09:58:02 am
Could do top 10, top 50, top 100, variety of categories, etc.

Category: Ring of the Ages Ranks (Fugitive would be 1st place).


Title: Re: Leaderboards
Post by: Fugitive on April 11, 2013, 09:59:07 am
Could do top 10, top 50, top 100, variety of categories, etc.

Category: Ring of the Ages Ranks (Fugitive would be 1st place).


500!!


Title: Re: Leaderboards
Post by: Mattnaik on April 11, 2013, 10:02:05 am
Could do top 10, top 50, top 100, variety of categories, etc.

Category: Ring of the Ages Ranks (Fugitive would be 1st place).


500!!

Grats man!


Title: Re: Leaderboards
Post by: Xiggie | Stone on April 11, 2013, 12:09:15 pm
Ideas for categories. Top 10 rank items, (RoA, SoA), first to get items, Top 10 hp, Top 10 hp regen, (Same cats for mana), Top 10 played time, creation dates, (if this can be done as active only would be more relevant). May even consider doing instead of top 10 top 100. If it takes too much resources to do live update you could even have it do an update during reboot.


Title: Re: Leaderboards
Post by: Felony on April 11, 2013, 12:13:42 pm
Don't use play time or any of that crap.
You want to use leaderboards that any joe can join the server and take a crack at if that is their cup of tea.
How long someone sits afk in game should not be rewarded with a possible leaderboard slot.

Stuff people care about:
AC
HP
Mana
Rare and hard to macro err acquire items


Title: Re: Leaderboards
Post by: Premador on April 11, 2013, 12:37:23 pm
I agree with Felony, no reason to use playtime as a ranking.
Would be interesting to add it for curiosity sake in other rankings.

HP rankings
1.soandso   2000000hp 1000000000days played
2.soandso2 1999999hp 100000000days played....


Would also be cool to be able to call up your ranking in the system. like...
/hpranking Premador

Premador is ranked #454 for hp on server.



Title: Re: Leaderboards
Post by: Natedog on April 11, 2013, 01:37:42 pm
Could add AA to the list of things to track!


Title: Re: Leaderboards
Post by: Peign on April 12, 2013, 12:00:21 am
RoA tracks AA no?   Tracking AA seems redundant. 

Fugitive   ~ tgm


Title: Re: Leaderboards
Post by: Natedog on April 12, 2013, 02:11:23 pm
Well after 500 ROA it would just stop no?

If you tracked AA it can keep going up! =p


Title: Re: Leaderboards
Post by: hateborne on April 12, 2013, 02:56:48 pm
Well after 500 ROA it would just stop no?

If you tracked AA it can keep going up! =p

Heh I'm all for it. I wish we could keep track of AAXP every day. Then we could see who is bot farming. :-P

-Hate


Title: Re: Leaderboards
Post by: Fugitive on April 12, 2013, 03:03:30 pm
Not really people could just turn off AA.. =(


Title: Re: Leaderboards
Post by: Ybik on April 12, 2013, 03:26:22 pm
I think he meant people bot farming aaxp but I could be wrong.


Title: Re: Leaderboards
Post by: Fugitive on April 12, 2013, 03:36:21 pm
shrug would be all over the place a geared player hard grinding can crank out 2-5k per hour with UW+ the 250% item.. where as others would be all over the place.


Title: Re: Leaderboards
Post by: Hunter on April 14, 2013, 02:06:46 am
I have 1 person already working on a webpage based leader boards and I'm probably going to make some in game leader boards.

With the coding aside, what would be a good way to get the information?

Query Cache?

What query to run, and when?

For example, how would we get everyones max hp? Add up all the hp on every item in inventory table slots 0-21? That'd take a while to get totals with inner join queries.

So yeah, need help to write up the queries I guess, which would be easiest and fastest.


Title: Re: Leaderboards
Post by: Natedog on April 14, 2013, 02:32:57 am
Code:
my $hptotal = $client->GetMaxHP();
my $manatotal = $client->GetMaxMana();
my $actotal = $client->GetAC();


Not sure when to run it though...

I have an NPC that you can add yourself to the Leaderboard on my test server. Could add a Global so that you can only add yourself once per 24 hours.



Title: Re: Leaderboards
Post by: Hunter on April 14, 2013, 03:40:55 am
There is a good idea. Choose when to add yourself to leader boards, via 24 hour cool down.

When adding, all your statistics get added to a custom table which then can be queried for different stuff like HP.


Title: Re: Leaderboards
Post by: Hunter on April 14, 2013, 08:39:31 am
Currently Leaderboards only adds players that hail the Leaderboards NPC.

If you don't want your stats up on there, then don't hail with your character. Just an alt to hail with to see what is on it.

Hope makes sense.

Will need some more time to figure out who or how will be added to it later autmatically, maybe even give an opt-out option for players that want to be private.



Title: Re: Leaderboards
Post by: Natedog on April 14, 2013, 04:19:08 pm
I hailed the Leaderboard on Paldail earlier and it gave me "Unknown" Race because I was a baddie and I was in skeleton illusion.

Guessing playable race illusions you could fake whatever race you are.

If you want to get a players Base Race can use this.


Code:
my $baserace = $client->GetBaseRace();
my %racelist = (
1 => ["Human"],
2 => ["Barbarian"],
3 => ["Erudite"],
4 => ["Wood Elf"],
5 => ["High Elf"],
6 => ["Dark Elf"],
7 => ["Half Elf"],
8 => ["Dwarf"],
9 => ["Troll"],
10 => ["Ogre"],
11 => ["Halfling"],
12 => ["Gnome"],
330 => ["Froglok"],
522 => ["Drakkin"],
);
my $baserace2 = $racelist{$baserace}[0];


So $baserace2 would spit out whatever their real race is... could even go as far as Shortening each Race name inside that list.  Can do the same thing for class as well if you wanted to shorten the way they show up.




Title: Re: Leaderboards
Post by: Hunter on April 14, 2013, 06:20:05 pm
Will use that!

Thanks :)


Title: Re: Leaderboards
Post by: Hunter on April 14, 2013, 08:17:21 pm
When I change from top 10 to top 15 via LIMIT 10 in the $query, then the leaderboards doesn't work anymore.

Here is the segment of the code, if anyone can figure out why?

Code:

my $query = "SELECT name, level, race, class, hp, mana, ac, played FROM leaderboards ORDER BY $ORDER_BY DESC LIMIT 10";
my $query_handle = $connect->prepare($query);
$query_handle->execute();

# GET THE 10 RECORDS
my $place_count = 1;
while(my $ref = $query_handle->fetchrow_hashref)
{
$GET_NAME = $ref->{'name'};
$GET_LEVEL = $ref->{'level'};
$GET_RACE = $ref->{'race'};
$GET_CLASS = $ref->{'class'};
$GET_HP = commify2($ref->{'hp'});
$GET_MANA = commify2($ref->{'mana'});
$GET_AC = commify2($ref->{'ac'});
$GET_PLAYED = $ref->{'played'};
$GetDays = commify2(int($GET_PLAYED/(24*60*60)));
$GetDays = "Blocked";

push(@table, "<TR><TD>$place_count
<TD><c \"#FE2E2E\"> $GET_NAME </c>
<TD><c \"#DF7401\"> $GET_LEVEL </c>
<TD><c \"#868A08\"> $GET_RACE </c>
<TD><c \"#088A08\"> $GET_CLASS </c>
<TD><c \"#0B615E\"> $GET_HP </c>
<TD><c \"#0431B4\"> $GET_MANA </c>
<TD><c \"#8904B1\"> $GET_AC </c>
<TD><c \"#DF013A\"> $GetDays </c>
<TD>");
$place_count++;
}
push(@table, "</table>");

quest::popup("Top Ten Players by $ORDER_BY", "@table");


Also, I did this and still didn't help:

Code:
mysql> set global max_allowed_packet=100000000;
Query OK, 0 rows affected (0.00 sec)

Just realized it might be a perl issue with array size, not mysql issue.

Printing the array in chat crashes client.


Title: Re: Leaderboards
Post by: Natedog on April 14, 2013, 11:29:54 pm
Aye I did this same thing... and got the same results. Reason why I only do Top 10.  


I tried to have a "List all Players" ... and it just got mad at me ... lol



Seems I max out at .... 19 Rows  ... with 8 columns being pulled for each player.


Title: Re: Leaderboards
Post by: Hunter on April 15, 2013, 12:07:46 am
Probably a reason some where. Size of array, in either perl or mysql. Some else must have had this problem, so there should be an answer some where on Google, just need to find it.


Title: Re: Leaderboards
Post by: Natedog on April 15, 2013, 12:21:32 am
Code:
$sth = $dbh->prepare("SELECT  name, hp, mana, class, level, armor, aa, race FROM leaderboard ORDER BY hp DESC LIMIT 10,10");


This will do  11 - 20  if you want....

Can have it where you click "By HP"  then do different parts... 1-10, 11-20 , 21-30 .. ect


Title: Re: Leaderboards
Post by: Natedog on April 15, 2013, 12:33:30 am
Also I noticed I missed Vah Shir on that list of races if you used that and want to add it lol

I failed and missed Iksar as well...


Code:
128 => ["Iksar"],
130 => ["Vah Shir"],


Title: Re: Leaderboards
Post by: Hunter on April 15, 2013, 02:40:55 am
Yeah, I saw the LIMIT 10,10 but didn't think to use that lol, sort of like next page.

Will add other races too.

Thanks for help!


Title: Re: Leaderboards
Post by: Hunter on April 15, 2013, 04:59:05 am
Leaderboards updated again.

Will now add profile of players that login / connect for first time.

You can hail the NPC and request to be removed.

Now can see Top HP/Mana/AC sorted by class, and top 20 (page of 1-10 and page of 11-20).

Top Played Days shows order of who has most played time, but doesn't show the actual time.

Top ROA shows top 15 players with highest RoA ranks.

See Leaderboards NPC in Nexus.

Mostly tested and should be working with no issues.


Title: Re: Leaderboards
Post by: Hunter on April 15, 2013, 06:50:16 am
I got the entire @table to print to text file via write() with no problem.

So probably is issue with perl / popup window?

Crashes on this line of code:

quest::popup("Top Ten", "@table");


Title: Re: Leaderboards
Post by: Hunter on April 15, 2013, 07:16:16 am
More testing, changing array @table to string $table via using '.' for concat, didn't make any difference, works for top 10 but not 15.

Still trying to figure out why large variable / array crashing popup window

void quest::popup(char *title, char *text, int32 popupid, int32 buttons, int32 Duration);

void $client->SendPopupToClient(const char *Title, const char *Text, int32 PopupID, int32 Buttons, int32 Duration);

Maybe max size of const char or something? Guessing its size issue in eqemu source code some where.



Title: Re: Leaderboards
Post by: Hunter on April 15, 2013, 08:13:17 am
Just thought of an idea. Could turn players names into a website link to bring up the players Magelo.

Just a neat feature short cut idea, but would probably conflict with size of info being passed to the popup window which we need to fix first.

Showing 10 results per popup is good idea anyways.


Title: Re: Leaderboards
Post by: Natedog on April 15, 2013, 03:40:26 pm
The text length in game is a client issue I think...

Sending a HUGE Array to chat WILL crash you... doing it in the Popup box just makes the box not work.  (Just a guess)

But this is what it seems like.


Title: Re: Leaderboards
Post by: lerxst2112 on April 15, 2013, 04:38:12 pm

The client can handle just under 4k for a chat message from the server.  I'm not sure if the same limit applies to the popup box as I didn't test that.


Title: Re: Leaderboards
Post by: Natedog on April 15, 2013, 06:34:44 pm
I'd suggest a minimum level for the Leaderboard... when you create a Level 1 Wizard it has a bugged amount of AC lol

Erudite Wizards have 65,534 AC  which is odd... 1 more AC than a level 1 Gnome Wizard


#Mystats  .... Erudite Wizard starts with -2 AC

ATK they start with is 65,531


Going negative in stats makes them really high.



Level 2 Erudite Wizard has the most AC though at -1 AC heh... wonder why they start with negative AC.. =\


Title: Re: Leaderboards
Post by: Hunter on April 15, 2013, 08:48:49 pm
Maybe minimum level 60, pointless for lower levels.


Title: Re: Leaderboards
Post by: Hunter on April 15, 2013, 08:52:32 pm
Now that we have a working beta leaderboards, I can expand on it.

Make minimum level 60 to be on it.

Also other stats like HP regen and Mana Regen.

Since we're limited to 4k size of message, then maybe top 10's would combine hp and hp regen, then mana and mana regen. Either way, I can't display all stat cause we'd go over the 4k size limit.

So what do we want to see? How do we get the info?

We want hp/mana regens? Whats the code to get that info?

I could easily do who got killed most by buff bot but that'd only encourage spamming.

I could do who died most times via global_npc.pl, haven't tried yet but sure its possible.

I thought about money but some people said thats private info. Same with days played.



Title: Re: Leaderboards
Post by: red2 on April 15, 2013, 10:29:13 pm
have it do a unique query, to tell you what # you are on the list? have it just return you are #37 .. etc


Title: Re: Leaderboards
Post by: Natedog on April 16, 2013, 12:35:23 am
have it do a unique query, to tell you what # you are on the list? have it just return you are #37 .. etc


Code:
if ($text=~/MY RANK/i)
{
$sth = $dbh->prepare("SELECT hp from leaderboard WHERE name = '$name'");
$sth->execute();
my $rankedHP = $sth->fetchrow_array();
$sth = $dbh->prepare("SELECT COUNT(hp) from leaderboard WHERE hp > $rankedHP");
$sth->execute();
my $ranked = int($sth->fetchrow_array()+1);
$client->Message(315,"You are Ranked Number $ranked on HP!");
if ($ranked > 10)
{
$ranklist = int($ranked -10);
}
else
{
$ranklist = int(1);
}
@table = "<table><TR><TD>#<TD>$Yel NAME </c><TD>$grn HP </c><TD>$Blu MANA </c><TD>$Pink CLASS </c>/$orange Race </c><TD>$Red LEVEL </c><TD>AC<TD>$purp AA </c><TD>";
$sth = $dbh->prepare("SELECT  name, hp, mana, class, level, armor, aa, race FROM leaderboard ORDER BY hp DESC LIMIT $ranklist,10");
$sth->execute();
$n = $ranklist;
if ($n > 1)
{
$n = $n+1;
}
while (my ($pname, $php, $pmana, $pclass, $plevel, $pac, $paa, $prace) = $sth->fetchrow_array())
{
my $php2 = plugin::commify($php);
my $pmana2 = plugin::commify($pmana);
my $pac2 = plugin::commify($pac);
my $paa2 = plugin::commify($paa);
push(@table, "<TR><TD>$n<TD>$Yel $pname </c><TD>$grn $php2 </c><TD>$Blu $pmana2 </c><TD>$Pink $pclass </c>/$orange $prace </c><TD>$Red $plevel </c><TD>$pac2<TD>$purp $paa2 </c><TD>");
$n++;
}
push(@table, "</table>");
quest::popup("Your Rank", "@table");
$sth->finish ();
$dbh->disconnect();
}


This will show the 9 players AHEAD of you in HP.. its fairly sloppy and probably could be written better... but this works and gives you an idea of how I did it heh.


Heres what it looks like...

(http://i574.photobucket.com/albums/ss189/jdub1337/Ranked.png) (http://s574.photobucket.com/user/jdub1337/media/Ranked.png.html)


Title: Re: Leaderboards
Post by: Hunter on April 16, 2013, 02:37:44 am
Went out today and beat from the heat, but will probably use some of that code soon into our current leaderboards, thanks again! :)


Title: Re: Leaderboards
Post by: Natedog on April 16, 2013, 07:24:04 pm
That code had a small error need to change how $n was calculated.

Code:
if ($text=~/MY RANK/i)
{
$sth = $dbh->prepare("SELECT hp from leaderboard WHERE name = '$name'");
$sth->execute();
my $rankedHP = $sth->fetchrow_array();
$sth = $dbh->prepare("SELECT COUNT(hp) from leaderboard WHERE hp > $rankedHP");
$sth->execute();
my $ranked = int($sth->fetchrow_array()+1);
$client->Message(315,"You are Ranked Number $ranked on HP!");
if ($ranked > 10)
{
$ranklist = int($ranked -10);
}
else
{
$ranklist = 0;
}
@table = "<table><TR><TD>#<TD>$Yel NAME </c><TD>$grn HP </c><TD>$Blu MANA </c><TD>$Pink CLASS </c>/$orange Race </c><TD>$Red LEVEL </c><TD>AC<TD>$purp AA </c><TD>";
$sth = $dbh->prepare("SELECT  name, hp, mana, class, level, armor, aa, race FROM leaderboard ORDER BY hp DESC LIMIT $ranklist,10");
$sth->execute();
$n = $ranklist;  #Set Rank to the Ranklist number
if ($ranked > 10)
{
$n = $n+1;   #If their rank is over 10 you must add 1 otherwise it won't be correct
}
if ($n == 0)
{
$n = 1;   #If they are in the top 10 need this part
}
while (my ($pname, $php, $pmana, $pclass, $plevel, $pac, $paa, $prace) = $sth->fetchrow_array())
{
my $php2 = plugin::commify($php);
my $pmana2 = plugin::commify($pmana);
my $pac2 = plugin::commify($pac);
my $paa2 = plugin::commify($paa);
push(@table, "<TR><TD>$n<TD>$Yel $pname </c><TD>$grn $php2 </c><TD>$Blu $pmana2 </c><TD>$Pink $pclass </c>/$orange $prace </c><TD>$Red $plevel </c><TD>$pac2<TD>$purp $paa2 </c><TD>");
$n++;
}
push(@table, "</table>");
quest::popup("Your Rank", "@table");
$sth->finish ();
$dbh->disconnect();
}


This one works better... had to find a way to get the numbered list to show up correctly for players ranked in the Top 10 when they checked their rank.


Title: Re: Leaderboards
Post by: Natedog on April 16, 2013, 07:39:28 pm
We want hp/mana regens? Whats the code to get that info?

I could do who died most times via global_npc.pl, haven't tried yet but sure its possible.


I don't see any Perl export for HP/Mana Regen.


Doing deaths would be awesome though!


Could maybe even do Boss kills?  Only for end bosses like OMM and such


Title: Re: Leaderboards
Post by: Hunter on April 19, 2013, 04:34:46 am
Added Resist and Richest leaderboards.

Might get some other ideas here:

https://github.com/EQEmu/Server/blob/master/zone/client.h (https://github.com/EQEmu/Server/blob/master/zone/client.h)


Title: Re: Leaderboards
Post by: Natedog on May 10, 2013, 01:31:28 pm
Took me all day... but I did it!


Used a bit of script from the AllaClone ... modified the script .. added some HTML and bam!

Hopefully EZs gets up soon! I wanna keep tabs on Fugitives HPz when I cant play! lol


http://108.239.155.107/AllaClone/leaderboard.php (http://108.239.155.107/AllaClone/leaderboard.php)


Title: Re: Leaderboards
Post by: Brokyn on May 10, 2013, 10:12:25 pm
That is awesome Nate!  Any chance to add a guild tag in there?