Author Topic: [Answered] AppOnIdle bug?  (Read 1229 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
[Answered] AppOnIdle bug?
« on: May 27, 2007, 07:41:26 pm »
Code: [Select]
type
  PInfo = record
    Alive: boolean;
  end;

var
  Player: array[1..32] of PInfo;

procedure AppOnIdle(Ticks: integer);
var
  i: byte;
begin
  for i := 1 to NumPlayers do if Player[i].Alive <> GetPlayerStat(i,'Alive') then Player[i].Alive := GetPlayerStat(i,'Alive');
  if Player[i].Alive = true then Command('/say Player[' + InttoStr(i) + '].Alive = true') else Command('/say Player[' + InttoStr(i) + '].Alive = false');
end;

It seems to... not work?

« Last Edit: May 29, 2007, 03:56:22 pm by DorkeyDear »

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: AppOnIdle bug?
« Reply #1 on: May 27, 2007, 07:49:17 pm »
The for only includes the first if because you are not using begin..end. Also, there is no need for the first if, you can do it this way:

Code: [Select]
type
  PInfo = record
    Alive: boolean;
  end;

var
  Player: array[1..32] of PInfo;

procedure AppOnIdle(Ticks: integer);
var
  i: byte;
begin
  for i := 1 to NumPlayers do
  begin
    Player[i].Alive := GetPlayerStat(i,'Alive');
    if Player[i].Alive = true then
      Command('/say Player[' + InttoStr(i) + '].Alive = true')
    else Command('/say Player[' + InttoStr(i) + '].Alive = false');
  end;
end;

If you write all the code in one line it gets confusing, you know.
And also i think i read somewhere that you can't rely on NumPlayers. You should use 32 instead.
urraka

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: AppOnIdle bug?
« Reply #2 on: May 27, 2007, 09:24:37 pm »
Haha fool, stop blaming the engine for your own coding errors.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: AppOnIdle bug?
« Reply #3 on: May 27, 2007, 09:34:15 pm »
Haha fool, stop blaming the engine for your own coding errors.
Uhh, dude? C'mon... Its a QUESTION... basically, is it my fault, or is it the engines? if mine, how do i fix? if engines, then how should i do it / will it be fixed in the future.
Could you please at the least not be so rude and help me out by spotting what it is? I already asked somebody else if there was my error and they said no.

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: AppOnIdle bug?
« Reply #4 on: May 27, 2007, 09:40:18 pm »
Read the post prior to my last.... He hits the nail spot-on.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: AppOnIdle bug?
« Reply #5 on: May 27, 2007, 10:01:41 pm »
LMFAO, I missed that post.
Sorry about that.
*becomes embarrassed* :P