12 error's = error 032: array index out of bounds
#1

Код:
C:\Program Files\San Andreas Multiplayer server\gamemodes\wow.pwn(108) : error 032: array index out of bounds (variable "gTeamUSA")
C:\Program Files\San Andreas Multiplayer server\gamemodes\wow.pwn(115) : error 032: array index out of bounds (variable "gTeamUSA")
C:\Program Files\San Andreas Multiplayer server\gamemodes\wow.pwn(122) : error 032: array index out of bounds (variable "gTeamUSA")
C:\Program Files\San Andreas Multiplayer server\gamemodes\wow.pwn(129) : error 032: array index out of bounds (variable "gTeamEstonia")
C:\Program Files\San Andreas Multiplayer server\gamemodes\wow.pwn(136) : error 032: array index out of bounds (variable "gTeamEstonia")
C:\Program Files\San Andreas Multiplayer server\gamemodes\wow.pwn(143) : error 032: array index out of bounds (variable "gTeamEstonia")
C:\Program Files\San Andreas Multiplayer server\gamemodes\wow.pwn(150) : error 032: array index out of bounds (variable "gTeamGerman")
C:\Program Files\San Andreas Multiplayer server\gamemodes\wow.pwn(157) : error 032: array index out of bounds (variable "gTeamGerman")
C:\Program Files\San Andreas Multiplayer server\gamemodes\wow.pwn(164) : error 032: array index out of bounds (variable "gTeamGerman")
C:\Program Files\San Andreas Multiplayer server\gamemodes\wow.pwn(171) : error 032: array index out of bounds (variable "gTeamRussia")
C:\Program Files\San Andreas Multiplayer server\gamemodes\wow.pwn(178) : error 032: array index out of bounds (variable "gTeamRussia")
C:\Program Files\San Andreas Multiplayer server\gamemodes\wow.pwn(185) : error 032: array index out of bounds (variable "gTeamRussia")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


