Hallo Liebe Leute,
ich habe ein Problem mit meinem Car system.
Ich habe es auf MySQL umgerschrieben jedoch updaten die autos nicht..
Meine Datenbank:
Codes:
Hier Connecten sie:
public PlayerCarConnect(playerid)
{
if(IsPlayerNPC(playerid)) { return 1; }
new string[256];
new iMaxCars = MaxVeh[playerid];
new iCurrentCar = -1;
{
if(IsPlayerNPC(playerid)) { return 1; }
new string[256];
new iMaxCars = MaxVeh[playerid];
new iCurrentCar = -1;
format(string, sizeof string, "SELECT * FROM `usercars` WHERE `uID` = %d", PlayerInfo[playerid][pSQLID]);
mysql_query(string);
mysql_store_result();
new tmpStr[256];
mysql_query(string);
mysql_store_result();
new tmpStr[256];
if(mysql_num_rows() >= 1)
{
while(mysql_fetch_row(string))
{
iCurrentCar += 1;
if(iCurrentCar > (iMaxCars-1)) {
mysql_free_result(MySQLConnection);
break;
}
mysql_fetch_field_row(tmpStr, "ID"); Carlist[playerid][iCurrentCar][ID] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Typ"); Carlist[playerid][iCurrentCar][Typ] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_X"); Carlist[playerid][iCurrentCar][pos_x] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Y"); Carlist[playerid][iCurrentCar][pos_y] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Z"); Carlist[playerid][iCurrentCar][pos_z] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Rot"); Carlist[playerid][iCurrentCar][z_angle] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Status"); Carlist[playerid][iCurrentCar][Status] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Lock"); Carlist[playerid][iCurrentCar][Lock] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Paintjob"); Carlist[playerid][iCurrentCar][Paintjob] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Farbe1"); Carlist[playerid][iCurrentCar][Farbe1] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Farbe2"); Carlist[playerid][iCurrentCar][Farbe2] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod1"); Carlist[playerid][iCurrentCar][mod1] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod2"); Carlist[playerid][iCurrentCar][mod2] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod3"); Carlist[playerid][iCurrentCar][mod3] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod4"); Carlist[playerid][iCurrentCar][mod4] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod5"); Carlist[playerid][iCurrentCar][mod5] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod6"); Carlist[playerid][iCurrentCar][mod6] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod7"); Carlist[playerid][iCurrentCar][mod7] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod8"); Carlist[playerid][iCurrentCar][mod8] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod9"); Carlist[playerid][iCurrentCar][mod9] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod10"); Carlist[playerid][iCurrentCar][mod10] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod11"); Carlist[playerid][iCurrentCar][mod11] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod12"); Carlist[playerid][iCurrentCar][mod12] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod13"); Carlist[playerid][iCurrentCar][mod13] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod14"); Carlist[playerid][iCurrentCar][mod14] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod15"); Carlist[playerid][iCurrentCar][mod15] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod16"); Carlist[playerid][iCurrentCar][mod16] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod17"); Carlist[playerid][iCurrentCar][mod17] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_SpawnSaveX"); Carlist[playerid][iCurrentCar][SpawnSaveX] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_SpawnSaveY"); Carlist[playerid][iCurrentCar][SpawnSaveY] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_SpawnSaveZ"); Carlist[playerid][iCurrentCar][SpawnSaveZ] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_SpawnSaveRot"); Carlist[playerid][iCurrentCar][SpawnSaveRot] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_TankVolumen"); Carlist[playerid][iCurrentCar][TankVolumen] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_RepairTime"); Carlist[playerid][iCurrentCar][RepairTime] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Versicherung"); Carlist[playerid][iCurrentCar][Versicherung] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_StandTime"); Carlist[playerid][iCurrentCar][StandTime] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Meter"); Carlist[playerid][iCurrentCar][Meter] = strval(tmpStr);
}
mysql_free_result(MySQLConnection);
}
{
while(mysql_fetch_row(string))
{
iCurrentCar += 1;
if(iCurrentCar > (iMaxCars-1)) {
mysql_free_result(MySQLConnection);
break;
}
mysql_fetch_field_row(tmpStr, "ID"); Carlist[playerid][iCurrentCar][ID] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Typ"); Carlist[playerid][iCurrentCar][Typ] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_X"); Carlist[playerid][iCurrentCar][pos_x] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Y"); Carlist[playerid][iCurrentCar][pos_y] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Z"); Carlist[playerid][iCurrentCar][pos_z] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Rot"); Carlist[playerid][iCurrentCar][z_angle] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Status"); Carlist[playerid][iCurrentCar][Status] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Lock"); Carlist[playerid][iCurrentCar][Lock] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Paintjob"); Carlist[playerid][iCurrentCar][Paintjob] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Farbe1"); Carlist[playerid][iCurrentCar][Farbe1] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Farbe2"); Carlist[playerid][iCurrentCar][Farbe2] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod1"); Carlist[playerid][iCurrentCar][mod1] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod2"); Carlist[playerid][iCurrentCar][mod2] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod3"); Carlist[playerid][iCurrentCar][mod3] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod4"); Carlist[playerid][iCurrentCar][mod4] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod5"); Carlist[playerid][iCurrentCar][mod5] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod6"); Carlist[playerid][iCurrentCar][mod6] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod7"); Carlist[playerid][iCurrentCar][mod7] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod8"); Carlist[playerid][iCurrentCar][mod8] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod9"); Carlist[playerid][iCurrentCar][mod9] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod10"); Carlist[playerid][iCurrentCar][mod10] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod11"); Carlist[playerid][iCurrentCar][mod11] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod12"); Carlist[playerid][iCurrentCar][mod12] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod13"); Carlist[playerid][iCurrentCar][mod13] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod14"); Carlist[playerid][iCurrentCar][mod14] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod15"); Carlist[playerid][iCurrentCar][mod15] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod16"); Carlist[playerid][iCurrentCar][mod16] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_mod17"); Carlist[playerid][iCurrentCar][mod17] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_SpawnSaveX"); Carlist[playerid][iCurrentCar][SpawnSaveX] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_SpawnSaveY"); Carlist[playerid][iCurrentCar][SpawnSaveY] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_SpawnSaveZ"); Carlist[playerid][iCurrentCar][SpawnSaveZ] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_SpawnSaveRot"); Carlist[playerid][iCurrentCar][SpawnSaveRot] = floatstr(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_TankVolumen"); Carlist[playerid][iCurrentCar][TankVolumen] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_RepairTime"); Carlist[playerid][iCurrentCar][RepairTime] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Versicherung"); Carlist[playerid][iCurrentCar][Versicherung] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_StandTime"); Carlist[playerid][iCurrentCar][StandTime] = strval(tmpStr);
mysql_fetch_field_row(tmpStr, "AH_Meter"); Carlist[playerid][iCurrentCar][Meter] = strval(tmpStr);
}
mysql_free_result(MySQLConnection);
}
for(new h = 0; h < MaxVeh[playerid]; h++)
{
if(Carlist[playerid][h][Typ] != -1 && Carlist[playerid][h][Status] == 0){
new iCarID = CreateTunedCar(playerid, h);
Carlist[playerid][h][Carid] = iCarID;
Meters[iCarID] = Carlist[playerid][h][Meter];
GetVehiclePos(iCarID, fOldPos[iCarID][0], fOldPos[iCarID][1], fOldPos[iCarID][2]);
}
}
return 1;
}
{
if(Carlist[playerid][h][Typ] != -1 && Carlist[playerid][h][Status] == 0){
new iCarID = CreateTunedCar(playerid, h);
Carlist[playerid][h][Carid] = iCarID;
Meters[iCarID] = Carlist[playerid][h][Meter];
GetVehiclePos(iCarID, fOldPos[iCarID][0], fOldPos[iCarID][1], fOldPos[iCarID][2]);
}
}
return 1;
}
Hier sollen sie Updaten:
public PlayerCarUpdate(playerid)
{
if(IsPlayerNPC(playerid)) { return 1; }
{
if(IsPlayerNPC(playerid)) { return 1; }
new string[6000];
for(new h = 0; h < MaxVeh[playerid]; h++)
{
if(Carlist[playerid][h][ID] != 0)
{
strmid(string, "", 0, sizeof(string));
format(string, sizeof(string), "UPDATE `usercars` SET `AH_Typ` = %d, ", Carlist[playerid][h][Typ]);
format(string, sizeof(string), "%s`AH_Typ` = %d, ", string, Carlist[playerid][h][Typ]);
for(new h = 0; h < MaxVeh[playerid]; h++)
{
if(Carlist[playerid][h][ID] != 0)
{
strmid(string, "", 0, sizeof(string));
format(string, sizeof(string), "UPDATE `usercars` SET `AH_Typ` = %d, ", Carlist[playerid][h][Typ]);
format(string, sizeof(string), "%s`AH_Typ` = %d, ", string, Carlist[playerid][h][Typ]);
format(string, sizeof(string), "%s`AH_X` = %f, ", string, Carlist[playerid][h][pos_x]);
format(string, sizeof(string), "%s`AH_Y` = %f, ", string, Carlist[playerid][h][pos_y]);
format(string, sizeof(string), "%s`AH_Z` = %f, ", string, Carlist[playerid][h][pos_z]);
format(string, sizeof(string), "%s`AH_Rot` = %f, ", string, Carlist[playerid][h][z_angle]);
format(string, sizeof(string), "%s`AH_Y` = %f, ", string, Carlist[playerid][h][pos_y]);
format(string, sizeof(string), "%s`AH_Z` = %f, ", string, Carlist[playerid][h][pos_z]);
format(string, sizeof(string), "%s`AH_Rot` = %f, ", string, Carlist[playerid][h][z_angle]);
format(string, sizeof(string), "%s`AH_Status` = %d, ", string, Carlist[playerid][h][Status]);
format(string, sizeof(string), "%s`AH_Lock` = %d, ", string, Carlist[playerid][h][Lock]);
format(string, sizeof(string), "%s`AH_Paintjob` = %d, ", string, Carlist[playerid][h][Paintjob]);
format(string, sizeof(string), "%s`AH_Lock` = %d, ", string, Carlist[playerid][h][Lock]);
format(string, sizeof(string), "%s`AH_Paintjob` = %d, ", string, Carlist[playerid][h][Paintjob]);
format(string, sizeof(string), "%s`AH_Farbe1` = %d, ", string, Carlist[playerid][h][Farbe1]);
format(string, sizeof(string), "%s`AH_Farbe2` = %d, ", string, Carlist[playerid][h][Farbe2]);
format(string, sizeof(string), "%s`AH_Farbe2` = %d, ", string, Carlist[playerid][h][Farbe2]);
format(string, sizeof(string), "%s`AH_mod1` = %d, ", string, Carlist[playerid][h][mod1]);
format(string, sizeof(string), "%s`AH_mod2` = %d, ", string, Carlist[playerid][h][mod2]);
format(string, sizeof(string), "%s`AH_mod3` = %d, ", string, Carlist[playerid][h][mod3]);
format(string, sizeof(string), "%s`AH_mod4` = %d, ", string, Carlist[playerid][h][mod4]);
format(string, sizeof(string), "%s`AH_mod5` = %d, ", string, Carlist[playerid][h][mod5]);
format(string, sizeof(string), "%s`AH_mod6` = %d, ", string, Carlist[playerid][h][mod6]);
format(string, sizeof(string), "%s`AH_mod7` = %d, ", string, Carlist[playerid][h][mod7]);
format(string, sizeof(string), "%s`AH_mod8` = %d, ", string, Carlist[playerid][h][mod8]);
format(string, sizeof(string), "%s`AH_mod9` = %d, ", string, Carlist[playerid][h][mod9]);
format(string, sizeof(string), "%s`AH_mod10` = %d, ", string, Carlist[playerid][h][mod10]);
format(string, sizeof(string), "%s`AH_mod11` = %d, ", string, Carlist[playerid][h][mod11]);
format(string, sizeof(string), "%s`AH_mod12` = %d, ", string, Carlist[playerid][h][mod12]);
format(string, sizeof(string), "%s`AH_mod13` = %d, ", string, Carlist[playerid][h][mod13]);
format(string, sizeof(string), "%s`AH_mod14` = %d, ", string, Carlist[playerid][h][mod14]);
format(string, sizeof(string), "%s`AH_mod15` = %d, ", string, Carlist[playerid][h][mod15]);
format(string, sizeof(string), "%s`AH_mod16` = %d, ", string, Carlist[playerid][h][mod16]);
format(string, sizeof(string), "%s`AH_mod17` = %d, ", string, Carlist[playerid][h][mod17]);
format(string, sizeof(string), "%s`AH_mod2` = %d, ", string, Carlist[playerid][h][mod2]);
format(string, sizeof(string), "%s`AH_mod3` = %d, ", string, Carlist[playerid][h][mod3]);
format(string, sizeof(string), "%s`AH_mod4` = %d, ", string, Carlist[playerid][h][mod4]);
format(string, sizeof(string), "%s`AH_mod5` = %d, ", string, Carlist[playerid][h][mod5]);
format(string, sizeof(string), "%s`AH_mod6` = %d, ", string, Carlist[playerid][h][mod6]);
format(string, sizeof(string), "%s`AH_mod7` = %d, ", string, Carlist[playerid][h][mod7]);
format(string, sizeof(string), "%s`AH_mod8` = %d, ", string, Carlist[playerid][h][mod8]);
format(string, sizeof(string), "%s`AH_mod9` = %d, ", string, Carlist[playerid][h][mod9]);
format(string, sizeof(string), "%s`AH_mod10` = %d, ", string, Carlist[playerid][h][mod10]);
format(string, sizeof(string), "%s`AH_mod11` = %d, ", string, Carlist[playerid][h][mod11]);
format(string, sizeof(string), "%s`AH_mod12` = %d, ", string, Carlist[playerid][h][mod12]);
format(string, sizeof(string), "%s`AH_mod13` = %d, ", string, Carlist[playerid][h][mod13]);
format(string, sizeof(string), "%s`AH_mod14` = %d, ", string, Carlist[playerid][h][mod14]);
format(string, sizeof(string), "%s`AH_mod15` = %d, ", string, Carlist[playerid][h][mod15]);
format(string, sizeof(string), "%s`AH_mod16` = %d, ", string, Carlist[playerid][h][mod16]);
format(string, sizeof(string), "%s`AH_mod17` = %d, ", string, Carlist[playerid][h][mod17]);
format(string, sizeof(string), "%s`AH_SpawnSaveX` = %f, ", string, Carlist[playerid][h][SpawnSaveX]);
format(string, sizeof(string), "%s`AH_SpawnSaveY` = %f, ", string, Carlist[playerid][h][SpawnSaveY]);
format(string, sizeof(string), "%s`AH_SpawnSaveZ` = %f, ", string, Carlist[playerid][h][SpawnSaveZ]);
format(string, sizeof(string), "%s`AH_SpawnSaveRot` = %f, ", string, Carlist[playerid][h][SpawnSaveRot]);
format(string, sizeof(string), "%s`AH_TankVolumen` = %d, ", string, Carlist[playerid][h][TankVolumen]);
format(string, sizeof(string), "%s`AH_RepairTime` = %d, ", string, Carlist[playerid][h][RepairTime]);
format(string, sizeof(string), "%s`AH_Versicherung` = %d, ", string, Carlist[playerid][h][Versicherung]);
format(string, sizeof(string), "%s`AH_StandTime` = %d, ", string, Carlist[playerid][h][StandTime]);
format(string, sizeof(string), "%s`AH_Meter` = %d ", string, Meters[Carlist[playerid][h][Carid]]);
format(string, sizeof(string), "%s`AH_SpawnSaveY` = %f, ", string, Carlist[playerid][h][SpawnSaveY]);
format(string, sizeof(string), "%s`AH_SpawnSaveZ` = %f, ", string, Carlist[playerid][h][SpawnSaveZ]);
format(string, sizeof(string), "%s`AH_SpawnSaveRot` = %f, ", string, Carlist[playerid][h][SpawnSaveRot]);
format(string, sizeof(string), "%s`AH_TankVolumen` = %d, ", string, Carlist[playerid][h][TankVolumen]);
format(string, sizeof(string), "%s`AH_RepairTime` = %d, ", string, Carlist[playerid][h][RepairTime]);
format(string, sizeof(string), "%s`AH_Versicherung` = %d, ", string, Carlist[playerid][h][Versicherung]);
format(string, sizeof(string), "%s`AH_StandTime` = %d, ", string, Carlist[playerid][h][StandTime]);
format(string, sizeof(string), "%s`AH_Meter` = %d ", string, Meters[Carlist[playerid][h][Carid]]);
format(string, sizeof(string), "%sWHERE `uID` = %d AND `ID` = %d", string, PlayerInfo[playerid][pSQLID], Carlist[playerid][h][ID]);
self_mysql_queryEx(string);
}
}
return 1;
}
}
}
return 1;
}
Hier disconnecten sie:
public PlayerCarDisconnect(playerid)
{
if(IsPlayerNPC(playerid)){
return 1;
}
for(new h = 0; h < MaxVeh[playerid]; h++)
{
if(Carlist[playerid][h][Carid] != -1)
{
GetVehiclePos(Carlist[playerid][h][Carid], Carlist[playerid][h][SpawnSaveX], Carlist[playerid][h][SpawnSaveY], Carlist[playerid][h][SpawnSaveZ]);
GetVehicleZAngle(Carlist[playerid][h][Carid], Carlist[playerid][h][SpawnSaveRot]);
Carlist[playerid][h][TankVolumen] = Gas[Carlist[playerid][h][Carid]];
PlayerCarUpdate(playerid);
ForAllPlayers(i)
{
SetVehicleParamsForPlayer(Carlist[playerid][h][Carid],i,0,0);
}
DestroyVehicleSelfmade(Carlist[playerid][h][Carid]);
Carlist[playerid][h][Carid] = -1;
}
}
if(Spectating[playerid] != -1){
ForAllPlayers(i){
SetVehicleParamsForPlayer(Kaufliste[Spectating[playerid]][Carid],i,0,0);
}
Spectating[playerid] = -1;
}
return 1;
}
{
if(IsPlayerNPC(playerid)){
return 1;
}
for(new h = 0; h < MaxVeh[playerid]; h++)
{
if(Carlist[playerid][h][Carid] != -1)
{
GetVehiclePos(Carlist[playerid][h][Carid], Carlist[playerid][h][SpawnSaveX], Carlist[playerid][h][SpawnSaveY], Carlist[playerid][h][SpawnSaveZ]);
GetVehicleZAngle(Carlist[playerid][h][Carid], Carlist[playerid][h][SpawnSaveRot]);
Carlist[playerid][h][TankVolumen] = Gas[Carlist[playerid][h][Carid]];
PlayerCarUpdate(playerid);
ForAllPlayers(i)
{
SetVehicleParamsForPlayer(Carlist[playerid][h][Carid],i,0,0);
}
DestroyVehicleSelfmade(Carlist[playerid][h][Carid]);
Carlist[playerid][h][Carid] = -1;
}
}
if(Spectating[playerid] != -1){
ForAllPlayers(i){
SetVehicleParamsForPlayer(Kaufliste[Spectating[playerid]][Carid],i,0,0);
}
Spectating[playerid] = -1;
}
return 1;
}
Danke im vorraus.