Author Topic: [Event] AfterPlayerRespawn  (Read 2895 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
[Event] AfterPlayerRespawn
« 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:
Code: [Select]
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! :'(
« Last Edit: July 25, 2007, 10:55:39 am by DorkeyDear »

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: [Event] AfterPlayerRespawn
« Reply #1 on: July 25, 2007, 04:24:28 am »
Great, it was necessary :)
« Last Edit: July 25, 2007, 04:35:52 am by xmRipper »
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: [Event] AfterPlayerRespawn
« Reply #2 on: July 25, 2007, 10:42:45 am »
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.

Offline zyxstand

  • Veteran
  • *****
  • Posts: 1106
  • Mother of all Bombs
Re: [Event] AfterPlayerRespawn
« Reply #3 on: July 25, 2007, 10:49:28 am »
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?
Can't think of anything original to put here...

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: [Event] AfterPlayerRespawn
« Reply #4 on: July 25, 2007, 10:54:12 am »
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...

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: [Event] AfterPlayerRespawn
« Reply #5 on: July 25, 2007, 12:29:08 pm »
ThreadFunc is buggy, hence why it isnt documented... duh
urraka