Author Topic: Calculateing Toplists ~>(- Solved -)<~  (Read 537 times)

0 Members and 1 Guest are viewing this topic.

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Calculateing Toplists ~>(- Solved -)<~
« 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.
« Last Edit: August 16, 2009, 05:55:45 am by Hacktank »