Error loop run out of limit -
meocahat - 11.07.2015
I made the code:
Код:
CMD:deleteallhouseex(playerid, params[])
{
for(new i = 0; i < 5001; i++)
{
HouseInfo[i][hLevel] = 0;
HouseInfo[i][hCustomInterior] = 0;
HouseInfo[i][hDescription] = 0;
format(HouseInfo[i][hOwnerName],MAX_PLAYER_NAME, "Nobody");
HouseInfo[i][hExteriorX] = 0;
HouseInfo[i][hExteriorY] = 0;
HouseInfo[i][hExteriorZ] = 0;
HouseInfo[i][hExteriorR] = 0;
HouseInfo[i][hExteriorA] = 0;
HouseInfo[i][hLock] = 0;
HouseInfo[i][hRentable] = 0;
HouseInfo[i][hRentFee] = 0;
HouseInfo[i][hValue] = 0;
ClearHouse(i);
DestroyDynamicPickup(HouseInfo[i][hPickupID]);
DestroyDynamic3DTextLabel(HouseInfo[i][hTextID]);
HouseInfo[i][hCustomExterior] = 0;
SaveHouses();
}
SendClientMessage(playerid, COLOR_YELLOW, "All house deleted.");
return 1;
}
When i run this command, the houses isn't delete. Then, the Console print this Message:
Код:
Saving House ID 0
Saving House ID 1
...
Saving House ID 4999
Saving House ID 0
Saving House ID 1
...
So, what was wrong with that loop ? How to fix ?
Re: Error loop run out of limit -
Prokill911 - 11.07.2015
Okay so lets take a look..
Firstly, You're saying..
i = 0..
While i < 5001
Count++,
You're then getting House Info[i]
i = 0..
You're basically telling it to destroy ID's that don't exist..
So It's looking through all "HouseInfo[i]"
an If It doesn't find a house that matches [i]..
It will stop an skip to the end...
You should define the maximum number of houses when a player logs in...
So when your server starts up..
It should count each house an assign an ID.
then you call the house ID its self..
So try this...
PHP код:
for(new i = 0; i < HouseInfo; i++) {
That's just guess code..
because I have no way of knowing how your enum / array structure is setup.
Re: Error loop run out of limit -
DarkLouis - 11.07.2015
No. The correct code's this.
PHP код:
for(new i = 0; i < sizeof(HouseInfo); i++)
Tested and worked.
Re : Error loop run out of limit -
KillerDVX - 11.07.2015
[I]This should works :
PHP код:
CMD:deleteallhouseex(playerid, params[])
{
for(new i = 0; i < sizeof(HouseInfo); i++)
{
HouseInfo[i][hLevel] = 0;
HouseInfo[i][hCustomInterior] = 0;
HouseInfo[i][hDescription] = 0;
format(HouseInfo[i][hOwnerName],MAX_PLAYER_NAME, "Nobody");
HouseInfo[i][hExteriorX] = 0;
HouseInfo[i][hExteriorY] = 0;
HouseInfo[i][hExteriorZ] = 0;
HouseInfo[i][hExteriorR] = 0;
HouseInfo[i][hExteriorA] = 0;
HouseInfo[i][hLock] = 0;
HouseInfo[i][hRentable] = 0;
HouseInfo[i][hRentFee] = 0;
HouseInfo[i][hValue] = 0;
ClearHouse(i);
DestroyDynamicPickup(HouseInfo[i][hPickupID]);
DestroyDynamic3DTextLabel(HouseInfo[i][hTextID]);
HouseInfo[i][hCustomExterior] = 0;
SaveHouses();
}
SendClientMessage(playerid, COLOR_YELLOW, "All house deleted.");
return 1;
}[/i]
KillerDVX,
Re: Error loop run out of limit -
meocahat - 11.07.2015
Thank you guys so much
Re: Error loop run out of limit -
liquor - 11.07.2015
But... If SaveHouses(); also is a loop through all houses, this code is very bad for server performance... Put SaveHouses(); outside the loop...