24.09.2016, 05:31
I have a delete house command, that whenever I use it near a house, creates a loop of messages that crashes the server.
What's wrong with it?
Код:
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--;
}
else
{
SendClientMessage(playerid, COLOR_RED, "ERROR: No house in range to delete.");
}
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "ERROR: You are not a high enough level to use this command.");
}
return 1;
}


