Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: soldat-game on December 24, 2016, 07:03:38 pm

Title: for i := 1 to 32 and return 0 :O
Post by: soldat-game on December 24, 2016, 07:03:38 pm
for i := 1 to 32 and return 0 :O

First start it:
Code: [Select]
procedure StartMatch();
var i:byte;
begin
MatchOn:=true;
 ..
Anty := 1;
...
Command('/restart');
end;

Next if map is restarting he leave game:
Code: [Select]
procedure LeaveGame(Player: TActivePlayer; Kicked: Boolean);
begin
if (MatchOn) then begin
if (PlayerInfo[Player.ID].InMatch) then CheckBattle(Player.ID);
end;
....
end;

next see check battle:
Code: [Select]
procedure CheckBattle(Loser:byte);
var i, Winner, One, Two: byte; x:integer;
begin
if (Anty=1) then anty:=0 else begin
if (GameStyle = 0) then begin
Writeln('TEST 001');
if (MatchOn) then begin
Writeln(inttostr(loser));
Writeln('TEST 002');
for i := 1 to 32 do if (Players[i].Active) then if (PlayerInfo[i].InMatch) then One:=i;
Writeln('TEST 003');
for i := 1 to 32 do if (Players[i].Active) then if (PlayerInfo[i].InMatch) and (One<>i) then Two:=i;
Writeln('ID '+inttostr(one)+' '+inttostr(two)); //result 1 and 0 LOL                                    <--- RETURN 0 :O HOW
if (Players[One].Kills>=MinimalKills) or (Players[Two].Kills>=MinimalKills) then begin
Writeln('TEST 004');

(http://s2.ifotos.pl/img/wdawdPNG_aepepnh.png)

It seems to me that this is so only when the player leaves the game when it is reset map, ID player leave game is 0? what? And what right loop 1 .. 32 find player witch id 0 :O
Title: Re: for i := 1 to 32 and return 0 :O
Post by: Falcon` on December 24, 2016, 10:04:02 pm
Your 2nd loop couldn't find a player that is Active, InMatch and <> One, so since variable Two got initialized with 0, it stayed that way
Title: Re: for i := 1 to 32 and return 0 :O
Post by: soldat-game on December 25, 2016, 06:17:43 am
But all happens when a player leaves the server and then any Changes to the player, you can still find and my variables player are restarted right at the end.