Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: Zabijaka on August 31, 2009, 06:40:26 am

Title: Stats & Ranks
Post by: Zabijaka 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


Title: Re: Stats & Ranks
Post by: 9al3a 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
Title: Re: Stats & Ranks
Post by: Zabijaka 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).
Title: Re: Stats & Ranks
Post by: Furai on September 24, 2009, 01:16:57 pm
Coder == {:Z:} /-\|)/-\/V\ ??
Title: Re: Stats & Ranks
Post by: Zabijaka on September 24, 2009, 01:23:52 pm
Coder == {:Z:} /-\|)/-\/V\ ??

Yes
Title: Re: Stats & Ranks
Post by: Furai 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.
Title: Re: Stats & Ranks
Post by: KEEN 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!
Title: Re: Stats & Ranks
Post by: dominikkk26 on November 16, 2009, 02:51:18 pm
Older versions have been better for me!