12 Errors.
ERROR IS ANY:
Код:
new rand = random(sizeof(gTeamUSA));
Код:
public OnPlayerSpawn(playerid)
{
  switch(gClass[playerid])
  {
    case 0:
    {
      // If the player's class is 0 then set it to Green
      SetPlayerColor(playerid, 0x009900ff); // Green
      new rand = random(sizeof(gTeamUSA));
      SetPlayerPos(playerid, gTeamUSA[rand][1],gTeamUSA[rand][2],gTeamUSA[rand][3]);
    }
    case 1:
    {
      // If the player's class is 1 then set it to Green
      SetPlayerColor(playerid, 0x009900ff); // Green
      new rand = random(sizeof(gTeamUSA));
      SetPlayerPos(playerid, gTeamUSA[rand][1],gTeamUSA[rand][2],gTeamUSA[rand][3]);
    }
    case 2:
    {
      // If the player's class is 2 then set it to Green
      SetPlayerColor(playerid, 0x009900ff); // Green
      new rand = random(sizeof(gTeamUSA));
      SetPlayerPos(playerid, gTeamUSA[rand][1],gTeamUSA[rand][2],gTeamUSA[rand][3]);
    }
    case 3:
    {
      // If the player's class is 3 then set it to Blue
      SetPlayerColor(playerid, 0x000099ff); // Blue
      new rand = random(sizeof(gTeamEstonia));
      SetPlayerPos(playerid, gTeamEstonia[rand][1],gTeamEstonia[rand][2],gTeamEstonia[rand][3]);
    }
    case 4:
    {
      // If the player's class is 4 then set it to Blue
      SetPlayerColor(playerid, 0x000099ff); // Blue
      new rand = random(sizeof(gTeamEstonia));
      SetPlayerPos(playerid, gTeamEstonia[rand][1],gTeamEstonia[rand][2],gTeamEstonia[rand][3]);
    }
    case 5:
    {
      // If the player's class is 5 then set it to Blue
      SetPlayerColor(playerid, 0x000099ff); // Blue
      new rand = random(sizeof(gTeamEstonia));
      SetPlayerPos(playerid, gTeamEstonia[rand][1],gTeamEstonia[rand][2],gTeamEstonia[rand][3]);
    }
    case 6:
    {
      // If the player's class is 6 then set it to Red
      SetPlayerColor(playerid, 0xcc0000ff); // Red
      new rand = random(sizeof(gTeamGerman));
      SetPlayerPos(playerid, gTeamGerman[rand][1],gTeamGerman[rand][2],gTeamGerman[rand][3]);
    }
    case 7:
    {
      // If the player's class is 7 then set it to Red
      SetPlayerColor(playerid, 0xcc0000ff); // Red
      new rand = random(sizeof(gTeamGerman));
      SetPlayerPos(playerid, gTeamGerman[rand][1],gTeamGerman[rand][2],gTeamGerman[rand][3]);
    }
		case 8:
    {
      // If the player's class is 8 then set it to Red
      SetPlayerColor(playerid, 0xcc0000ff); // Red
      new rand = random(sizeof(gTeamGerman));
      SetPlayerPos(playerid, gTeamGerman[rand][1],gTeamGerman[rand][2],gTeamGerman[rand][3]);
    }
    case 9:
    {
      // If the player's class is 9 then set it to White
      SetPlayerColor(playerid, 0xffffffff); // White
      new rand = random(sizeof(gTeamRussia));
      SetPlayerPos(playerid, gTeamRussia[rand][1],gTeamRussia[rand][2],gTeamRussia[rand][3]);
    }
    case 10:
    {
      // If the player's class is 9 then set it to White
      SetPlayerColor(playerid, 0xffffffff); // White
      new rand = random(sizeof(gTeamRussia));
      SetPlayerPos(playerid, gTeamRussia[rand][1],gTeamRussia[rand][2],gTeamRussia[rand][3]);
    }
    case 11:
    {
      // If the player's class is 9 then set it to White
      SetPlayerColor(playerid, 0xffffffff); // White
      new rand = random(sizeof(gTeamRussia));
      SetPlayerPos(playerid, gTeamRussia[rand][1],gTeamRussia[rand][2],gTeamRussia[rand][3]);
    }
  }
  SetPlayerInterior(playerid,0); // Interior 0
	return 1;
}
Reply
#2

And how do you have your arrays defined ?
Reply
#3

hmm the random dont working
Reply
#4

Код:
new Float:gTeamUSA[3][3] = {
{-1514.7295,2522.4514,55.8321},
{-1587.0784,2691.2866,55.5256},
{-1394.5430,2643.5271,55.8939}
};
new Float:gTeamEstonia[3][3] = {
{406.8107,2539.2747,16.5465},
{178.0585,1928.4592,18.0673},
{289.4476,1842.2612,17.6406}
};
new Float:gTeamGerman[3][3] = {
{-204.4719,1212.2919,19.7422},
{-251.7514,1052.8495,20.1162},
{80.8761,1165.1185,18.6565}
};
new Float:gTeamRussia[3][3] = {
{-550.3456,2593.8296,53.9348},
{-254.2574,2603.0325,62.8582},
{-157.2245,2757.0549,62.6646}
};
Reply
#5

pawn Код:
SetPlayerPos(playerid, gTeamUSA[rand][0],gTeamUSA[rand][1],gTeamUSA[rand][2]);
etc
Reply
#6

hmm array starts with 0 not 1
Reply
#7

Can you stop being such a fucking captain obvious ?
And no, you could have not posted the same time as me, it alerted you after you pressed the post button
Reply
#8

Hmm....?

[3][3]
(1)Y,(2)Z,(3)X
(1)Y,(2)Z,(3)X
(1)Y,(2)Z,(3)X

How should be 0?
Reply
#9

Array indexes start with zero
Reply
#10

Quote:
Originally Posted by Tundmatu
Hmm....?

[3][3]
(1)Y,(2)Z,(3)X
(1)Y,(2)Z,(3)X
(1)Y,(2)Z,(3)X

How should be 0?
pawn Код:
[0]X,[1]Y,[2]Z;
Does that helps ?

/Artix
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)