28.06.2020, 10:22
Hello.
I want to do a /v cmd that show's your vehicles that you own.
It shows the correct number like 2 vehicles but the problem is that i get someone else vehicle.
If in the database the car number 1 is mine then car number 2 is someone else car and my seccond car is the car with id 3, i will get first two cars 1 and 2 not 1 and 3.
Any ideas ?
EDIT: solved, i added.
But now i have the problem that if i sellect car 2 it give's me someone else car from db, is like i am selecting car database id not the menu car id.
I want to do a /v cmd that show's your vehicles that you own.
Code:
CMD:v(playerid)
{
new string[128], count;
mysql_format(handle, string, sizeof(string), "SELECT * FROM `cars` WHERE `Owner` = '%s' ORDER BY `ID` DESC", GetName(playerid));
new Cache:result = mysql_query(handle, string);
format(string, sizeof(string), "ID\tModel\n");
for(new i = 1; i <= cache_num_rows(); i++)
{
format(string, sizeof string, "%s%d\t%s\n", string, i, CarInfo[i][CarOwner]);
count++;
}
if(count == 0) return SCM(playerid, -1, "You don't own any cars.");
cache_delete(result);
ShowPlayerDialog(playerid, DIALOG_CARS, DIALOG_STYLE_TABLIST_HEADERS, "Cars:", string, "Select", "Quit");
return 1;
}
If in the database the car number 1 is mine then car number 2 is someone else car and my seccond car is the car with id 3, i will get first two cars 1 and 2 not 1 and 3.
Any ideas ?
EDIT: solved, i added.
Code:
cache_get_value_int(i, "ID", carid); format(string, sizeof(string), "%s%d\t%s\n", string, i, CarInfo[carid][CarOwner]);



. You would either have to create some PVars to store the carid to the right listitem, or run the SQL code again to run the same code as in /v. If no data was altered, the listitem would be the same as the row number.