Vehicle Plate is saving but not loading... - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vehicle Plate is saving but not loading... (
/showthread.php?tid=639909)
Vehicle Plate is saving but not loading... -
adamslj - 25.08.2017
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...
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);
This successfully saves a random numberplate to the database under the 'carPlate' field. I then load it like this...
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;
}
Then, under Car_Spawn I have this code...
PHP код:
SetVehicleNumberPlate(carid, CarData[carid][carPlate]);
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?
Re: Vehicle Plate is saving but not loading... -
Kane - 25.08.2017
Do you respawn the car after setting the plate?
https://sampwiki.blast.hk/wiki/SetVehicleToRespawn
Re: Vehicle Plate is saving but not loading... -
adamslj - 25.08.2017
Good call, thank you!