Hallo Breadfish
ich habe ein großes Problem
wenn ich ein fahrzeug kaufe wird es nicht gespeichert und auch nicht erstellt
ich bitte um hilfe
Code: OnPlayerBuyCar
public OnPlayerBuyCar(playerid,Model,Preis,Autohaus)//CARSYS
{
if(IsPlayerConnected(playerid) && !Dtc_PlayerHaveCar[playerid][Dtc_PlayerKey[playerid]])
{
CallRemoteFunction("M_GivePlayerMoney","id",playerid,-Preis);
Gas[Model] = GetGasMax(GetVehicleModel(Model));
SetParkPlatz(playerid,Autohaus);
new name[MAX_PLAYER_NAME], str[512], x = Dtc_PlayerKey[playerid];
GetPlayerName(playerid, name, sizeof name);
mysql_format(handle, str, sizeof(str), "INSERT INTO `Privatcar` (`CarOwner`,`CarId`,`CarModel`,`CarPos_X`,`CarPos_Y`,`CarPos_Z`,`CarPos_A`,`Preis`,`Plate`) VALUES ('%s_%d','%d','%d','%f','%f','%f','%f','%d','N/A');",
name, x, x, Model, PlayerCar[playerid][x][CarPos_x], PlayerCar[playerid][x][CarPos_y], PlayerCar[playerid][x][CarPos_z],PlayerCar[playerid][x][CarRotate],Preis);
mysql_pquery(handle, str);
OnPlayerCarLogin(playerid);
printf("OnPlayerBuyCar (%s_%d)",name,x);
}
return 1;
}
Alles anzeigen
Code: OnPlayerCarLogin
public OnPlayerCarLogin(playerid)
{
for(new x = 0; x < MaxVeh; x++)
{
if(!Dtc_PlayerHaveCar[playerid][x])
{
new string2[256],string3[256];
new playername2[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
format(string3, sizeof(string3), "/Privatcars/%s%d.dtcar", playername2,x);
new File: UserFile = fopen(string3, io_read);
if (UserFile)
{
Dtc_PlayerHaveCar[playerid][x] = 1;
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( UserFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey( Data );
if( strcmp( key , "CarId" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarId] = strval( val ); }
if( strcmp( key , "CarModel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarModel] = strval( val ); }
if( strcmp( key , "CarPos_x" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPos_x] = floatstr( val ); }
if( strcmp( key , "CarPos_y" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPos_y] = floatstr( val ); }
if( strcmp( key , "CarPos_z" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPos_z] = floatstr( val ); }
if( strcmp( key , "CarRotate" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarRotate] = floatstr( val ); }
if( strcmp( key , "CarNitro" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarNitro] = strval( val ); }
if( strcmp( key , "CarHyd" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarHyd] = strval( val ); }
if( strcmp( key , "CarWheel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarWheel] = strval( val ); }
if( strcmp( key , "CarAusp" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarAusp] = strval( val ); }
if( strcmp( key , "CarSideL" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarSideL] = strval( val ); }
if( strcmp( key , "CarSideR" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarSideR] = strval( val ); }
if( strcmp( key , "CarFB" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarFB] = strval( val ); }
if( strcmp( key , "CarRB" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarRB] = strval( val ); }
if( strcmp( key , "CarSpoiler" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarSpoiler] = strval( val ); }
if( strcmp( key , "CarRoof" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarRoof] = strval( val ); }
if( strcmp( key , "CarHood" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarHood] = strval( val ); }
if( strcmp( key , "CarVents" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarVents] = strval( val ); }
if( strcmp( key , "CarLamps" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarLamps] = strval( val ); }
if( strcmp( key , "CarPJ" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPJ] = strval( val ); }
if( strcmp( key , "CarC1" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarC1] = strval( val ); }
if( strcmp( key , "CarC2" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarC2] = strval( val ); }
if( strcmp( key , "Preis" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarPreis] = strval( val ); }
if( strcmp( key , "Neon" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][Neon] = strval( val ); }
if( strcmp( key , "Plate" , true ) == 0 ) { val = ini_GetValue( Data ); format(PlayerCar[playerid][x][CarPlate], 32, "%s", val); }
if( strcmp( key , "Number" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarNumber] = strval( val ); }
if( strcmp( key , "Gesperrt" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarGesperrt] = strval( val ); }
if( strcmp( key , "Sperrpreis" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][CarSperrpreis] = strval( val ); }
if( strcmp( key , "Kralle", true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][Abgeschleppt] = strval( val ); }
}
fclose(UserFile);
mysql_format(handle, string2, sizeof(string2), "INSERT INTO `Privatcar` (`CarOwner`) VALUES ('%s_%d')",playername2,x);
mysql_pquery(handle, string2);
format(string2, sizeof(string2), "UPDATE `Privatcar` SET `CarModel`='%d',`CarPos_X`='%f',`CarPos_Y`='%f',`CarPos_Z`='%f',`CarPos_A`='%f',`CarNitro`='%d',`CarHyd`='%d',`CarWheel`='%d',`CarAusp`='%d' WHERE `CarOwner`='%s_%d'",
PlayerCar[playerid][x][CarModel], PlayerCar[playerid][x][CarPos_x], PlayerCar[playerid][x][CarPos_y], PlayerCar[playerid][x][CarPos_z],
PlayerCar[playerid][x][CarRotate], PlayerCar[playerid][x][CarNitro],PlayerCar[playerid][x][CarHyd], PlayerCar[playerid][x][CarWheel], PlayerCar[playerid][x][CarAusp], playername2, x);
mysql_pquery(handle, string2);
format(string2, sizeof(string2), "UPDATE `Privatcar` SET `CarSideL`='%d',`CarSideR`='%d',`CarFB`='%d',`CarFB`='%d',`CarRB`='%d',`CarSpoiler`='%d',`CarRoof`='%d',`CarHood`='%d',`CarVents`='%d',`CarLamps`='%d' WHERE `CarOwner`='%s_%d'",
PlayerCar[playerid][x][CarSideL], PlayerCar[playerid][x][CarSideR], PlayerCar[playerid][x][CarFB], PlayerCar[playerid][x][CarRB],
PlayerCar[playerid][x][CarSpoiler], PlayerCar[playerid][x][CarRoof],
PlayerCar[playerid][x][CarHood], PlayerCar[playerid][x][CarVents], PlayerCar[playerid][x][CarLamps], playername2, x);
mysql_pquery(handle, string2);
format(string2, sizeof(string2), "UPDATE `Privatcar` SET `CarPJ`='%d',`CarC1`='%d',`CarC2`='%d',`Preis`='%d',`Neon`='%d',`Plate`='%d',`Number`='%s',`Gesperrt`='%d',`Sperrpreis`='%d',`Kralle`='%d' WHERE `CarOwner`='%s_%d'",
PlayerCar[playerid][x][CarPJ], PlayerCar[playerid][x][CarC1], PlayerCar[playerid][x][CarC2], PlayerCar[playerid][x][CarPreis],
PlayerCar[playerid][x][Neon], PlayerCar[playerid][x][CarPlate],
PlayerCar[playerid][x][CarNumber], PlayerCar[playerid][x][CarGesperrt], PlayerCar[playerid][x][CarSperrpreis], PlayerCar[playerid][x][Kralle], playername2, x);
mysql_pquery(handle, string2);
fremove(string3);
PlayerCarSpawn(playerid,x);
}
else
{
mysql_format(handle, string2, sizeof(string2), "SELECT * FROM Privatcar WHERE `CarOwner` = '%s_%d'", playername2, x);
mysql_pquery(handle, string2, "LoadMysqlCars", "sii", playername2,x,playerid);
}
}
}
}
Alles anzeigen
mfg Paddy87