Author Topic: AppOnIdle Errors  (Read 846 times)

0 Members and 1 Guest are viewing this topic.

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
AppOnIdle Errors
« on: May 25, 2009, 05:51:37 pm »
Hello guys,
I get AppOnIdle Errors with my script ( Thanks to Curt =] )
Here is the script.
Code: [Select]
//Secret Project
var
FlagHolders: array[1..2] of byte;
Dropped: Array[1..32] of boolean;

procedure OnFlagDropped(const Id, Flag: byte);
 //var
  //Dropped: array[1..32] of boolean;
begin
    if Dropped[ID] = True then begin
     command('/kill ' +inttostr(ID));
  end;
end;

procedure AppOnIdle(Ticks: cardinal);
Var
i: Byte;
begin
 For i := 1 to 32 do
if (GetPlayerStat(FlagHolders[1], 'Flagger') = false) then begin // if the old alpha flag holder no longer has the flag
    OnFlagDropped(FlagHolders[1], 1);
    FlagHolders[1] := 0; // clear the alpha flag holder
    Dropped[i] := true;
  end;
  if (GetPlayerStat(FlagHolders[2], 'Flagger') = false) then begin
    OnFlagDropped(FlagHolders[2], 2);
    FlagHolders[2] := 0;
    Dropped[i] := True;
  end;
 end;

procedure OnFlagGrab(ID, TeamFlag: byte;GrabbedInBase: boolean);
begin
 ForceWeapon(ID,255,255,255);
  if (FlagHolders[TeamFlag] <> 0) then // if there was an old flag holder (can be the same person)
    OnFlagDropped(FlagHolders[TeamFlag], TeamFlag);
  FlagHolders[TeamFlag] := Id; // set the new flag holder for the given team flag
// other contents
end;

Procedure OnFlagScore(ID, TeamFlag:Byte);
//Var
//Dropped: Array [1..32] of boolean;
begin
   Dropped[ID]:=False;
   ForceWeapon(ID,7,1,1);     
end;

procedure OnJoinTeam(ID, Team: byte);
begin
  Dropped[ID]:=False;
end;

procedure OnPlayerRespawn(ID: Byte);
begin
 Dropped[ID]:=False;
end;
I tried with
Code: [Select]
For i := 1 to 32 do begin for all procedures but it wasn't detecting the false either the true.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: AppOnIdle Errors
« Reply #1 on: May 26, 2009, 09:05:31 am »
I realized an error in my code and modified it:
Code: [Select]
var
  FlagHolders: array[1..2] of byte;

procedure OnFlagDropped(const Id, Flag: byte);
begin
WriteLn('OnFlagDropped(' + InttoStr(Id) + ', ' + InttoStr(Flag) + ');');
end;

procedure AppOnIdle(Ticks: cardinal);
begin
  if (FlagHolders[1] > 0) then
    if (GetPlayerStat(FlagHolders[1], 'Active') = true) then
      if (GetPlayerStat(FlagHolders[1], 'Flagger') = false) then begin
        OnFlagDropped(FlagHolders[1], 1);
        FlagHolders[1] := 0;
      end;
  if (FlagHolders[2] > 0) then
    if (GetPlayerStat(FlagHolders[2], 'Active') = true) then
      if (GetPlayerStat(FlagHolders[2], 'Flagger') = false) then begin
        OnFlagDropped(FlagHolders[2], 2);
        FlagHolders[2] := 0;
      end;
end;

procedure OnFlagGrab(Id, TeamFlag: byte; GrabbedInBase: boolean);
begin
  if (FlagHolders[TeamFlag] <> 0) then
    OnFlagDropped(FlagHolders[TeamFlag], TeamFlag);
  FlagHolders[TeamFlag] := Id;
end;

procedure OnFlagScore(Id, TeamFlag: byte);
begin
  FlagHolders[TeamFlag] := 0;
end;
Actually tested this time. It seems to work. Also made it so OnFlagDropped doesn't get called when a player caps the flag.
The code is not your posted code modified, but rather my old code modified. You will need to re-implement what you were trying to implement before.

I don't advise you to modify the contents of my part of AppOnIdle (unless you really want to); I'd rather put it in OnFlagDropped. It seems as though you are wanting to set all Dropped values for all players to true when a player captures the flag. Under OnFlagDropped, for i := 1 to 32 do Dropped[ i ] := true;
« Last Edit: May 27, 2009, 05:20:16 am by DorkeyDear »

Offline VinceBros

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 275
Re: AppOnIdle Errors
« Reply #2 on: May 26, 2009, 06:01:01 pm »
Another Time Curt.
Thanks alot =)