MSQL Speichert als "Null"
- RedDragon28080
- Geschlossen
- Erledigt
Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!
Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
-
-
Nicht diese Zeile.
Die erste ALTER TABLE Zeile, sprich die zweite Zeile im Code. -
die ganzen zeilen soll ich löschen???
C
Alles anzeigenmysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarModel` varchar(64) NOT NULL DEFAULT ''"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarPos_x` float NOT NULL DEFAULT '0.0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarPos_y` float NOT NULL DEFAULT '0.0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarPos_z` float NOT NULL DEFAULT '0.0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarRotate` float NOT NULL DEFAULT '0.0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarNitro` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarHyd` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarWheel` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarAusp` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarSideL` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarSideR` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarFB` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarRB` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarSpoiler` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarRoof` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarHood` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarVents` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarLamps` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarPJ` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarC1` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarC2` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `Preis` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `Neon` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `Plate` varchar(64) NOT NULL DEFAULT ''"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `Number` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `Gesperrt` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `Sperrpreis` int(11) NOT NULL DEFAULT '0'"); mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `Abgeschleppt` int(11) NOT NULL DEFAULT '0'");
-
Nein...
Das ist die erste Zeile von den ALTER TABLEs:
mysql_pquery(handle, "ALTER TABLE `Privatcar` ADD `CarOwner` varchar(64) NOT NULL DEFAULT ''");
Die sollst du entfernen. Nur die.Weil du schon "CarOwner" in der CREATE TABLE Zeile stehen hast, sonst hast du es doppelt.
-
oky
habe ich gelöscht
aber habe noch eine frage und zwar muss ich das "CarId" in "CarModel" oder soll ich das stehen lassen wie es ist weil nicht im phpmyadmin nicht erstellt -
Du hast die Bezeichnung der Spalte dort verändert.
Mache es so, das geht auf jeden Fall und ist auch besser, da nur ein Query gesendet wird:
new query[1500];
format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `Privatcar` (`ID` int(11) PRIMARY KEY,");
format(query, sizeof(query), "%s`CarOwner` varchar(64) NOT NULL DEFAULT '',",query);
format(query, sizeof(query), "%s`CarId` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarModel` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarPos_x` float NOT NULL DEFAULT '0.0',",query);
format(query, sizeof(query), "%s`CarPos_y` float NOT NULL DEFAULT '0.0',",query);
format(query, sizeof(query), "%s`CarPos_z` float NOT NULL DEFAULT '0.0',",query);
format(query, sizeof(query), "%s`CarRotate` float NOT NULL DEFAULT '0.0',",query);
format(query, sizeof(query), "%s`CarNitro` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarHyd` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarWheel` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarAusp` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarSideL` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarSideR` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarFB` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarRB` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarSpoiler` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarRoof` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarHood` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarVents` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarLamps` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarPJ` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarC1` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarC2` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`Preis` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`Neon` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`Plate` varchar(64) NOT NULL DEFAULT '',",query);
format(query, sizeof(query), "%s`Number` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`Gesperrt` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`Sperrpreis` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`Abgeschleppt` int(11) NOT NULL DEFAULT '0'",query);
format(query, sizeof(query), "%s) ENGINE=MyISAM DEFAULT CHARSET=latin1;",query);
mysql_pquery(handle, query); -
jetzt wieder der gleiche Fehler es steht in der datenbank überall 0
sehe bild
was nunhier ist der Msql_log
C
Alles anzeigen[18:39:06] [DEBUG] mysql_pquery - connection: 1, query: "CREATE TABLE IF NOT EXISTS `Privatcar` (`ID` int(11) PRIMARY KEY", callback: "(null)", format: "(null)" [18:39:06] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [18:39:08] [DEBUG] mysql_format - connection: 1, len: 256, format: "SELECT * FROM Privatcar WHERE `CarOwner` = '%s_%d'" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "SELECT * FROM Privatcar WHERE `CarOwner` = 'Hans_0'", callback: "LoadMysqlCars", format: "sii" [18:39:08] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'HandyVer' [18:39:08] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'HandyGeld' [18:39:08] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError [18:39:08] [DEBUG] CMySQLQuery::Execute[] - starting query execution [18:39:08] [DEBUG] mysql_format - connection: 1, len: 256, format: "SELECT * FROM Privatcar WHERE `CarOwner` = '%s_%d'" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "SELECT * FROM Privatcar WHERE `CarOwner` = 'Hans_1'", callback: "LoadMysqlCars", format: "sii" [18:39:08] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'Pos_y' [18:39:08] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError [18:39:08] [DEBUG] CMySQLQuery::Execute[] - starting query execution [18:39:08] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'Pos_x' [18:39:08] [DEBUG] mysql_format - connection: 1, len: 256, format: "SELECT * FROM `bans` WHERE `Name` = '%e' OR `IP`='%e'" [18:39:08] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'CarL[18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "SELECT * FROM `bans` WHERE `Name` = 'Hans' OR `IP`='127.0.0.1'", callback: "OnMysqlCheck", format: "d" [18:39:08] [DEBUG] CMySQLQuery::Execute[] - starting query execution [18:39:08] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError [18:39:08] [DEBUG] CMySQLQuery::Execute[] - starting query execution [18:39:08] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'FlyLic' [18:39:08] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError [18:39:08] [DEBUG] CMySQLQuery::Execute[] - starting query execution [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarModel` varchar(64) NOT NULL DEFA", callback: "(null)", format: "(null)" [18:39:08] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'Pos_z' [18:39:08] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarId` int(11) NOT NULL DEFAULT '0'", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] CMySQLQuery::Execute[] - starting query execution [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarPos_x` float NOT NULL DEFAULT '0", callback: "(null)", format: "(null)" [18:39:08] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'FishLic' [18:39:08] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'NewLic' [18:39:08] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError [18:39:08] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError `CarPos_y` float NOT NULL DEFAULT '0", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarPos_z` float NOT NULL DEFAULT '0", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] CMySQLQuery::Execute[] - starting query execution [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarRotate` float NOT NULL DEFAULT '", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarNitro` int(11) NOT NULL DEFAULT ", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarHyd` int(11) NOT NULL DEFAULT '0", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarWheel` int(11) NOT NULL DEFAULT ", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarAusp` int(11) NOT NULL DEFAULT '", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarSideL` int(11) NOT NULL DEFAULT ", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarSideR` int(11) NOT NULL DEFAULT ", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarFB` int(11) NOT NULL DEFAULT '0'", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarRB` int(11) NOT NULL DEFAULT '0'", callback: "(null)", format: "(null)" [18:39:08] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'LKWLic' [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarSpoiler` int(11) NOT NULL DEFAUL", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarRoof` int(11) NOT NULL DEFAULT '", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] CMySQLQuery::Execute[] - starting query execution [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarHood` int(11) NOT NULL DEFAULT '", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarVents` int(11) NOT NULL DEFAULT ", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarLamps` int(11) NOT NULL DEFAULT ", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarPJ` int(11) NOT NULL DEFAULT '0'", callback: "(null)", format: "(null)" [18:39:08] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'Taxischein' [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarC1` int(11) NOT NULL DEFAULT '0'", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `CarC2` int(11) NOT NULL DEFAULT '0'", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `Preis` int(11) NOT NULL DEFAULT '0'", callback: "(null)", format: "(null)" [18:39:08] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'GunLic' [18:39:08] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `Neon` int(11) NOT NULL DEFAULT '0'", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError [18:39:08] [DEBUG] CMySQLQuery::Execute[] - starting query execution [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `Plate` varchar(64) NOT NULL DEFAULT", callback: "(null)", format: "(null)" [18:39:08] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'Kekse' [18:39:08] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError [18:39:08] [DEBUG] CMySQLQuery::Execute[] - starting query execution [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `Number` int(11) NOT NULL DEFAULT '0", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `Gesperrt` int(11) NOT NULL DEFAULT ", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `Sperrpreis` int(11) NOT NULL DEFAUL", callback: "(null)", format: "(null)" [18:39:08] [DEBUG] mysql_pquery - connection: 1, query: "ALTER TABLE `Privatcar` ADD `Abgeschleppt` int(11) NOT NULL DEFA", callback: "(null)", format: "(null)"
-
Poste bitte den Code, mit dem du ein Fahrzeug kaufst, den aktuellen Code.
Und entferne die ganzen ALTER TABLE Zeilen, die brauchst du durch obigen Code ja nicht mehr. -
C: Hier gehört alles dazu
Alles anzeigenpublic 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[1500], x = Dtc_PlayerKey[playerid]; GetPlayerName(playerid, name, sizeof name); mysql_format(handle, str, sizeof(str), "INSERT INTO `Privatcar` (`CarOwner`) VALUES ('%s_%d');", name, x); mysql_pquery(handle, str); format(str, sizeof(str), "UPDATE `Privatcar` SET `CarModel`='%d', `CarPos_X`='%f', `CarPos_Y`='%f', `CarPos_Z`='%f', `CarPos_A`='%f', `CarNitro`='0', `CarHyd`='0', `CarWheel`='0', `CarAusp`='0'", Model, PlayerCar[playerid][x][CarPos_x], PlayerCar[playerid][x][CarPos_y], PlayerCar[playerid][x][CarPos_z],PlayerCar[playerid][x][CarRotate]); format(str, sizeof(str), "%s, `CarSideL`='0', `CarSideR`='0', `CarFB`='0', `CarRB`='0', `CarSpoiler`='0', `CarRoof`='0', `CarHood`='0', `CarVents`='0', `CarLamps`='0'",str); format(str, sizeof(str), "%s, `CarPJ`='0', `CarC1`='0', `CarC2`='0', `Preis`='%d', `Neon`='0' , `Plate`='0', `Number`='GBN-0', `Gesperrt`='0', `Sperrpreis`='0', `Kralle`='0' WHERE `CarOwner` = '%s_%d'", str, Preis, name, x); mysql_pquery(handle, str); OnPlayerCarLogin(playerid); printf("OnPlayerBuyCar (%s_%d)",name,x); } return 1; } public OnPlayerCarLogin(playerid) { for(new x = 0; x < MaxVeh; x++) { if(!Dtc_PlayerHaveCar[playerid][x]) { print("PlayerCarSpawn/1"); new string2[256]; new 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); print("PlayerCarSpawn/1-2"); if (UserFile) { Dtc_PlayerHaveCar[playerid][x] = 1; new key[ 256 ] , val[ 256 ]; new Data[ 256 ]; print("PlayerCarSpawn/1-3"); while ( fread( UserFile , Data , sizeof( Data ) ) ) { key = ini_GetKey( Data ); print("PlayerCarSpawn/1-4"); 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 ); PlayerCar[playerid][x][CarPlate] = strval( val ); } if( strcmp( key , "Number" , true ) == 0 ) { val = ini_GetValue( Data ); format(PlayerCar[playerid][x][CarNumber], 32, "%s", 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 , "Abgeschleppt", true ) == 0 ) { val = ini_GetValue( Data ); PlayerCar[playerid][x][Abgeschleppt] = strval( val ); } } print("PlayerCarSpawn/1-5"); fclose(UserFile); print("PlayerCarSpawn/1-6"); fremove(string3); print("PlayerCarSpawn/2"); 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); print("PlayerCarSpawn/3"); 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); print("PlayerCarSpawn/4"); } } } } forward LoadMysqlCars(playername,x,playerid); public LoadMysqlCars(playername,x,playerid) { new rows,fields,v[128]; cache_get_data(rows,fields); if(rows) { print("LoadMysqlCars/1"); Dtc_PlayerHaveCar[playerid][x] = 1; cache_get_field_content(0,"CarModel",v); PlayerCar[playerid][x][CarModel] = strval(v); cache_get_field_content(0,"CarPos_X",v); PlayerCar[playerid][x][CarPos_x] = floatstr(v); cache_get_field_content(0,"CarPos_Y",v); PlayerCar[playerid][x][CarPos_y] = floatstr(v); cache_get_field_content(0,"CarPos_Z",v); PlayerCar[playerid][x][CarPos_z] = floatstr(v); cache_get_field_content(0,"CarPos_A",v); PlayerCar[playerid][x][CarRotate] = floatstr(v); cache_get_field_content(0,"CarNitro",v); PlayerCar[playerid][x][CarNitro] = strval(v); cache_get_field_content(0,"CarHyd",v); PlayerCar[playerid][x][CarHyd] = strval(v); cache_get_field_content(0,"CarWheel",v); PlayerCar[playerid][x][CarWheel] = strval(v); cache_get_field_content(0,"CarAusp",v); PlayerCar[playerid][x][CarAusp] = strval(v); cache_get_field_content(0,"CarSideL",v); PlayerCar[playerid][x][CarSideL] = strval(v); cache_get_field_content(0,"CarSideR",v); PlayerCar[playerid][x][CarSideR] = strval(v); cache_get_field_content(0,"CarFB",v); PlayerCar[playerid][x][CarFB] = strval(v); cache_get_field_content(0,"CarRB",v); PlayerCar[playerid][x][CarRB] = strval(v); cache_get_field_content(0,"CarSpoiler",v); PlayerCar[playerid][x][CarSpoiler] = strval(v); cache_get_field_content(0,"CarRoof",v); PlayerCar[playerid][x][CarRoof] = strval(v); cache_get_field_content(0,"CarHood",v); PlayerCar[playerid][x][CarHood] = strval(v); cache_get_field_content(0,"CarVents",v); PlayerCar[playerid][x][CarVents] = strval(v); cache_get_field_content(0,"CarLamps",v); PlayerCar[playerid][x][CarLamps] = strval(v); cache_get_field_content(0,"CarPJ",v); PlayerCar[playerid][x][CarPJ] = strval(v); cache_get_field_content(0,"CarC1",v); PlayerCar[playerid][x][CarC1] = strval(v); cache_get_field_content(0,"CarC2",v); PlayerCar[playerid][x][CarC2] = strval(v); cache_get_field_content(0,"Preis",v); PlayerCar[playerid][x][CarPreis] = strval(v); cache_get_field_content(0,"Neon",v); PlayerCar[playerid][x][Neon] = strval(v); cache_get_field_content(0,"Plate",v); PlayerCar[playerid][x][CarPlate] = strval(v); cache_get_field_content(0,"Number",v); format(PlayerCar[playerid][x][CarNumber], 32, "%s", v); cache_get_field_content(0,"Gesperrt",v); PlayerCar[playerid][x][CarGesperrt] = strval(v); cache_get_field_content(0,"Sperrpreis",v); PlayerCar[playerid][x][CarSperrpreis] = strval(v); cache_get_field_content(0,"Kralle",v); PlayerCar[playerid][x][Kralle] = strval(v); print("LoadMysqlCars/2"); PlayerCarSpawn(playerid,x); } } public 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); 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(PlayerCar[playerid][Slot][CarPlate] != 0) {SetVehicleNumberPlate(PlayerCar[playerid][Slot][CarId],PlayerCar[playerid][Slot][CarNumber]);} SetVehicleToRespawn(Slot); print("PlayerCarSpawn 1"); new strings[15]; format(strings, sizeof(strings), "%s",PlayerCar[playerid][Slot][CarNumber]); SetVehicleNumberPlate(PlayerCar[playerid][Slot][CarId], strings); if(Dtc_LockOnSpawn) { Dtc_Carlock[PlayerCar[playerid][Slot][CarId]] = 1; Dtc_LockCar(PlayerCar[playerid][Slot][CarId]); } if(PlayerCar[playerid][Slot][Neon] == 1) { new Float:x,Float:y,Float:z; Neonrohr[playerid][Neon] = CreateObject(18648,x,y,z,0,0,0,283); Neonrohr[playerid][Neon1] = CreateObject(18648,x,y,z,0,0,0,283); AttachObjectToVehicle(Neonrohr[playerid][Neon], PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], 0.8,0,-0.70,0,0,0); AttachObjectToVehicle(Neonrohr[playerid][Neon1], PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], -0.8,0,-0.70,0,0,0); } if(PlayerCar[playerid][Slot][Neon] == 2) { new Float:x,Float:y,Float:z; Neonrohr[playerid][Neon] = CreateObject(18647,x,y,z,0,0,0,283); Neonrohr[playerid][Neon1] = CreateObject(18647,x,y,z,0,0,0,283); AttachObjectToVehicle(Neonrohr[playerid][Neon], PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], 0.8,0,-0.70,0,0,0); AttachObjectToVehicle(Neonrohr[playerid][Neon1], PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], -0.8,0,-0.70,0,0,0); } if(PlayerCar[playerid][Slot][Neon] == 3) { new Float:x,Float:y,Float:z; Neonrohr[playerid][Neon] = CreateObject(18649,x,y,z,0,0,0,283); Neonrohr[playerid][Neon1] = CreateObject(18649,x,y,z,0,0,0,283); AttachObjectToVehicle(Neonrohr[playerid][Neon], PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], 0.8,0,-0.70,0,0,0); AttachObjectToVehicle(Neonrohr[playerid][Neon1], PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], -0.8,0,-0.70,0,0,0); } if(PlayerCar[playerid][Slot][Neon] == 4) { new Float:x,Float:y,Float:z; Neonrohr[playerid][Neon] = CreateObject(18652,x,y,z,0,0,0,283); Neonrohr[playerid][Neon1] = CreateObject(18652,x,y,z,0,0,0,283); AttachObjectToVehicle(Neonrohr[playerid][Neon], PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], 0.8,0,-0.70,0,0,0); AttachObjectToVehicle(Neonrohr[playerid][Neon1], PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], -0.8,0,-0.70,0,0,0); } if(PlayerCar[playerid][Slot][Neon] == 5) { new Float:x,Float:y,Float:z; Neonrohr[playerid][Neon] = CreateObject(18651,x,y,z,0,0,0,283); Neonrohr[playerid][Neon1] = CreateObject(18651,x,y,z,0,0,0,283); AttachObjectToVehicle(Neonrohr[playerid][Neon], PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], 0.8,0,-0.70,0,0,0); AttachObjectToVehicle(Neonrohr[playerid][Neon1], PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], -0.8,0,-0.70,0,0,0); } if(PlayerCar[playerid][Slot][Neon] == 6) { new Float:x,Float:y,Float:z; Neonrohr[playerid][Neon] = CreateObject(18650,x,y,z,0,0,0,283); Neonrohr[playerid][Neon1] = CreateObject(18650,x,y,z,0,0,0,283); AttachObjectToVehicle(Neonrohr[playerid][Neon], PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], 0.8,0,-0.70,0,0,0); AttachObjectToVehicle(Neonrohr[playerid][Neon1], PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId], -0.8,0,-0.70,0,0,0); } print("PlayerCarSpawn 2"); } } }
-
Mache das so:
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`,`CarModel`,`CarPos_X`,`CarPos_Y`,`CarPos_Z`,`CarPos_A`,`Preis`) VALUES ('%s_%d','%d','%f','%f','%f','%f','%d');",
name, 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;
}Und ändere noch:
format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `Privatcar` (`ID` int(11) PRIMARY KEY,");
zu:
format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `Privatcar` (`ID` int(11) AUTO_INCREMENT PRIMARY KEY,");Lösche dann die Tabelle, bevor du den Server wieder startest.
-
und jetzt wird nicks in der "Tabelle: privatcar" erstellt
msql_log
C: msql_log
Alles anzeigen[19:10:40] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving [19:11:10] [DEBUG] mysql_format - connection: 1, len: 512, format: "INSERT INTO `Privatcar` (`CarOwner`,`CarModel`,`CarPos_X`,`CarPos_Y`,`CarPos_Z`,`CarPos_A`,`Preis`) VALUES ('%s_%d','%d','%f','%..." [19:11:10] [DEBUG] mysql_pquery - connection: 1, query: "INSERT INTO `Privatcar` (`CarOwner`,`CarModel`,`CarPos_X`,`CarPo", callback: "(null)", format: "(null)" [19:11:10] [DEBUG] mysql_format - connection: 1, len: 256, format: "SELECT * FROM Privatcar WHERE `CarOwner` = '%s_%d'" [19:11:10] [DEBUG] mysql_pquery - connection: 1, query: "SELECT * FROM Privatcar WHERE `CarOwner` = 'GhostRider_0'", callback: "LoadMysqlCars", format: "sii" [19:11:10] [DEBUG] CMySQLQuery::Execute[] - starting query execution [19:11:10] [DEBUG] CMySQLQuery::Execute[LoadMysqlCars] - starting query execution [19:11:10] [ERROR] CMySQLQuery::Execute[] - (error #1054) Unknown column 'CarPos_A' in 'field list' [19:11:10] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError [19:11:10] [DEBUG] CMySQLQuery::Execute[LoadMysqlCars] - query was successfully executed within 1.759 milliseconds [19:11:10] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [19:11:10] [DEBUG] mysql_format - connection: 1, len: 256, format: "SELECT * FROM Privatcar WHERE `CarOwner` = '%s_%d'" [19:11:10] [DEBUG] mysql_pquery - connection: 1, query: "SELECT * FROM Privatcar WHERE `CarOwner` = 'GhostRider_1'", callback: "LoadMysqlCars", format: "sii" [19:11:10] [DEBUG] Calling callback "LoadMysqlCars".. [19:11:10] [DEBUG] cache_get_data - connection: 1 [19:11:10] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [19:11:10] [DEBUG] CMySQLQuery::Execute[LoadMysqlCars] - starting query execution [19:11:10] [DEBUG] CMySQLQuery::Execute[LoadMysqlCars] - query was successfully executed within 1.632 milliseconds [19:11:10] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [19:11:10] [DEBUG] Calling callback "LoadMysqlCars".. [19:11:10] [DEBUG] cache_get_data - connection: 1 [19:11:10] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
-
Die Rotation fehlt in der Tabelle.
Ändere das Query zur Erstellung der Tabelle zu:
new query[1500];
format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `Privatcar` (`ID` int(11) AUTO_INCREMENT PRIMARY KEY,");
format(query, sizeof(query), "%s`CarOwner` varchar(64) NOT NULL DEFAULT '',",query);
format(query, sizeof(query), "%s`CarId` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarModel` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarPos_X` float NOT NULL DEFAULT '0.0',",query);
format(query, sizeof(query), "%s`CarPos_Y` float NOT NULL DEFAULT '0.0',",query);
format(query, sizeof(query), "%s`CarPos_Z` float NOT NULL DEFAULT '0.0',",query);
format(query, sizeof(query), "%s`CarPos_A` float NOT NULL DEFAULT '0.0',",query);
format(query, sizeof(query), "%s`CarRotate` float NOT NULL DEFAULT '0.0',",query);
format(query, sizeof(query), "%s`CarNitro` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarHyd` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarWheel` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarAusp` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarSideL` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarSideR` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarFB` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarRB` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarSpoiler` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarRoof` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarHood` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarVents` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarLamps` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarPJ` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarC1` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`CarC2` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`Preis` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`Neon` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`Plate` varchar(64) NOT NULL DEFAULT '',",query);
format(query, sizeof(query), "%s`Number` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`Gesperrt` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`Sperrpreis` int(11) NOT NULL DEFAULT '0',",query);
format(query, sizeof(query), "%s`Abgeschleppt` int(11) NOT NULL DEFAULT '0'",query); //Letzte Zeile nach 0 kein Komma!
format(query, sizeof(query), "%s) ENGINE=MyISAM DEFAULT CHARSET=latin1;",query); -
ich ein kleines Problem mit das kennzeichen
wenn ich mir ein Fahrzeug kaufe steht da "0" soll aber "N/A" stehen
-
mysql_format(handle, str, sizeof(str), "INSERT INTO `Privatcar` (`CarOwner`,`CarModel`,`CarPos_X`,`CarPos_Y`,`CarPos_Z`,`CarPos_A`,`Preis`) VALUES ('%s_%d','%d','%f','%f','%f','%f','%d');",
zu:
mysql_format(handle, str, sizeof(str), "INSERT INTO `Privatcar` (`CarOwner`,`CarModel`,`CarPos_X`,`CarPos_Y`,`CarPos_Z`,`CarPos_A`,`Preis`,`Plate`) VALUES ('%s_%d','%d','%f','%f','%f','%f','%d','N/A');", -
habe noch 3 Probleme das erste ist wenn ich "/park" eingebe verschwindest sein car aber erstellt wird das fahrzeug nicht mehr
es hört bei "SaveMysqlCars 1"auf mehr Passiert nichtsC: SaveMysqlCars
Alles anzeigenforward SaveMysqlCars(playername2[],x,playerid); public SaveMysqlCars(playername2[],x,playerid) { print("SaveMysqlCars 1"); new rows,fields,string3[1024]; cache_get_data(rows,fields); if(rows) { print("SaveMysqlCars 2"); format(string3, sizeof(string3), "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], Spielerinfo[playerid][Name], x); mysql_pquery(handle, string3); print("SaveMysqlCars 3"); format(string3, sizeof(string3), "UPDATE `Privatcar` SET `CarSideL`='%d',`CarSideR`='%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], Spielerinfo[playerid][Name], x); mysql_pquery(handle, string3); print("SaveMysqlCars 4"); format(string3, sizeof(string3), "UPDATE `Privatcar` SET `CarPJ`='%d',`CarC1`='%d',`CarC2`='%d',`Preis`='%d',`Neon`='%d',`Plate`='%d',`Number`='%s',`Gesperrt`='%d',`Sperrpreis`='%d',`Kralle`='%d',`Abgeschleppt`='%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],PlayerCar[playerid][x][Abgeschleppt], Spielerinfo[playerid][Name], x); mysql_pquery(handle, string3); print("SaveMysqlCars 5"); } }
Das Nächste Problem liegt beim löschen von Fahrzeuge wenn mann "/carsell" eingibe würd das Fahrzeug vom Server Gelöscht aber nicht von der Tabelle da steht das fahrzeug noch drine
C: /carsell
Alles anzeigenif(strcmp("/carsell", cmdtext, true, 10) == 0) { if(Dtc_PlayerHaveCar[playerid][Dtc_PlayerKey[playerid]]) { GivePlayerMoney(playerid,PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPreis]/2); Dtc_Carlock[PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId]] = 0; Dtc_UnLockCar(PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId]); DestroyVehicle(PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId]); new string3[32]; new playername3[MAX_PLAYER_NAME]; GetPlayerName(playerid, playername3, sizeof(playername3)); mysql_format(handle,string3, sizeof(string3), "DELETE FROM `Privatcar` WHERE `CarOwner`='%s_%d'", playername3,Dtc_PlayerKey[playerid]); mysql_pquery(handle, string3); Dtc_PlayerHaveCar[playerid][Dtc_PlayerKey[playerid]] = 0; SendClientMessage(playerid, COLOR_YELLOW, "Fahrzeug erfolgreich verkauft. Die Helfte des Kaufpreises wurde dir erstattet!"); } else { SendClientMessage(playerid, COLOR_GREY, "Du besitzt kein Fahrzeug!"); return 1; } return 1; }
3.Problem
ich kann nur ein Fahrzeug kaufen das das nächste wird erstellt aber nicht geladen
ist wegen "CarId" weil da immer 0 stehtDanke im Vorraus
-
Heißt alter table nicht sowas wie löschen?
-
Heißt alter table nicht sowas wie löschen?
Nein ALTER ändert die Struktur einer Tabelle (Zeile erstellen / löschen / editieren etc)
bspw: ALTER TABLE `players` CHANGE COLUMN `positionX` `posX` FLOAT; -
sry jungs aber ich warte auf ein der mehr anung hat von MSQL
-
@fishy
Eine Tabelle löscht man mit "DROP TABLE".
http://dev.mysql.com/doc/refman/5.7/en/drop-table.html
_____________________Zu den Problemen:
1.)
Wie sieht dein /park Befehl aktuell aus? Poste den bitte.
Warum wird das Fahrzeug beim parken eigentlich neu erstellt? Ist das Absicht, wenn ja, was ist der Grund dafür?2.)
Die Variable für das Query im /carsell Befehl ist zu kurz.
new string3[32];
zu:
new string3[128];3.)
Was hat es mit der CarId auf sich?
Ändere gegebenenfalls
mysql_format(handle, str, sizeof(str), "INSERT INTO `Privatcar` (`CarOwner`,`CarModel`,`CarPos_X`,`CarPos_Y`,`CarPos_Z`,`CarPos_A`,`Preis`,`Plate`) VALUES ('%s_%d','%d','%f','%f','%f','%f','%d','N/A');",
name, x,Model, PlayerCar[playerid][x][CarPos_x], PlayerCar[playerid][x][CarPos_y], PlayerCar[playerid][x][CarPos_z],PlayerCar[playerid][x][CarRotate],Preis);
zu:
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);
Ich habe jetzt einfach mal angenommen, dass die CarId dem Key entspricht, also hier dem x.
Falls das nicht passt, ändere das. -
hier ist das /Park system alles was dazu gehört
aber das hier macht er nicht "OnPlayerCarUpdate_SQL(playerid);"
sonnst macht er den Befehl ja
Zitat von JeffryZu den Problemen:
1.)Warum wird das Fahrzeug beim parken eigentlich neu erstellt? Ist das Absicht, wenn ja, was ist der Grund dafür?
ja das ist mit absicht gemacht das, das Fahrzeug das parken auch übernimmt nachen
C
Alles anzeigenif(strcmp("/park", cmdtext, true, 10) == 0) { if(Dtc_PlayerHaveCar[playerid][Dtc_PlayerKey[playerid]]) { new newcar = GetPlayerVehicleID(playerid); if (newcar == PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarId]) { new Float:X,Float:Y,Float:Z; new Float:z_rot; GetPlayerPos(playerid, X,Y,Z); GetVehicleZAngle(newcar, z_rot); PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_x] = X; PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_y] = Y; PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarPos_z] = Z; PlayerCar[playerid][Dtc_PlayerKey[playerid]][CarRotate] = z_rot; OnPlayerCarUpdate_SQL(playerid); SendClientMessage(playerid, COLOR_YELLOW, "Du hast dein Fahrzeug hier geparkt, ab nun kannst du dein Fahrzeug hier finden!"); } else { SendClientMessage(playerid,COLOR_GREY,"Du bist nicht in deinem Fahrzeug/Du hast nicht den Schlüssel zu diesem Fahrzeug ausgewählt!"); return 1; } } else { SendClientMessage(playerid, COLOR_GREY, "Du besitzt kein Fahrzeug für deinen ausgewählten Schlüssel!"); return 1; } return 1; }
C: OnPlayerCarUpdate_SQL
Alles anzeigenpublic OnPlayerCarUpdate_SQL(playerid) { if(IsPlayerConnected(playerid)) { for(new x = 0; x < MaxVeh; x++) { if(Dtc_PlayerHaveCar[playerid][x]) { print("OnPlayerCarUpdate_SQL 1"); DestroyObject(Neonrohr[playerid][Neon]); DestroyObject(Neonrohr[playerid][Neon1]); DestroyVehicle(PlayerCar[playerid][x][CarId]); print("OnPlayerCarUpdate_SQL 2"); Dtc_Carlock[PlayerCar[playerid][x][CarId]] = 0; Dtc_LockCar(PlayerCar[playerid][x][CarId]); print("OnPlayerCarUpdate_SQL 3"); new query[256]; mysql_format(handle, query, sizeof(query), "SELECT * FROM Privatcar WHERE `CarOwner` = '%s_%d'", Spielerinfo[playerid][Name],x); mysql_pquery(handle, query, "SaveMysqlCars", "sii", Spielerinfo[playerid][Name],x,playerid); print("OnPlayerCarUpdate_SQL 3"); } } } }
C: SaveMysqlCars
Alles anzeigenforward SaveMysqlCars(playername2[],x,playerid); public SaveMysqlCars(playername2[],x,playerid) { print("SaveMysqlCars 1"); new rows,fields,string3[1024]; cache_get_data(rows,fields); if(rows) { print("SaveMysqlCars 2"); format(string3, sizeof(string3), "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], Spielerinfo[playerid][Name], x); mysql_pquery(handle, string3); print("SaveMysqlCars 3"); format(string3, sizeof(string3), "UPDATE `Privatcar` SET `CarSideL`='%d',`CarSideR`='%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], Spielerinfo[playerid][Name], x); mysql_pquery(handle, string3); print("SaveMysqlCars 4"); format(string3, sizeof(string3), "UPDATE `Privatcar` SET `CarPJ`='%d',`CarC1`='%d',`CarC2`='%d',`Preis`='%d',`Neon`='%d',`Plate`='%d',`Number`='%s',`Gesperrt`='%d',`Sperrpreis`='%d',`Kralle`='%d',`Abgeschleppt`='%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],PlayerCar[playerid][x][Abgeschleppt], Spielerinfo[playerid][Name], x); mysql_pquery(handle, string3); print("SaveMysqlCars 5"); } }
Was hat es mit der CarId auf sich?
ja das ist das leiche wie du mir das fertig gemacht hast mit ID
format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `Privatcar` (`ID` int(11) AUTO_INCREMENT PRIMARY KEY,"); -