25.08.2017, 02:50
I'm having a problem where the random number plate is saving to the database, but it will not load... can anyone help?
Under PlayerCar_Create I have this code...
This successfully saves a random numberplate to the database under the 'carPlate' field. I then load it like this...
Then, under Car_Spawn I have this code...
But when the car loads, the plate is still the default (XYZSR22
. Now, I can't see why this is not working... the plate saves to the database, so something must be wrong with how I'm loading it... anyone see why?
Under PlayerCar_Create I have this code...
PHP код:
new str[8];
format(str, sizeof(str), "%s%s%d%d%s%s%s", LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], random(9), random(9), LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]);
SetVehicleNumberPlate(i, str);
format(CarData[i][carPlate], 11, "%s", str);
PHP код:
forward PlayerCar_Load(playerid);
public PlayerCar_Load(playerid)
{
static
rows,
fields,
str[128];
cache_get_data(rows, fields, SQL_CONNECTION);
for (new i = 0; i < rows; i ++) if (i < MAX_DYNAMIC_CARS)
{
cache_get_field_content(i, "carPlate", CarData[i][carPlate], SQL_CONNECTION, 12);
Car_Spawn(i);
}
return 1;
}
PHP код:
SetVehicleNumberPlate(carid, CarData[carid][carPlate]);
