All vehicle data loading except plate [DEBUG DONE] -
Lucases - 15.11.2017
Vehicle Plate isn't loading, it's weird, because the owner's name loads without problems.
PHP код:
forward LoadPlayerVehicles(playerid);
public LoadPlayerVehicles(playerid)
{
new query[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
format(query, sizeof(query), "SELECT * FROM vehicles WHERE Owner = '%s'", pname);
new DBResult:data = db_query(vehiclesdb, query), count;
if(db_num_rows(data) > 0)
{
for(new a; a<db_num_rows(data); a++)
{
new vehicleid = GetFreeVehicleSlot();
IsValidVehicle[vehicleid] = true;
VehicleInfo[vehicleid][vID] = db_get_field_assoc_int(data, "ID");
//printf("Vehicle ID: %i", VehicleInfo[vehicleid][vID]);
VehicleInfo[vehicleid][vModelid] = db_get_field_assoc_int(data, "Model");
//printf("Vehicle Model: %i", VehicleInfo[vehicleid][vModelid]);
VehicleInfo[vehicleid][vType] = VEHICLE_PLAYER;
//printf("Vehicle Type: %i", VehicleInfo[vehicleid][vType]);
db_get_field_assoc(data, "Owner", VehicleInfo[vehicleid][vOwner], MAX_PLAYER_NAME);
//printf("Vehicle Owner %s", VehicleInfo[vehicleid][vOwner]);
VehicleInfo[vehicleid][vPrice] = db_get_field_assoc_int(data, "Price");
//printf("Vehicle Price: %i", VehicleInfo[vehicleid][vPrice]);
VehicleInfo[vehicleid][vX] = db_get_field_assoc_float(data, "X");
//printf("Vehicle X: %f", VehicleInfo[vehicleid][vX]);
VehicleInfo[vehicleid][vY] = db_get_field_assoc_float(data, "Y");
//printf("Vehicle Y: %f", VehicleInfo[vehicleid][vY]);
VehicleInfo[vehicleid][vZ] = db_get_field_assoc_float(data, "Z");
//printf("Vehicle Z: %f", VehicleInfo[vehicleid][vZ]);
VehicleInfo[vehicleid][vA] = db_get_field_assoc_float(data, "A");
//printf("Vehicle A: %f", VehicleInfo[vehicleid][vA]);
VehicleInfo[vehicleid][vColor1] = db_get_field_assoc_int(data, "COLOR1");
//printf("Vehicle Primary Color: %i", VehicleInfo[vehicleid][vColor1]);
VehicleInfo[vehicleid][vColor2] = db_get_field_assoc_int(data, "COLOR2");
//printf("Vehicle Secondary Color: %i", VehicleInfo[vehicleid][vColor2]);
db_get_field_assoc(data, "Plate", VehicleInfo[vehicleid][vPlate], 9);
//printf("Plate Loaded: %s", VehicleInfo[vehicleid][vPlate]);
CreateVehicle(VehicleInfo[vehicleid][vModelid], VehicleInfo[vehicleid][vX],VehicleInfo[vehicleid][vY], VehicleInfo[vehicleid][vZ], VehicleInfo[vehicleid][vA], VehicleInfo[vehicleid][vColor1],VehicleInfo[vehicleid][vColor1], -1);
SetTimerEx("SetPlayerVehiclePlate", 200, false, "i", vehicleid);
count++;
db_next_row(data);
}
printf("%i vehicle(s) loaded for player %s", count, pname);
}
}
This is the server log
Everything loadfs fine except the plate "PLate Loaded: " is empty.
Re: All vehicle data loading except plate [DEBUG DONE, SQLITE] -
Zeth - 15.11.2017
You must re-spawn/re-stream the vehicle again to load the vehicle number plate.
PHP код:
SetTimerEx("SetPlayerVehiclePlate", 200, false, "i", vehicleid); //
//Respawn the vehicle in above function.
//Use SetVehicleToRespawn(vehicleid)
Wiki:
SetVehicleNumberPlate
Re: All vehicle data loading except plate [DEBUG DONE, SQLITE] -
Lucases - 15.11.2017
Thanks but I said the vehicle plate isn't loading, I already have the function to set vehicle plate in game.
PHP код:
forward SetPlayerVehiclePlate(vehicleid);
public SetPlayerVehiclePlate(vehicleid)
{
SetVehicleNumberPlate(vehicleid, VehicleInfo[vehicleid][vPlate]);
SetVehicleToRespawn(vehicleid);
}
I debugged everything and found the plate isn't loading from the database
Re: All vehicle data loading except plate [DEBUG DONE, SQLITE] -
Zeth - 15.11.2017
PHP код:
db_get_field_assoc(data, "Plate", VehicleInfo[vehicleid][vPlate], 9); //increase it to 32 characters
//and do the same in Database structure.
Re: All vehicle data loading except plate [DEBUG DONE, SQLITE] -
Lucases - 15.11.2017
I use randomized plate strings so I can't change that value.
When I buy the vehicle in game the first time the plate gets saved normally and I can see the randomized plate.
After I log out, the vehicle despawns as scripted by me, and respawns when I log in. The plate doesn't load from the database.