Problem with for() - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with for() (
/showthread.php?tid=595450)
Problem with for() -
Japanda - 03.12.2015
Hi.
i have a problem with for()
see my code:
Код:
for(new house = 0; house < 1100; house++)
{
HouseInfo[house][hHel] = 0;
SaveVal(HouseInfo[house][hOwner], "pPhousekey", 9999);
SaveValH(house, "hHel", 0);
HouseInfo[house][hLock] = 1;
SaveValH(house, "hLock", 1);
HouseInfo[house][hOwned] = 0;
SaveValH(house, "hOwned", 0);
strmid(HouseInfo[house][hOwner], "The State", 0, strlen("The State"), 255);
SaveStrH(house, "hOwner", "The State");
new playername[128];
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "House %d is for sell, You can use /findhouse %d to find it.",house,house);
SendClientMessageToAll(-1,string);
}
i have 1099 house in my server.
after run this code server just sold house id 0.
sorry for my bad english.
can anybody helps me?
Re: Problem with for() -
Japanda - 03.12.2015
Can anyone help me?
Re: Problem with for() -
CmZxC - 03.12.2015
What are you trying to do? Sell all houses in the server?
Re: Problem with for() -
Japanda - 03.12.2015
@CmZxC , Yes i want to sell all houses!
Re: Problem with for() -
CmZxC - 03.12.2015
Your code is very weird. The last part with playername is completely useless, and you're sending 1,100 message to everyone in the server.
Here's a cleaned up version, try this.
PHP код:
for(new house; house < 1100; house++)
{
HouseInfo[house][hHel] = 0;
SaveVal(HouseInfo[house][hOwner], "pPhousekey", 9999);
SaveValH(house, "hHel", 0);
HouseInfo[house][hLock] = 1;
SaveValH(house, "hLock", 1);
HouseInfo[house][hOwned] = 0;
SaveValH(house, "hOwned", 0);
strmid(HouseInfo[house][hOwner], "The State", 0, strlen("The State"), 255);
SaveStrH(house, "hOwner", "The State");
if(house == 1099) SendClientMessageToAll(-1, "All the houses have been sold");
}
Re: Problem with for() -
Lenon - 03.12.2015
Код:
for(new house; house <= 1100; house++)
Re: Problem with for() -
SilverStand - 04.12.2015
Код:
for(new house = 0; house <= 1100; house++)
{
HouseInfo[house][hHel] = 0;
SaveVal(HouseInfo[house][hOwner], "pPhousekey", 9999);
SaveValH(house, "hHel", 0);
HouseInfo[house][hLock] = 1;
SaveValH(house, "hLock", 1);
HouseInfo[house][hOwned] = 0;
SaveValH(house, "hOwned", 0);
strmid(HouseInfo[house][hOwner], "The State", 0, strlen("The State"), 255);
SaveStrH(house, "hOwner", "The State");
new playername[128];
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "House %d is for sell, You can use /findhouse %d to find it.",house,house);
SendClientMessageToAll(-1,string);
}