Error-008
#1

Hi,
I have a problem with this it gets me this error:
Код:
error 008: must be a constant expression; assumed zero
on the line
Код:
GetRegionCheck(Float:posx[iidd],Float:posy[iidd],Float:posz[iidd])
and i dont know how to fix this
Please help me...
Код:
new iidd;
new Float:posx[MAX_PLAYERS];
new Float:posy[MAX_PLAYERS];
new Float:posz[MAX_PLAYERS];

GetRegionCheck(Float:posx[iidd],Float:posy[iidd],Float:posz[iidd])
{
	new zone[256];
	for (new r=0; r < MAX_REGIONS; r++)
	{
		if(posx[iidd]>=gRegionCoords[r][0] && posx[iidd]<=gRegionCoords[r][3] && posy[iidd]>=gRegionCoords[r][1] && posy[iidd]<=gRegionCoords[r][4] && posz[iidd]>=gRegionCoords[r][2] && posz[iidd] < gRegionCoords[r][5])
		{
			format(zone, sizeof(zone), "%s", gRegionNames[r]);
			break;
		}
	}
	return zone;
}
Reply
#2

Delete
Reply
#3

An array is basiclly a table with data stored in each cell (new a[24] = 24 cells = 24 stored numbers). You cannot compare the whole array with one number. Try this code:

pawn Код:
GetRegionCheck(Float:posx,Float:posy,Float:posz)
{
    new zone[256];
    for (new r=0; r < MAX_REGIONS; r++)
    {
        if(posx>=gRegionCoords[r][0] && posx<=gRegionCoords[r][3] && posy>=gRegionCoords[r][1] && posy<=gRegionCoords[r][4] && posz>=gRegionCoords[r][2] && posz < gRegionCoords[r][5])
        {
            format(zone, sizeof(zone), "%s", gRegionNames[r]);
            break;
        }
    }
    return zone;
}
Also, you do not need to declare variables which you define as function parameters
Reply
#4

Quote:
Originally Posted by dice7
An array is basiclly a table with data stored in each cell (new a[24] = 24 cells = 24 stored numbers). You cannot compare the whole array with one number. Try this code:

pawn Код:
GetRegionCheck(Float:posx,Float:posy,Float:posz)
{
    new zone[256];
    for (new r=0; r < MAX_REGIONS; r++)
    {
        if(posx>=gRegionCoords[r][0] && posx<=gRegionCoords[r][3] && posy>=gRegionCoords[r][1] && posy<=gRegionCoords[r][4] && posz>=gRegionCoords[r][2] && posz < gRegionCoords[r][5])
        {
            format(zone, sizeof(zone), "%s", gRegionNames[r]);
            break;
        }
    }
    return zone;
}
Also, you do not need to declare variables which you define as function parameters
that was original GetRegionCheck, but I needed to edit this to be there "zone" per every player because then I use this:
pawn Код:
new Text:txt;
new Text:txt2;

ONGAMEMODEINIT:
txt2 = TextDrawCreate(445.0, 411.5, "lol");
txt = TextDrawCreate(430.0, 400.0, "lol");

ONPLAYERCONNECT:
SetTimerEx("location",1000,1,"i",playerid);

public location(id)
{
new string[300];
new string2[300];
format(string,300,"Your location is:");
TextDrawSetString(txt,string);
TextDrawSetShadow(txt, 0);
TextDrawAlignment(txt, 4);
TextDrawColor(txt, COLOR_YELLOW);
TextDrawShowForPlayer(id, txt);
format(string2,300,"%s",GetRegionCheck(pos));
TextDrawSetString(txt2,string2);
TextDrawSetShadow(txt2, 0);
TextDrawAlignment(txt2, 4);
TextDrawColor(txt2, COLOR_RED);
TextDrawShowForPlayer(id, txt2);
}
And if there are 2 or more players the location writing is flipping per each player...For example, if there is player number 1 and player number 2, and player 1 is in downtown and player 2 in doherty, then for both players it shows txt2 like Downtown,Doherty,Downtown,Doherty .... so its merging or something...
Reply
#5

Anybody help?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)