Author Topic: Choosing of the best player  (Read 896 times)

0 Members and 1 Guest are viewing this topic.

Offline Martino

  • Major(1)
  • Posts: 18
Choosing of the best player
« on: September 04, 2007, 02:26:49 pm »
I want to make script that will choose player with highest score and if he will be able to do something. I wrote this script but it isn't working.
Code: [Select]
var
m: byte;
f:byte;
highscore: integer;
procedure HighscorerChange(highscore:integer; highscorer: byte);
begin
for m:=1 to 32 do if GetPlayerStat(m,'kills')>highscore then begin
m:=GetPlayerStat(highscorer,'id');
highscore:=GetPlayerStat(highscorer,'kills');
WriteConsole(0,'bbb',rgb(0,0,100));
Writeln('bbb');
end;
end;

If anybody can help please write here.

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Choosing of the best player
« Reply #1 on: September 06, 2007, 11:16:59 pm »
It compiles fine...
I think that your problem is that nothing calls this procedure so... it never runs. How often do you want this to run?

Offline Kavukamari

  • Camper
  • ***
  • Posts: 435
  • 3.14159265358979, mmm... pi
Re: Choosing of the best player
« Reply #2 on: September 06, 2007, 11:31:23 pm »
I'm not sure, but is HighScorerChange a valid procedure? can you do that? make ur own procedures?
"Be mindful of fame, show a mighty courage, watch against foes. Nor shalt thou lack what thou desirest, if with thy life thou hast comest out from that heroic task."

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1906
Re: Choosing of the best player
« Reply #3 on: September 06, 2007, 11:44:00 pm »
I'm not sure, but is HighScorerChange a valid procedure? can you do that? make ur own procedures?
Yes, you can. If you want to use it the way I suspect you'd be better off with a function to return the ID of the player with the highest score though.

My two cents (haven't really tested it but it should work in theory):

Code: [Select]
function HighestScorePlayer():byte;
var
i,high_id: byte;
high_score: integer;
begin
high_score:=-1;
for i:=1 to 32 do begin
if GetPlayerStat(i,'active')=false then continue;
if GetPlayerStat(i,'kills')>high_score then begin
high_id:=i;
high_score:=GetPlayerStat(i,'kills');
end;
end;
result:=high_id;
end;

Then you'd assign the result of HighestScorePlayer to a variable and you'd have the ID of the player with the highest score there. Do whatever you want of it.

Offline Martino

  • Major(1)
  • Posts: 18
Re: Choosing of the best player
« Reply #4 on: September 11, 2007, 01:43:43 pm »
i want to run this every time that id of best player changes.