10.09.2016, 03:13
Hi
I made this simple code to show player own vehicles (Reading data from MySQL database) but the thing is, it only displays the first result from the query, instead of displaying me all the vehicles that belong to the player.
For example, In my database I have 2 bikes owned by "Tester" but the command only shows up the dialog with the data of the first bike that was registered on the database with the owner described above.
Any help will be apreciated
I made this simple code to show player own vehicles (Reading data from MySQL database) but the thing is, it only displays the first result from the query, instead of displaying me all the vehicles that belong to the player.
For example, In my database I have 2 bikes owned by "Tester" but the command only shows up the dialog with the data of the first bike that was registered on the database with the owner described above.
Any help will be apreciated
PHP код:
CMD:mybikes(playerid,params[])
{
if(IsSpawned[playerid] == 0) return SendClientMessage(playerid,-1,"You must be spawned");
new query[150];
mysql_format(mysql, query, sizeof(query),"SELECT * FROM `cars` WHERE `Owner` = '%e'", GetName(playerid));
mysql_tquery(mysql, query, "ShowPlayerBikes", "i", playerid);
printf("%s",query);
return 1;
}
public ShowPlayerBikes(playerid)
{
print("ShowPlayerBikes is getting called!");
SendClientMessage(playerid,-1,"DEBUG** ShowPlayerBikes callback is getting called properly" );
new rows = cache_num_rows();
for (new i = 0; i < rows; i++)
{
if(rows) // check if there are rows or not
{
new string[180];
CarInfo[i][cID] = cache_get_field_content_int(0, "ID");
CarInfo[i][cModel] = cache_get_field_content_int(0, "Model");
format(string,sizeof(string), "**Bike ID: %i - MODEL ID: %i\n",CarInfo[i][cID], CarInfo[i][cModel]);
ShowPlayerDialog(playerid, MyBikes, DIALOG_STYLE_LIST , "Your bikes" , string , "Ok" , "Close");
printf("Number of rows for Username %s: %i",GetName(playerid), rows);
}
else
{
SendClientMessage(playerid,-1,"According to our database, you don't own any bike!");
}
}
return 1;
}