Author Topic: for i := 1 to 32 and return 0 :O  (Read 1756 times)

0 Members and 1 Guest are viewing this topic.

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
for i := 1 to 32 and return 0 :O
« 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');



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
« Last Edit: December 24, 2016, 07:10:09 pm by soldat-game »

Offline Falcon`

  • Flagrunner
  • ****
  • Posts: 792
  • A wanted lagger
Re: for i := 1 to 32 and return 0 :O
« Reply #1 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
If you're not paying for something, you're not the customer; you're the product being sold.
- Andrew Lewis

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Re: for i := 1 to 32 and return 0 :O
« Reply #2 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.