For loop "Crash"? - 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: For loop "Crash"? (
/showthread.php?tid=357949)
For loop "Crash"? -
vIBIENNYx - 08.07.2012
Basically, when creating the for loop to load the businesses it loads the first record and then stops completely.
Here is the code:
pawn Код:
stock loadbusiness()
{
new Query[500];
format(Query, sizeof(Query), "SELECT * FROM `businessinfo`");
mysql_query(Query);
mysql_store_result();
for(new i = 1; i != mysql_num_rows(); i++)
{
if(i <= mysql_num_rows())
{
LoadBusinessInfo(i);
format(Query, sizeof(Query), "SELECT * FROM `businessinfo` WHERE `bid` = %d", i);
businesspickup[i] = CreatePickup(1272, 1, BVar[businessid[i]][bpickupx], BVar[businessid[i]][bpickupy], BVar[businessid[i]][bpickupz], 0);
print(Query);
currbusiness++;
}
}
print("Buinesses Loaded");
return 1;
}
Any help would be appreciated.
Re: For loop "Crash"? -
Kirollos - 09.07.2012
try
replace
pawn Код:
for(new i = 1; i != mysql_num_rows(); i++)
to
pawn Код:
for(new i = 1; i < mysql_num_rows(); i++)
Re: For loop "Crash"? -
vIBIENNYx - 09.07.2012
pawn Код:
stock loadbusiness()
{
new Query[500];
format(Query, sizeof(Query), "SELECT * FROM `businessinfo`");
mysql_query(Query);
mysql_store_result();
for(new i = 1; i < mysql_num_rows(); i++)
{
if(i <= mysql_num_rows())
{
format(Query, sizeof(Query), "SELECT * FROM `businessinfo` WHERE `bid` = %d", i);
print(Query);
LoadBusinessInfo(i);
businesspickup[i] = CreatePickup(1272, 1, BVar[businessid[i]][bpickupx], BVar[businessid[i]][bpickupy], BVar[businessid[i]][bpickupz], 0);
currbusiness++;
}
}
print("Buinesses Loaded");
}
This is the script now, however it doesn't actually loop, it just does it once and then doesn't create the pickup like it used to.
This is the console log: