09.05.2020, 12:18
Code:
LoadAvailableBounties(playerid) { new DB_Query[256]; mysql_format(Database, DB_Query, sizeof(DB_Query), "SELECT * FROM `player_bounties`"); mysql_tquery(Database, DB_Query, "LoadBounties", "i", playerid); printf("%s", DB_Query); // the query is printed correctly } forward LoadBounties(playerid); public LoadBounties(playerid) { if(cache_num_rows()>0) // the error line is here and fairly enough, only the first entry is shown in the dialog { new target, hitprice; for(new i; i<cache_num_rows(); i++) { cache_get_value_int(i, "hitid", target); cache_get_value_int(i, "amount", hitprice); // some more code not mysql related } } return 1; } CMD:bounties(playerid, params[]) { LoadAvailableBounties(playerid); return 1; }
PHP Code:
LoadAvailableBounties(playerid)
{
new DB_Query[450];
mysql_format(Database, DB_Query, sizeof(DB_Query), "SELECT * FROM `player_bounties`");
mysql_tquery(Database, DB_Query, "LoadBounties", "i", playerid);
printf("%s", DB_Query);
}
function LoadBounties(playerid)
{
new Rows;
cache_get_row_count(Rows);
if(!Rows)
return true;
new target, hitprice;
for(new i; i<Rows; i++)
{
cache_get_value_int(i, "hitid", target);
cache_get_value_int(i, "amount", hitprice);
// some more code not mysql related
}
return 1;
}
PHP Code:
LoadAvailableBounties(playerid)
{
new DB_Query[256];
mysql_format(Database, DB_Query, sizeof(DB_Query), "SELECT * FROM `player_bounties` WHERE `ID` = %d", PlayerInfo[playerid][SQLID]); // replace playerinfo with your player variables and `ID` to the id column in your table. Hope you understood.
mysql_tquery(Database, DB_Query, "LoadBounties", "i", playerid);
printf("%s", DB_Query); // the query is printed correctly
}