Load gang zones problem
#1

I have a weird bug when I'm creating and showing the gang zone.

my code:

turfs in database table are with ID:
1, 2, 3....last id: 28

Код:
#define MAX_GANG_ZONES (29)

public LoadZoness()
{

	for(new x = 0; x < cache_num_rows(); x++)
	{
		new id = cache_get_field_content_int(x, "ID");
		tvar[id][tID] = id;

	 	tvar[id][tOwner] = cache_get_field_content_int(x, "owned_by");

	 	tvars[id][tMinX] = cache_get_field_content_float(x, "min_x");
	 	tvar[id][tMinY] = cache_get_field_content_float(x, "min_y");
	 	tvar[id][tMaxX] = cache_get_field_content_float(x, "max_x");
	 	tvar[id][tMaxY] = cache_get_field_content_float(x, "max_y");

	 	tvar[id][tPosition] = GangZoneCreateEx(tvar[id][tMinX], tvar[id][tMinY], tvar[id][tMaxX], tvar[id][tMaxY], tvar[id][tID], 1.5);
	}

}

CMD:gangz(playerid)
{


for(new t = 1; t < MAX_GANG_ZONES; t++)
	{

		GangZoneShowForPlayerEx(playerid, tvar[t][tPosition], COLOR_WHITE);
	}
return 1;
}
When i'm use /gangz all turfs are WHITE, but the first turf (ID 1) is black, why?

Pictures: https://i.gyazo.com/7390a849ada93f12...bcaf6ca4f2.png
Reply
#2

Auto increment ID is not meant to be used as array index. It is just a database identifier! Use `x` as array index and start the loops from index 0.

You should also have a global variable to know upper bound of gang zones. If you load 28 gang zones, it is different to loop 28 times instead of 1024 times because of < MAX_GANG_ZONES.

If the problem is still not fixed, post functions `GangZoneCreateEx` and `GangZoneShowForPlayerEx`.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)