Delete house command creates a loop that crashes server
#2

Код:
CMD:delhouse(playerid, params[])
{
	new string[128];
	new HouseID;

	if(pInfo[playerid][Admin] >= 4)
	{
		foreach(new h : Houses)
		{
			if(IsPlayerInRangeOfPoint(playerid, 3.5, hInfo[h][HouseX], hInfo[h][HouseY], hInfo[h][HouseZ]))
			{
			    format(string, sizeof(string), "-| House ID %d deleted. |-", h);
			    SendClientMessage(playerid, COLOR_RED, string);
			    hInfo[h][Owned] = false;
			    strmid(hInfo[HouseID][HouseName], "Deleted", 0, strlen("Deleted"), strlen("Deleted"));
		    	DestroyDynamicPickup(hInfo[h][DoorPickup]);
		    	HouseFileRemove(h);
				DestroyDynamic3DTextLabel(hInfo[h][DoorTextID]);
				hInfo[h][Buyable] = false;
				Iter_Remove(Houses, h);
				zInfo[GetPlayer2DZoneID(playerid)][HousesInZone]--;
				HouseCount--;
				break; // You'll need to stop the loop
			}
			else
			{
			    SendClientMessage(playerid, COLOR_RED, "ERROR: No house in range to delete.");
				break; // You'll need to stop the loop
			}
		}
	}
	else
	{
	    SendClientMessage(playerid, COLOR_RED, "ERROR: You are not a high enough level to use this command.");
	}
	return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)