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;
}
public ShowPlayerBikes(playerid)
{
new rows = cache_num_rows();
if(rows) // Checks to see if you have a bike before initiating for loop.
{
new string[512], tmpstr[128]; // Creates string to hold 1 line of dialog and another string to store whole dialog.
for (new i = 0; i < rows; i++) // Each time it loops it will create another line in your dialog.
{
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]);
strcat(string, tmpstr, sizeof(string)); // This adds the new line to your dialog.
}
ShowPlayerDialog(playerid, MyBikes, DIALOG_STYLE_LIST , "Your bikes" , string , "Ok" , "Close"); // After all the lines are made, dialog will open
}
else
SendClientMessage(playerid,-1,"According to our database, you don't own any bike!");
return 1;
}
cache_get_field_content_int(i, "ID"); CarInfo[i][cModel] = cache_get_field_content_int(i, "Model");
PHP код:
|
format(tmpstr,sizeof(tmpstr), "**Bike ID: %i - MODEL ID: %i\n", CarInfo[i][cID], CarInfo[i][cModel]);
strcat(string, tmpstr, sizeof(string)); // This adds the new line to your dialog.