22.06.2015, 21:00
Quote:
I have created a SQL database for vehicles, it's A-okay yet nothing wrong with it.
Vehicles in the database have a unique ID specified in the DB and when it's spawned it gets another ID from the server(vehicleid). Here's an image from the DB, for the sake of deep explanation. And as I said, in the server when it's spawned it gets another ID(vehicleid). Now what I want is creating a simple command letting me know the vehicleid by writing on the ID on the database. Here's what I've done:- On Vehicle Spawn: Код:
CarData[carid][carVehicle] = CreateVehicle(CarData[carid][carModel], CarData[carid][carPos][0], CarData[carid][carPos][1], CarData[carid][carPos][2], CarData[carid][carPos][3], CarData[carid][carColor1], CarData[carid][carColor2], (CarData[carid][carOwner] != 0) ? (-1) : (1200000)); // The spawning line. "CarData[carid][carVehicle]" outputs server's vehicleid. CarData[carid][carSrvID] = CarData[carid][carVehicle]; // Storing server's vehicleid in another column on the database. This works well and stores the ID but what I wrote in the command is the following: Код:
CMD:getservervehid(playerid, params[]) { new enteredID; new string[64]; new gottenid; if (sscanf(params, "d", enteredID)) return SendSyntaxMessage(playerid, "/getservervehid [ID]"); format(string, sizeof(string), "SELECT * FROM `cars` WHERE `carID` = '%d'", enteredID); //Will select the car with the DB ID. mysql_tquery(g_iHandle, string); gottenid = cache_get_field_int(gottenid, "carSrvID"); SendServerMessage(playerid, "IDgotten > %d.", gottenid); return 1; } Thanks. |
How are you getting the field when you haven't even defined rows & fields..
Try
PHP код:
new rows,fields, id_string, gottenid;
cache_get_data(rows,fields);
if(rows >= 1) {
cache_get_row(0, 0, id_string);
gottenid = strval(id_string);
} else {
printf("0 Rows Found");
}
So Due to you're selecting a designated ID...
The ROW ID = 0
the Colum (IF ITS YOUR PRIMARY KEY) = 0
Then you store it..
then you assign strval when retrive