Author Topic: Wierd Error  (Read 1281 times)

0 Members and 1 Guest are viewing this topic.

Offline rayanaga

  • Soldier
  • **
  • Posts: 143
  • ~Fur flying~
    • Kryonex
Wierd Error
« on: June 01, 2008, 07:29:09 pm »
Being a C++ developer, i picked up on Pascal very easily. Its a lot like basic.

I'm making a mod but i get this very wierd Error:

Quote
Error: OnJoinTeam: Out of range
Error: OnJoinTeam: Out of range
Error: OnJoinTeam: Out of range
Error: OnJoinTeam: Out of range
Error: OnJoinTeam: Out of range
Error: OnJoinTeam: Out of range
Error: OnJoinTeam: Out of range
Error: OnJoinTeam: Out of range
Error: OnJoinTeam: Out of range
Error: OnJoinTeam: Out of range
Error: OnJoinTeam: Out of range
Error: OnJoinTeam: Out of range
Error: OnJoinTeam: Out of range
Error: OnJoinTeam: Out of range
Error: OnMapChange : Out of range.

Anyone know how to solve this?
[kY] Kryonex - Your local zombie fanatics.
http://www.kryonex.com/

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Wierd Error
« Reply #1 on: June 01, 2008, 07:37:59 pm »
Usually out of range deals with trying to index an invalid spot in an array... Could we see the code?
For dynamic arrays (declared like Blarg: array of byte;), you must do SetArrayLength(Ary: array of variant; Length: <not sure exactly what datatype, but the sense of unsigned integers>);
Note that if you do SetArrayLength(Blarg, 1); the only index you may use is 0, one less than it's length.

Offline rayanaga

  • Soldier
  • **
  • Posts: 143
  • ~Fur flying~
    • Kryonex
Re: Wierd Error
« Reply #2 on: June 01, 2008, 07:46:27 pm »
Quote
//Setup
////////
var
  Cash: array[1..50] of integer;
  Mana: array[1..50] of integer;
  Zombied: array[1..50] of integer;
  i: Integer;
  temp: string;
  piece: array[0..10] of string;
  shiftx: array[1..50] of integer;
  shifty: array[1..50] of integer;
  stat: array[1..50] of integer;

Quote
procedure OnMapChange(NewMap: String);
begin
//First get rid of the old wave;
Command('/kick Zombie');

//Then set every player to unzombied and give bonuses to survivors.
   for i := 1 to 50 do
      begin       
        if GetPlayerStat(1,'Team') = 1 then
           begin
            Cash := Cash + 1500;
            Mana := Mana + 40;
            WriteConsole(i,'You recieved $1500 and 40% Mana for surviving!',$EE81FAA1);
            if Mana > 99 then
            Mana := 100;
           end;
        //shiftx := 0;
        //shifty := 0;
        stat   := 0;
        Zombied := 0;
        Command('/setteam1 ' + inttostr(i));
      end;

//Now spawn the first wave
WriteConsole(0,'Wave 1 has spawned',$EE81FAA1);
Command('/addbot2 zombiegrunt');
Command('/addbot2 zombiegrunt');
end;
Quote
procedure OnJoinTeam(ID, Team: byte);
begin
if Team = 1 then
begin
if Zombied[ID] = 1 then
begin
Command('/setteam2 ' + inttostr(ID));
WriteConsole(ID,'Bad Zombie! You cannot join the humans until next round!',$EE81FAA1);
end;
SetWeaponActive(ID, 1, false);
SetWeaponActive(ID, 2, false);
SetWeaponActive(ID, 3, true);
SetWeaponActive(ID, 4, false);
SetWeaponActive(ID, 5, false);
SetWeaponActive(ID, 6, false);
SetWeaponActive(ID, 7, false);
SetWeaponActive(ID, 8, false);
SetWeaponActive(ID, 9, false);
SetWeaponActive(ID, 10, false);
SetWeaponActive(ID, 11, true);
SetWeaponActive(ID, 12, true);
SetWeaponActive(ID, 13, true);
SetWeaponActive(ID, 14, true);
end;

if Team = 2 then
begin
if Zombied[ID] = 0 then
begin
Zombied[ID] := 1;
WriteConsole(ID,'Silly Marine. Joining Bravo makes you a zombie!',$EE81FAA1);
end;
SetWeaponActive(ID, 1, false);
SetWeaponActive(ID, 2, false);
SetWeaponActive(ID, 3, false);
SetWeaponActive(ID, 4, false);
SetWeaponActive(ID, 5, false);
SetWeaponActive(ID, 6, false);
SetWeaponActive(ID, 7, false);
SetWeaponActive(ID, 8, false);
SetWeaponActive(ID, 9, false);
SetWeaponActive(ID, 10, false);
SetWeaponActive(ID, 11, false);
SetWeaponActive(ID, 12, false);
SetWeaponActive(ID, 13, true);
SetWeaponActive(ID, 14, false);
end;

if Team = 3 then
begin
Command('/setteam2 ' + inttostr(ID));
Zombied[ID] := 1;
end;

if Team = 4 then
begin
Command('/setteam2 ' + inttostr(ID));
Zombied[ID] := 1;
end;

end;
[kY] Kryonex - Your local zombie fanatics.
http://www.kryonex.com/

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Wierd Error
« Reply #3 on: June 01, 2008, 08:07:16 pm »
The max number of players is 32 btw, so 50 should be replaced with 32.

Quote
procedure OnMapChange(NewMap: String);
begin
//First get rid of the old wave;
Command('/kick Zombie');

//Then set every player to unzombied and give bonuses to survivors.
   for i := 1 to 50 do
      begin       
        if GetPlayerStat(1,'Team') = 1 then
           begin
            Cash := Cash + 1500;
            Mana := Mana + 40;
            WriteConsole(i,'You recieved $1500 and 40% Mana for surviving!',$EE81FAA1);
            if Mana > 99 then
            Mana := 100;
           end;
        //shiftx := 0;
        //shifty := 0;
        stat   := 0;
        Zombied := 0;
        Command('/setteam1 ' + inttostr(i));
      end;

//Now spawn the first wave
WriteConsole(0,'Wave 1 has spawned',$EE81FAA1);
Command('/addbot2 zombiegrunt');
Command('/addbot2 zombiegrunt');
end;
"if GetPlayerStat(1,'Team') = 1 then" -> "if GetPlayerStat(i,'Team') = 1 then"
But before that, it'd be better to check if the player is in-game... "if GetPlayerStat(i,'Active') = true) then if GetPlayerStat(i,'Team') = 1 then"
Note 2 things... if .. then if .. then; this is to prevent the check for the player's team if they are not in-game (more of a "just in case" type of thing); and "...Active') = true" the = true is needed sense it returns a variant, not boolean.

Glancing through it, I'm not seeing the error... one sec to get it on my server myself.

EDIT:
I copied the code and I'm not receiving the errors when I join the game ^^ You sure its not a different script?
« Last Edit: June 01, 2008, 08:09:23 pm by DorkeyDear »

Offline rayanaga

  • Soldier
  • **
  • Posts: 143
  • ~Fur flying~
    • Kryonex
Re: Wierd Error
« Reply #4 on: June 01, 2008, 08:19:06 pm »
Here, ill send you the full script.

See what you can do with it buddy. :D
[kY] Kryonex - Your local zombie fanatics.
http://www.kryonex.com/

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: Wierd Error
« Reply #5 on: July 31, 2008, 01:19:08 pm »
I might be wrong..
But you are using wrong colors.
KAWAAAAAAAIIIIIIIIII