Author Topic: Stats & Ranks  (Read 5968 times)

0 Members and 1 Guest are viewing this topic.

Offline Zabijaka

  • Soldier
  • **
  • Posts: 201
  • Soldat Fan, Hitman Fan
Stats & Ranks
« on: August 31, 2009, 06:40:26 am »
Script Name: Stats and Ranks (beta)
Script Description: Simple stats with rank system based on MySSQL database, no accounts creation, no passwords, stats are stored by player names. You can use this with nickregistration script.
Authors: (/-\|)/-\/V\ -coder, CurryWurst -MySSQL and debuging help, Zabijaka -idea creator)
Core Version: 2.6.5

More info:
Script record kills, deaths and points (points=(kills*k/d ratio)/10). Selfkills are not stored in database (good for RS servers).
Code: [Select]
procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
If (Killer<>Victim) and (GetPlayerStat(Killer,'Team')<>GetPlayerStat(Victim,'Team')) then begin
Kills[Killer]:=Kills[Killer]+1;
Deaths[Victim]:=Deaths[Victim]+1;
SaveStats(Killer);
SaveStats(Victim);
end;
end;

procedure SaveStats(i:Byte);
var
row:Longword;
Killss,Deathss:Integer;
begin
row:=GetRowByPlayer(IdToName(i));
Killss:=StrToInt(GetPiece(Database[Row], #9, 2));
Deathss:=StrToInt(GetPiece(Database[Row], #9, 3));
_SetColumn(Row, 2 , IntToStr(Killss+Kills[I]));
_SetColumn(Row, 3 , IntToStr(Deathss+Deaths[I]));
_SetColumn(Row, 1 , Rnd(FloatToStr((Killss/Deathss*Killss)/10)));
Kills[I]:=0;
Deaths[I]:=0;
end;

Script use quicksort function to sort ranks (on map change sort is automaticaly activated, admin can use command /sort to manualy activate function).
Script have backup procedure (automaticaly every 2h and manualy by command /backup) so
script needs folder "temp" in server root location
stats database are created automaticaly in server root location (stats.txt).

Commands for players:
!stats
Rank x/xx
Points
Kills
Deaths
K/D ratio

!top - show top 20 players and theirs points

Update 7.09.2009
1.Integer Points in database (float numbers use more cpu at sorting procedure and integers are more stable imo xD).
2.Command !top now show top 20 players (more usefull imo).

Update 24.09.2009
3.New version of ixsplit function (http://forums.soldat.pl/index.php?topic=35698.0)
Good improvement of stability.


Generaly thats all, simple and sexy xD


« Last Edit: September 25, 2009, 03:25:30 am by Zabijaka »

Offline 9al3a

  • Major(1)
  • Posts: 1
Re: Stats & Ranks
« Reply #1 on: September 24, 2009, 10:37:25 am »
i tried to used it on my pub server, but once the state.txt got a good amount of information the script throw errors here and there.
but thx for the effort

Offline Zabijaka

  • Soldier
  • **
  • Posts: 201
  • Soldat Fan, Hitman Fan
Re: Stats & Ranks
« Reply #2 on: September 24, 2009, 12:47:24 pm »
I know about exept violations errors, today I remove old ixsplit function and add new version by DorkeyDear (http://forums.soldat.pl/index.php?topic=35698.0)
This is very good improvement of stability. Check new version.

btw. if script crash use the backup to recover stats (restart server needed).
« Last Edit: September 24, 2009, 12:54:25 pm by Zabijaka »

Offline Furai

  • Administrator
  • Veteran
  • *****
  • Posts: 1908
    • TransHuman Design
Re: Stats & Ranks
« Reply #3 on: September 24, 2009, 01:16:57 pm »
Coder == {:Z:} /-\|)/-\/V\ ??
"My senses are so powerful that I can hear the blood pumping through your veins."

Offline Zabijaka

  • Soldier
  • **
  • Posts: 201
  • Soldat Fan, Hitman Fan
Re: Stats & Ranks
« Reply #4 on: September 24, 2009, 01:23:52 pm »
« Last Edit: October 09, 2009, 02:30:54 am by Zabijaka »

Offline Furai

  • Administrator
  • Veteran
  • *****
  • Posts: 1908
    • TransHuman Design
Re: Stats & Ranks
« Reply #5 on: September 24, 2009, 01:59:57 pm »
I was founder to his nickname about 2 years ago. (; Didn't know that he started coding though.
"My senses are so powerful that I can hear the blood pumping through your veins."

Offline KEEN

  • Major
  • *
  • Posts: 95
  • soldat champagne
    • Soldat Argentina
Re: Stats & Ranks
« Reply #6 on: November 16, 2009, 02:31:45 pm »
Hi, I've a query about how to apply this script to my server.

How should the tables in MySQL? Which fields should contain?

Thanks bro!

Offline dominikkk26

  • Camper
  • ***
  • Posts: 404
    • PMGsite
Re: Stats & Ranks
« Reply #7 on: November 16, 2009, 02:51:18 pm »
Older versions have been better for me!