Official Soldat Forums
Server Talk => Scripting Releases => Topic started by: DorkeyDear on July 24, 2007, 11:30:19 pm
-
Script Name: After Player Respawn Event
Script Description: Procedure is called after a player respawns. I think this should be better than doing ThreadFunc([ID],'AfterPlayerRespawn') (with an extra Sleep(1) at the beginning) sense it doesn't end up with loads of errors when a group of players respawn all at ones (directed towards survival mode). Theres just one note. When using survival mode, sense code can not be ran through in an instant, the order that AfterPlayerRespawn is called from the player's ID may be different from the order that OnPlayerRespawn is called.
Original Author: Curt (DorkeyDear)
Core Version: 2.6.1b
Code:procedure AfterPlayerRespawn(ID: byte);
begin
//Code to be executed after a player respawns (basic test was using ForceWeapon procedure)
end;
procedure RespawnCheckLoop;
var
i: byte;
Alive: array[1..32] of boolean;
begin
while true do begin
for i := 1 to 32 do if GetPlayerStat(i,'Active') = true then begin
if (Alive[i] = false) and (GetPlayerStat(i,'Alive') = true) then begin
Alive[i] := true;
AfterPlayerRespawn(i);
end else if (Alive[i] = true) and (GetPlayerStat(i,'Alive') = false) then Alive[i] := false;
end else Alive[i] := false;
Sleep(1);
end;
end;
procedure ActivateAfterRespawn;
begin
ThreadFunc([],'RespawnCheckLoop');
end;
procedure ActivateServer();
begin
ActivateAfterRespawn;
end;
Now if ThreadFunc always worked properly, then I believe this would work properly! But if ThreadFunc worked properly, then I wouldn't have ever posted this sense I would be using a ThreadFunc([ID],'AfterRespawn') on OnPlayerRespawn with a Sleep(1) at t he beginning of AfterRespawn, and it wouldn't be buggy at all! :'(
-
Great, it was necessary :)
-
I tried implementing in my script today and its a complete failure, lol.. ThreadFunc wants to give me errors.
Sometimes it wants to work, other times it doesn't.. I hate it!! Why doesn't the socket loop bring up errors then? :'( Makes me sad.
-
wait, you tested it after you released it and it doesn't work? Shouldn't you have tested it before? Or is it the case that it worked before and few times it doesn't?
-
I tested it before, it worked.. then i released it. then the next day (today) i tried implementing it in the script im currently working on, and it wants to be extremely frustrating... with errors.. and errors.. and errors.
Man ThreadFunc is evil sometimes...
-
ThreadFunc is buggy, hence why it isnt documented... duh