loop problem - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: loop problem (
/showthread.php?tid=238233)
loop problem -
Hornet600 - 11.03.2011
Im having problems with this code i made it myself but there is one problem the loop sends the message 10 times that is the max cars that a player can own and is buged -.- how i can make it send only one message for each vehicle get from the db? I really need help with it =|
pawn Код:
if(strcmp(x_v,"list",true) == 0)
{
new query[256];
for(new i; i < MAX_PLAYER_CARS; i ++)
{
format(query, sizeof(query)," SELECT * FROM vehicles WHERE Owner= '%s' LIMIT 1",playerinfo[playerid][Name]);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows())
if(mysql_fetch_row(query,"|"))
{
sscanf(query, "p<|>e<iiiifffs[25]iii>", vehicleinfo[i]);
format(string, sizeof(string),"Owner: %s || Car id : %d || Model id : %d", vehicleinfo[i][Owner], vehicleinfo[i][id],vehicleinfo[i][Model]);
SendClientMessage(playerid, COLOR_GREEN, string);
}
}
return 1;
}
Re: loop problem -
MadeMan - 11.03.2011
pawn Код:
if(strcmp(x_v,"list",true) == 0)
{
new query[256];
format(query, sizeof(query),"SELECT * FROM vehicles WHERE Owner='%s'",playerinfo[playerid][Name]);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows())
{
for(new i; i < MAX_PLAYER_CARS; i++)
{
if(mysql_fetch_row(query,"|"))
{
sscanf(query, "p<|>e<iiiifffs[25]iii>", vehicleinfo[i]);
format(string, sizeof(string),"Owner: %s || Car id : %d || Model id : %d", vehicleinfo[i][Owner], vehicleinfo[i][id],vehicleinfo[i][Model]);
SendClientMessage(playerid, COLOR_GREEN, string);
}
}
}
mysql_free_result();
return 1;
}