I never thought OnPlayerRespawn was threaded, and still am in doubt, but after what I did today, I became a little confuzzled...
function AlivePlayers(Team: shortint): byte;
var
i: byte;
begin
for i := 1 to 32 do if (GetPlayerStat(i,'Active') = true) and (GetPlayerStat(i,'Alive') = true) and ((Team = -1) or (GetPlayerStat(i,'Team') = Team)) then Result := Result + 1;
end;
procedure AfterRespawn(ID: byte);
begin
Sleep(10);
ForceWeapon(ID,RespawnWeapon[ID][1],RespawnWeapon[ID][2],0);
RespawnWeapon[ID][1] := 255;
RespawnWeapon[ID][2] := 255;
end;
procedure OnPlayerRespawn(ID: byte);
begin
if AlivePlayers(-1) = 0 then Timer := TimerLimit;
Command('/say ID = ' + InttoStr(ID) + '; AlivePlayers(-1) = ' + InttoStr(AlivePlayers(-1)));
ThreadFunc([ID],'AfterRespawn');
end;
Survival mode is enabled...
I'm testing with bots.
I add 4 bravo bots while im alpha.
I kill myself
They die.
Everybody respawns.
The Command procedure is only called four times when it should be called five times, sense there are five players. Errors related to ThreadFunc come up, nothing unexpected due to its instability.
Now I comment out the ThreadFunc line...
Everybody respawns, starting at 2, going up, and then takes care of player 1... Alive players goes up from 1 to 5.
Two problems.. even if I don't use the ThreadFunc line, the number of AlivePlayers should go from 0 to 4 if I am thinking this though correctly, sense it is called b4 the players actually respawn, when player 2's OnPlayerRespawn is called (the first time it is called), the number of alive players is 0 but it says it is 1.
Now when I use ThreadFunc, which is required or my script, it gets really messy... Other than error messages coming up many times every time the group of people respawning, theres a problem... When the error comes up for player number 1 (the 5th time OnPlayerRespawn is called), it seems to act as if everything that already happened in OnPlayerRespawn never happened (it doesn't call the procedure Command)
sry if my wording is confusing