Hallo Beadfish-Community,
ich bin derzeitig am versuchen das private Auto in MySQL zu speichern und auch zu laden...
Das Problem was ich derzeitig habe, der Spieler hat ein Auto aber es werden 4 Autos gespawnt obwohl
der Spieler nur ein Auto in der Datenbank hat...
//Habe es versucht das auch das CarKey sofort geladen wird...
forward LoadPrivatAuto(playerid);
public LoadPrivatAuto(playerid)
{
new query[128],spielerautoname[MAX_PLAYER_NAME];
GetPlayerName(playerid,spielerautoname,sizeof(spielerautoname));
format(query,sizeof(query),"SELECT * FROM autos WHERE Name='%s'",Dtc_PlayerKey[playerid], spielerautoname);
mysql_function_query(dbhandle,query,true,"OnPlayerCarLogin","i",playerid);
return 1;
}
Auto laden:
Function OnPlayerCarLogin(playerid)
{
for(new x = 0; x < MaxVeh; x++)
{
if(!Dtc_PlayerHaveCar[playerid][x])
{
Dtc_PlayerHaveCar[playerid][x] = 1;
new num_fields,num_rows;
cache_get_data(num_rows,num_fields,dbhandle);
if(!num_rows)return 1;
//for(new i=0; i<num_rows; i++)
if(num_rows == 1)
{
Dtc_PlayerKey[playerid] = cache_get_field_content_int(0,"CarKey",dbhandle);
PlayerCar[playerid][x][CarId] = cache_get_field_content_int(0,"CarId",dbhandle);
PlayerCar[playerid][x][CarModel] = cache_get_field_content_int(0,"CarModel",dbhandle);
PlayerCar[playerid][x][CarPos_x] = cache_get_field_content_float(0,"CarPos_x",dbhandle);
PlayerCar[playerid][x][CarPos_y] = cache_get_field_content_float(0,"CarPos_y",dbhandle);
PlayerCar[playerid][x][CarPos_z] = cache_get_field_content_float(0,"CarPos_z",dbhandle);
PlayerCar[playerid][x][CarRotate] = cache_get_field_content_float(0,"CarRotate",dbhandle);
PlayerCar[playerid][x][CarNitro] = cache_get_field_content_int(0,"CarNitro",dbhandle);
PlayerCar[playerid][x][CarHyd] = cache_get_field_content_int(0,"CarHyd",dbhandle);
PlayerCar[playerid][x][CarAusp] = cache_get_field_content_int(0,"CarAusp",dbhandle);
PlayerCar[playerid][x][CarSideL] = cache_get_field_content_int(0,"CarSideL",dbhandle);
PlayerCar[playerid][x][CarSideR] = cache_get_field_content_int(0,"CarSideR",dbhandle);
PlayerCar[playerid][x][CarFB] = cache_get_field_content_int(0,"CarFB",dbhandle);
PlayerCar[playerid][x][CarRB] = cache_get_field_content_int(0,"CarRB",dbhandle);
PlayerCar[playerid][x][CarSpoiler] = cache_get_field_content_int(0,"CarSpoiler",dbhandle);
PlayerCar[playerid][x][CarRoof] = cache_get_field_content_int(0,"CarRoof",dbhandle);
PlayerCar[playerid][x][CarHood] = cache_get_field_content_int(0,"CarHood",dbhandle);
PlayerCar[playerid][x][CarVents] = cache_get_field_content_int(0,"CarVents",dbhandle);
PlayerCar[playerid][x][CarLamps] = cache_get_field_content_int(0,"CarLamp",dbhandle);
PlayerCar[playerid][x][CarPJ] = cache_get_field_content_int(0,"CarPJ",dbhandle);
PlayerCar[playerid][x][CarC1] = cache_get_field_content_int(0,"CarC1",dbhandle);
PlayerCar[playerid][x][CarC2] = cache_get_field_content_int(0,"CarC2",dbhandle);
PlayerCar[playerid][x][CarArrest] = cache_get_field_content_int(0,"CarArrest",dbhandle);
PlayerCarSpawn(playerid,x);
}
}
}
return 1;
}
Auto Spawn:
Function PlayerCarSpawn(playerid,Slot)
{
if(IsPlayerConnected(playerid))
{
if(Dtc_PlayerHaveCar[playerid][Slot])
{
PlayerCar[playerid][Slot][CarId] = CreateVehicle(PlayerCar[playerid][Slot][CarModel],PlayerCar[playerid][Slot][CarPos_x],PlayerCar[playerid][Slot][CarPos_y],PlayerCar[playerid][Slot][CarPos_z],PlayerCar[playerid][Slot][CarRotate],PlayerCar[playerid][Slot][CarC1],PlayerCar[playerid][Slot][CarC2], 60000);/*vehicle spawn*/
ChangeVehicleColor(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarC1],PlayerCar[playerid][Slot][CarC2]);
if(PlayerCar[playerid][Slot][CarPJ] >= 0) {ChangeVehiclePaintjob(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarPJ]);}
if(PlayerCar[playerid][Slot][CarNitro] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarNitro]);}
if(PlayerCar[playerid][Slot][CarHyd] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarHyd]);}
if(PlayerCar[playerid][Slot][CarWheel] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarWheel]);}
if(PlayerCar[playerid][Slot][CarAusp] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarAusp]);}
if(PlayerCar[playerid][Slot][CarSideL] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarSideL]);}
if(PlayerCar[playerid][Slot][CarSideR] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarSideR]);}
if(PlayerCar[playerid][Slot][CarFB] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarFB]);}
if(PlayerCar[playerid][Slot][CarRB] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarRB]);}
if(PlayerCar[playerid][Slot][CarSpoiler] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarSpoiler]);}
if(PlayerCar[playerid][Slot][CarRoof] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarRoof]);}
if(PlayerCar[playerid][Slot][CarHood] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarHood]);}
if(PlayerCar[playerid][Slot][CarVents] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarVents]);}
if(PlayerCar[playerid][Slot][CarLamps] != 0) {AddVehicleComponent(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarLamps]);}
if(Dtc_LockOnSpawn)
{
Dtc_Carlock[PlayerCar[playerid][Slot][CarId]] = 1;
Dtc_LockCar(PlayerCar[playerid][Slot][CarId]);
SetVehicleToRespawn(PlayerCar[playerid][Slot][CarId]);
}
}
}
Auch in der Datenbank habe ich extra eine neue Spalte angelegt mit "CarKey" aber bei der Abfrage ging dann alles wieder schief...
Ich hoffe ihr könnt mir weiterhelfen, denn ich weiß nicht wo der Fehler liegt...
Vielen Dank im Vorraus!
Lg
J0a9