Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: Hacktank on August 14, 2009, 06:26:11 am

Title: Calculateing Toplists ~>(- Solved -)<~
Post by: Hacktank on August 14, 2009, 06:26:11 am
I am makeing my own spree script which has a toplist but i have never been able to get toplists to work, they always save duplicate names and stuff.

Here is the code that is called in onplayerkill:
Code: [Select]
procedure CheckTop(ID: byte);
var i,np: integer;
begin
np := getstringindex(getplayerstat(ID,'name'),topnames);
for i := 1 to toplist do begin
if ((np=-1) OR (np+1>=i)) then if spree[ID] > topsprees[i] then begin
topsprees[i] := spree[ID];
topnames[i] := getplayerstat(ID,'name');
exit;
break;
end;
end;
end;

[FIXED CODE]
Code: [Select]
procedure CheckTop(ID: byte);
var i,np: integer;
begin
np := getstringindex(getplayerstat(ID,'name'),topnames);
for i := 1 to toplist do begin
if (np=-1) then if spree[ID] > topsprees[i] then begin
topsprees[i] := spree[ID];
topnames[i] := getplayerstat(ID,'name');
break;
end;
end;
if np > -1 then begin
if np > 0 then if spree[ID] > topsprees[np] then begin
topsprees[np+1] := topsprees[np];
topnames[np+1] := topnames[np];
topsprees[np] := spree[ID];
topnames[np] := getplayerstat(ID,'name');
exit;
end;
if spree[ID] > topsprees[np+1] then topsprees[np+1] := spree[ID];
end;
end;
[/FIXED CODE]

Here is an example of the problem: (from toplist.txt)
Code: [Select]
158 .0.
22 renato
10 renato
10 Funbox
9 .:TLW:.Sarumar
4 .:TLW:.Sarumar
4 Nationkid
1 `Niv
1 .:TLW:.Sarumar
1 Nationkid
Notice how renato and sarumar are there twice.

What am i doing wrong?

Thank you.

EDIT: After a two day break from this script i came back facepalming myself for not seeing the solution.