#1

I get :

Quote:

C:\Users\Callum Riley\Desktop\Pbrp\gamemodes\bbrp(77323) : warning 219: local variable "house" shadows a variable at a preceding level
C:\Users\Callum Riley\Desktop\Pbrpgamemodes\bbrp(77323) : error 017: undefined symbol "i"

For:

Код:
		new house = i;
Full:

Код:
CMD:asellallhouses(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 4)
	{
		new playername[MAX_PLAYER_NAME];
		GetPlayerName(playerid, playername, sizeof(playername));

		new string[128];
		for (new house = 0; house != MAX_HOUSES; house++)
		{
		new house = i;
		HouseInfo[house][hLock] = 1;
		new ip[32];
		GetPlayerIp(playerid,ip,sizeof(ip));
		format(string,sizeof(string),"Administrator %s (IP: %s) has admin-sold house ID %d (was owned by %s).",GetPlayerNameEx(playerid),ip,house,HouseInfo[house][hOwner]);
		Log("logs/house.log", string);
		ClearHouse(house);
		format( HouseInfo[house][hOwner], 128, "Nobody" );
		HouseInfo[house][hGLUpgrade] = 1;
		PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
		format(string, sizeof(string), "~w~You have sold house %d.", house);
		GameTextForPlayer(playerid, string, 10000, 3);
		SaveHouses();
		DestroyDynamicPickup(HouseInfo[house][hPickupID]);
		HouseInfo[house][hPickupID] = CreateDynamicPickup(1273, 23, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]);
		DestroyDynamic3DTextLabel(HouseInfo[house][hTextID]);
		format(string, sizeof(string), "This home is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\n/buyhouse to buy it.",HouseInfo[house][hDescription],HouseInfo[house][hValue],HouseInfo[house][hLevel]);
		HouseInfo[house][hTextID] = CreateDynamic3DTextLabel( string, COLOR_GREEN, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]+0.5,30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1,  -1, 30.0);
		return 1;
		}
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use that command!");
	}
	return 1;
}
Reply
#2

You've created the 'house' variable in your for-loop and not an 'i' variable like you thought:

PHP код:
for (new house 0house != MAX_HOUSEShouse++) 
And since 'new house = i;' is in the body of your for-loop, it will pop that error.

Out of curiosity, what is this even for?:
PHP код:
new house i
Reply
#3

Or just keep it simple and do this if you want to use " i " as the loop variable:

Quote:

new house;
for (new i= 0; i != MAX_HOUSES; i++)
house = i;

That's more like it.


Reason: I removed the " new house = i " from the loop body because it would cause the variable " house " to be declared again and again until the loop ends. So peace.

As you see, there are many ways for solving a problem. Choose the one, which suits to your mind.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)