Some things not working right.
#1

Will rep anyone that helps.

Okay, This command only works for the players first house, It's meant to work for all houses.

Код:
CMD:furniture(playerid, params[])
{
    new string[128];
	for(new h = 0; h < MAX_OWNABLE_HOUSES+1;h++)
	{
		format(string, sizeof(string), "HouseKey_%d", h+1);
		if(GetPVarInt(playerid,"HouseKey_1") == 1000) return SendClientMessage(playerid, COLOR_LIGHTRED, "Error: You do not own a house!");
		if(IsPlayerInRangeOfPoint(playerid, 50.0,HouseInfo[GetPVarInt(playerid,string)][HouseIntPos][0],HouseInfo[GetPVarInt(playerid,string)][HouseIntPos][1],HouseInfo[GetPVarInt(playerid,string)][HouseIntPos][2]) && GetPlayerVirtualWorld(playerid) == HouseInfo[GetPVarInt(playerid,string)][Vw])
		{
		    HouseKeyForFurniture[playerid] = h;
		    SendClientMessage(playerid, COLOR_ORANGE, "Note: Go to your house interior and type /showhouseinfo to show the Object ID's and their position to remove from");
		    SendClientMessage(playerid, COLOR_ORANGE, "Note: You must be in a range of 3.0 meters of the object *May Course lag if its more*");
			ShowPlayerDialog(playerid, HouseFurniture, DIALOG_STYLE_LIST, "Furniture Menu", "Add Furniture\nRemove Furniture by ID\nRemove Closest Furniture\nRemove All Furniture", "Continue", "Cancel");
	 		return 1;
	  	}
	  	else return SendClientMessage(playerid, COLOR_LIGHTRED, "Error: You are not near any of your houses!");
	}
	return 1;
}
This code doesn't work at all, It doesn't show the textlabel but says the you don't own a house if you don't own one.
Код:
CMD:showhouseinfo(playerid, params[])
{
    new string[128];
    if(GetPVarInt(playerid,"HouseInfoDisplay") == 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "Error: You are already showing a houses information!");
	for(new h = 0; h < MAX_OWNABLE_HOUSES+1;h++)
	{
		format(string, sizeof(string), "HouseKey_%d", h+1);
		if(GetPVarInt(playerid,"HouseKey_1") == 1000) return SendClientMessage(playerid, COLOR_LIGHTRED, "Error: You do not own a house!");
		if(IsPlayerInRangeOfPoint(playerid, 50.0,HouseInfo[GetPVarInt(playerid,string)][HouseIntPos][0],HouseInfo[GetPVarInt(playerid,string)][HouseIntPos][1],HouseInfo[GetPVarInt(playerid,string)][HouseIntPos][2]) && GetPlayerVirtualWorld(playerid) == HouseInfo[h][Vw])
		{
		    for(new f = 0; f < MAX_FURNITURE;f++)
			{
				format(string, sizeof(string), "ObjectID%i", f);
				if(HouseInfo[GetPVarInt(playerid,string)][ObjectID][h] > 0)
				{
			    	new string1[256];
		        	format(string1, sizeof(string1), "Object ID: %d", f);
			    	Object3D[f] = CreateDynamic3DTextLabel(string, COLOR_ORANGE, HouseInfo[GetPVarInt(playerid,string)][ObjectPosX][f], HouseInfo[GetPVarInt(playerid,string)][ObjectPosY][f], HouseInfo[GetPVarInt(playerid,string)][ObjectPosZ][f]+0.75, 3.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, HouseInfo[GetPVarInt(playerid,string)][ObjectVW][f], HouseInfo[GetPVarInt(playerid,string)][ObjectInt][f], playerid, 100.0);
			    	return 1;
		 		}
			}
	  	}
	  	else return SendClientMessage(playerid, COLOR_LIGHTRED, "Error: You are not near any of your houses!");
	}
	return 1;
}
And now this Dialog won't work to remove objects.

Код:
case 2:
				{
				    for(new h = 0; h < MAX_FURNITURE;h++)
					{
					    new i = HouseKeyForFurniture[playerid];
					    if(IsPlayerInRangeOfPoint(playerid, 5.0,HouseInfo[i][ObjectPosX][h], HouseInfo[i][ObjectPosY][h], HouseInfo[i][ObjectPosZ][h]) && GetPlayerVirtualWorld(playerid) == HouseInfo[h][Vw])
					    {
					        new ModelFile[124];
			  				new key = HouseKeyForFurniture[playerid];
			    			new String[124];
				    		format(ModelFile,sizeof(ModelFile),"Houses/furnhouse%i.ini",key);
				    		format(String,sizeof(String),"ObjectID%i",listitem);
			    			HouseInfo[key][ObjectID][h] = 0;
							DOF2_SetInt(ModelFile,String,0);
							DestroyDynamicObject(HouseObject[key][h]);
							format(String,sizeof(String),"Furniture Object ID [%d] deleted.", h);
							SendClientMessage(playerid, 0x42F3F198, String);
							return 1;
					    }
					}
				}
Reply
#2

I don't know how many times I've said this already in how many different threads: never return inside a loop unless you purposely want to end it! You cannot possibly know if the player isn't in range of any house before you have checked them all.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
I don't know how many times I've said this already in how many different threads: never return inside a loop unless you purposely want to end it! You cannot possibly know if the player isn't in range of any house before you have checked them all.
Thanks they work, But it says unknown commands.
Reply
#4

Quick tip : for(new h = 0; h < MAX_OWNABLE_HOUSES+1;h++)
can be : for(new h = 0; h <= MAX_OWNABLE_HOUSES;h++)

"Unknown command" text occurs when a command has some error that the compiler doesn't detect or when a you return 0;
Add Crashtest plugin / include to see what happens.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)