can't fix error 032: array index out of bounds -
aqu - 19.01.2012
Код:
enum wnt
{
WeaponNames[ 256 ]
}
new weaponnames[MAX_TEAMS][wnt]= {
{ "- Primary~n- Deagle(100)~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"}
};
// Somewhere in the script
playerclass[playerid]=1;
new string[256];
format(string,sizeof(string),"%s",weaponnames[playerclass[playerid]][wnt]);
TextDrawSetString(OPRQwnp[playerid],string);
TextDrawShowForPlayer(playerid,OPRQwnp[playerid]);
Код:
C:\Users\Tadas\Desktop\Gang Wars\gamemodes\SSSGW.pwn(809) : error 032: array index out of bounds (variable "weaponnames")
help ;(
Re: can't fix error 032: array index out of bounds -
Vince - 19.01.2012
How is MAX_TEAMS defined?
Re: can't fix error 032: array index out of bounds -
aqu - 19.01.2012
defined as 10
Re: can't fix error 032: array index out of bounds -
MP2 - 19.01.2012
It's tertiary, not thirdly.
Also, the array doesn't make sense. What exactly are you trying to do?
Re: can't fix error 032: array index out of bounds -
aqu - 19.01.2012
EDIT: deleted
Re: can't fix error 032: array index out of bounds -
aqu - 19.01.2012
I am going to make,that it will show weapons on player request class,that player will have if he spawn as that class.
Here's code:
Код:
// On the top
new playerclass[MAX_PLAYERS];
new Text:OPRQwnp[MAX_PLAYERS];
enum wnt
{
WeaponNames[ 256 ]
}
new weaponnames[MAX_TEAMS][wnt]= {
{ "- Primary~n- Deagle(100)~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"},
{ "- Primary~n- Secondary~n- Thirdly"}
};
// On Player connects
OPRQwnp[playerid] = TextDrawCreate(9.000000, 150.000000, "- Primary(100)");
TextDrawBackgroundColor(OPRQwnp[playerid], 255);
TextDrawFont(OPRQwnp[playerid], 1);
TextDrawLetterSize(OPRQwnp[playerid], 0.500000, 1.000000);
TextDrawColor(OPRQwnp[playerid], -1);
TextDrawSetOutline(OPRQwnp[playerid], 0);
TextDrawSetProportional(OPRQwnp[playerid], 1);
TextDrawSetShadow(OPRQwnp[playerid], 1);
// On player request class
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerClass( playerid, classid );
SetPlayerColor( playerid, COLOR_INACTIVE );
PlayerPlaySound( playerid, 1068, 0.0, 0.0, 0.0 );
switch(classid)
{
case 0:
{
playerclass[playerid]=1;
SetPlayerPos(playerid,2772.5334,-2382.5310,18.9217);
SetPlayerCameraPos(playerid,2776.8987,-2377.0911,18.9217);
SetPlayerCameraLookAt(playerid,2772.5334,-2382.5310,18.9217);
SetPlayerFacingAngle(playerid,294.2843);
ApplyAnimation(playerid,"LOWRIDER", "RAP_B_Loop",4.0,1,1,1,1,1);
}
}
new string[256];
format(string,sizeof(string),"%s",weaponnames[playerclass[playerid]][wnt]);
TextDrawSetString(OPRQwnp[playerid],string);
TextDrawShowForPlayer(playerid,OPRQwnp[playerid]);
return 1;
}
Re: can't fix error 032: array index out of bounds -
Tannz0rz - 19.01.2012
It'd be easier on everyone's behalf if you specified which line is line 809. The only thing that comes to mind is that playerclass[playerid] is either less than 0 or greater than 9.
EDIT: After further review I've come to notice this:
pawn Код:
weaponnames[playerclass[playerid]][wnt]
Change it to:
pawn Код:
weaponnames[playerclass[playerid]][WeaponNames]
Also, I suggest you remove "string" from the combination entirely. Just use
pawn Код:
TextDrawSetString(OPRQwnp[playerid], weaponnames[playerclass[playerid]][WeaponNames]);
Re: can't fix error 032: array index out of bounds -
aqu - 19.01.2012
oh,yeah,stupid mistake.Thank you all. +rep for all.