SA-MP Forums Archive
Help with errors - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with errors (/showthread.php?tid=566353)



Help with errors - semaj - 05.03.2015

Can someone help me out with this please?
pawn Код:
D:\GTA SA\new rp\samp03z_svr_R1_win32\gamemodes\New.pwn(13298) : error 032: array index out of bounds (variable "gSAZones")
D:\GTA SA\new rp\samp03z_svr_R1_win32\gamemodes\New.pwn(13302) : error 032: array index out of bounds (variable "gSAZones")
pawn Код:
stock GetPlayer3DZone(playerid)
{
    new zone[32] = "San Andreas";
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    for(new i = 0; i < sizeof(gSAZones); i++)
    {
13298-->        if(x >= gSAZones[i][SAZONE_MAIN][0] && x <= gSAZones[i][SAZONE_MAIN][3]
        && y >= gSAZones[i][SAZONE_MAIN][1] && y <= gSAZones[i][SAZONE_MAIN][4]
        && z >= gSAZones[i][SAZONE_MAIN][2] && z <= gSAZones[i][SAZONE_MAIN][5])
        {
13302-->            strmid(zone, gSAZones[i][SAZONE_MAIN], 0, 28);
            return zone;
        }
    }
    return zone;
}



AW: Help with errors - Kaliber - 05.03.2015

Pls show us how you declared gSAZones


Re: Help with errors - semaj - 05.03.2015

pawn Код:
static const gSAZones[][SAZONE_MAIN] =
what else do you mean?


Re: Help with errors - semaj - 05.03.2015

pawn Код:
enum MainZone
{
    Zone_Name[28],
    Float:Zone_Area[6]
}



AW: Re: Help with errors - Kaliber - 05.03.2015

Well, i ******d it, i found the enum & the decleration xD

Write it like this:

Код:
stock GetPlayer3DZone(playerid)
{
	new zone[32] = "San Andreas";
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
 	for(new i = 0; i < sizeof(gSAZones); i++)
	{
                if(x >= gSAZones[i][SAZONE_AREA][0] && x <= gSAZones[i][SAZONE_AREA][3]
		&& y >= gSAZones[i][SAZONE_AREA][1] && y <= gSAZones[i][SAZONE_AREA][4]
		&& z >= gSAZones[i][SAZONE_AREA][2] && z <= gSAZones[i][SAZONE_AREA][5])
		{
		        strmid(zone, gSAZones[i][SAZONE_NAME], 0, 28);
			return zone;
		}
	}
	return zone;
}
Greekz


Re: Help with errors - semaj - 05.03.2015

Thanks Kaliber that fixed it