Hi, Please look here
#1

I'm scripting turf taxes system and got a problem, Whenever I include use of Gangzones[id][gFACTION] (e.g. using its value), It causes UNKNOWN Command and returns 0, anyone knows why?
Код:
	new housesGz[500];
		new bizesGz[200];
		new moneyGz[100];
		for(new gz=0; gz < sizeof(Gangzones); gz++)
		{
			housesGz[gz] = 0;
			bizesGz[gz] = 0;
			moneyGz[gz] = 10000;
			for(new hid=0; hid < sizeof(House); hid++)
			{
			    if(IsCoordsInArea(House[hid][House_x], House[hid][House_y], Gangzones[gz][maxX], Gangzones[gz][minX], Gangzones[gz][maxY], Gangzones[gz][minY	]))
			    {
			        housesGz[gz]++;
			    }
			}
			for(new bid=0; bid < sizeof(biz); bid++)
			{
			    if(IsCoordsInArea(biz[bid][bizenter_x], biz[bid][bizenter_y], Gangzones[gz][maxX], Gangzones[gz][minX], Gangzones[gz][maxY], Gangzones[gz][minY]))
			    {
			        bizesGz[gz]++;
			    }
			}
   			SendClientMessage(playerid, COLOR_RED, "Pass till 1");
            if(Gangzones[gz][gFACTION] != 255 || Gangzones[gz][gFACTION] != -1 || Gangzones[gz][gFACTION] != 0)
            {
                moneyGz[gz] = housesGz[gz] + bizesGz[gz] * 12500;
                new fcabankx[128], fcabank;
                format(fcabankx,sizeof(fcabankx),"%sBank",GetFactionName(Gangzones[gz][gFACTION]));
                SendClientMessage(playerid, COLOR_RED, "Pass till 2");
				fcabank = dini_Int(globalstats,fcabankx);
				dini_IntSet(globalstats, fcabankx, fcabank + moneyGz[gz]);
				SendClientMessage(playerid, COLOR_RED, "Pass till 3");
				printf("[DEBUG] Faction %s turf money set!",GetFactionName(Gangzones[gz][gFACTION]));
            }
		}
I tried to debug, It can only show the message pass till 1, I tried before the formaat too and it passed but after format it dont, This is my getfactionname:

Код:
stock GetFactionName ( factionid )
{
	return teams[ GetTeam(factionid) ][teamname];
}
teams[id][teamname] value is MAX_STRING (12
and gFACTION of the enumerator _Gangzones is assigned as integer.
Reply
#2

Hi!

I'm not sure but try:
PHP код:
return teamsGetTeam(factionid) ][teamname]; 
to
PHP код:
return teamsfactionid ][teamname]; 
Reply
#3

tried right now, still unknown command
Reply
#4

bump and i rewritten the whole system!
new code:
Код:
stock GetHousesInTurf(ixa)
{
	new hs=0;
	for(new h = 0; h < sizeof(House);h++)
	{
 		if(IsCoordsInArea(House[h][House_x], House[h][House_y], Gangzones[ixa][maxX], Gangzones[ixa][minX], Gangzones[ixa][maxY], Gangzones[ixa][minY]))
 		{
			hs++;
		}
	}
	return hs;
}
stock GetBizsInTurf(ixab)
{
	new bz=0;
	for(new b = 0; b < sizeof(biz);b++)
	{
 		if(IsCoordsInArea(biz[b][bizexit_x], biz[b][bizexit_y], Gangzones[ixab][maxX], Gangzones[ixab][minX], Gangzones[ixab][maxY], Gangzones[ixab][minY]))
 		{
			bz++;
		}
	}
	return bz;
}
stock TurfDay()
{
    for(new i=0;i<sizeof(Gangzones);i++)
	{
	    Gangzones[i][gEARN] = 0;
		new houses = GetHousesInTurf(i);
		new bizes = GetBizsInTurf(i);
		Gangzones[i][gEARN] = houses + bizes * 12500;
		if(Gangzones[i][gFACTION] != 255 || Gangzones[i][gFACTION] != -1 || Gangzones[i][gFACTION] != 0)
		{
		    teams[Gangzones[i][gFACTION]][teamturf]++;
			teams[Gangzones[i][gFACTION]][teamearn] += Gangzones[i][gEARN];
			teams[Gangzones[i][gFACTION]][teamearn] += 10000;
		}
	}
	for(new f=0;f<16;f++)
	{
	    if(f != 0 || f != 255 || f != -1 || f != 7 || f != 8 || f != 9 || f != 10 || f != 11 || f != 13)
	    {
	        new tmpfieldx[ 64 ];
		    format(tmpfieldx, 64, "%sBank", teams[f][teamname]);
	    	new balancecur = dini_Int(globalstats, tmpfieldx);
			dini_IntSet(globalstats, tmpfieldx, balancecur+teams[f][teamearn]);
			format(iStr, sizeof(iStr), "# [%s] Faction earned +$%s into F-BANK from %d Turfs", teams[f][teamname], number_format(teams[f][teamearn]), teams[f][teamturf]);
			SendClientMessageToTeam(f, iStr, COLOR_PLAYER_VLIGHTBLUE);
	    }
	    teams[f][teamturf] = 0;
	    teams[f][teamearn] = 0;
	}
	return 1;
}
still unknown command, i'll try debugging later
Reply
#5

Use crashdetect and post log.
Reply
#6

stop abusing of stocks already, leave "stock" from everything in your script ex: stock GetName > GetName
Reply
#7

Quote:
Originally Posted by introzen
Посмотреть сообщение
Use crashdetect and post log.
Here
https://www.solidfiles.com/v/q2LwraVmPrA5L

Quote:
Originally Posted by sheNdjze
Посмотреть сообщение
stop abusing of stocks already, leave "stock" from everything in your script ex: stock GetName > GetName
Nothing related with my problem so fuck off,
and stop #shitpost 'ing
Reply
#8

mighty righty bump
Reply
#9

Quote:
Originally Posted by MafiaOink
Посмотреть сообщение
mighty righty bump
1. How about you read the rules, no bumping within 24 hours.
2. How about you read this sticky, https://sampforum.blast.hk/showthread.php?tid=574725, it talks about bad titles.
Reply
#10

Sorry and I debugged some things
teams[Gangzones[i][gFACTION]][teamturf]++;
Error on this
[Gangzones[i][gFACTION] array index out of bounds

lol i didnt need anyones help anymore
crashdetect is love
lol fixed it myself
I just had to add if(Gangzones[i][gFACTION] > 1) because!
I dont have faction 0 and -1 and 255 added in the teams list thats why and unowned turfs have -1 faction so thats why
tags:-
making turf system
array index out of bounds enumerator
crayder
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)