How is this wrong?
#1

Код:
	for(new t=0; t<=164; t++)
	{
	    TurfInfo[t][tOwner] = cache_get_field_content_int(t, "owner");

		new gangzone[64];
		
		format(gangzone, sizeof(gangzone), "gangzone%d", t);

		if(TurfInfo[t][tOwner] == 0) { GangZoneShowForAll(gangzone, COLOR_GROVET); }
		if(TurfInfo[t][tOwner] == 1) { GangZoneShowForAll(gangzone, COLOR_BALLAST); }
		if(TurfInfo[t][tOwner] == 2) { GangZoneShowForAll(gangzone, COLOR_VAGOST); }
		if(TurfInfo[t][tOwner] == 3) { GangZoneShowForAll(gangzone, COLOR_AZTECAST); }
		if(TurfInfo[t][tOwner] == 4) { GangZoneShowForAll(gangzone, COLOR_RIFAT); }
		if(TurfInfo[t][tOwner] == 5) { GangZoneShowForAll(gangzone, COLOR_TRIADST); }
		if(TurfInfo[t][tOwner] == 6) { GangZoneShowForAll(gangzone, COLOR_DANANGT); }
		if(TurfInfo[t][tOwner] == 7) { GangZoneShowForAll(gangzone, COLOR_ITALIANT); }
		if(TurfInfo[t][tOwner] == 8) { GangZoneShowForAll(gangzone, COLOR_RUSSIANT); }
		if(TurfInfo[t][tOwner] == 10) { GangZoneShowForAll(gangzone, COLOR_UNOCCUPIEDTURF); }
	}
This gives the error: "argument type mismatch (argument 1)" for the lines using GangZoneShowForAll
Someone please help me. Thanks
Reply
#2

Gangzones aren't strings, they are integers. See:
https://sampwiki.blast.hk/wiki/GangZoneCreate
https://sampwiki.blast.hk/wiki/GangZoneShowForAll

Simply use the ID returned by GangZoneCreate, no need to format as a string(not that you even can).
Reply
#3

How would I do this? I really don't know. Just deleting de format and replace "gangzone" with t-1 ? (my gangzones start from 1 to 164 so i guess they return 0-163 ?? )

Yep this worked.
Reply
#4

Quote:
Originally Posted by hydravink
Посмотреть сообщение
How would I do this? I really don't know. Just deleting de format and replace "gangzone" with t-1 ? (my gangzones start from 1 to 164 so i guess they return 0-163 ?? )
First, you have not created the zone
PHP код:
GangZoneCreate(Float:minxFloat:minyFloat:maxxFloat:maxy); 
Secondly you do not have an array of 164, as the new gangzone[64]; // Less than 64 < 164
Note: If you have a true 164 different zones.
Reply
#5

No, you need to supply what GangZoneCreate returns. If you have alot of gangzones you can do something such as:
pawn Код:
new GangZones[30];

public OnFilterScriptInit()
{
      GangZones[0] = GangZoneCreate(....)
      GangZones[1] = GangZoneCreate(....)
     
      for(new i; i < sizeof GangZones; i++)
      {
            if(GangZones[i])
            {
                  #if defined IsValidGangZone
                  if(IsValidGangZone(i))
                  {
                         GangZoneShowForAll(GangZones[i], COLOR_GROVET);
                  }
                  #else
                  GangZoneShowForAll(GangZones[i], COLOR_GROVET);
                  #endif
              }
       }

       return 1;
}
Reply
#6

What I did fixed it. I was formatting them because I have them like this:
gangzone1 = Create...

So I needed gangzone+t(the number)...
But gangzone1 returns id 0.. so its t-1.

But what you did is better, I will try. Thanks


EDIT: wow, new problem, now mysql doesn't read the value...

Код:
	
for(new t=1; t<=164; t++)
{
	mysql_format(mysql, query, sizeof(query), "SELECT `owner` FROM `turfs` WHERE `turfid` = %d", t);
	mysql_tquery(mysql, query, "", "");
		
	 TurfInfo[t][tOwner] = cache_get_field_content_int(0, "owner");
	 printf("%d", TurfInfo[t][tOwner]);
}
In the console always prints 0 when it should print 10.... What is wrong?
I am 100% sure it isn't anything wrong in the table and MYSQL connects sucessfully...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)