Es gelingt garnichts in die Datenbank wenn ich den Server verlasse ich habe das ganze auch mal Printen lassen hier mal der Code und unten noch ein Screen
PHP
stock CreatePrivatfahrzeug(playerid)
{
new query[1000];
for(new h = 0; h < MaxVeh[playerid]; h++)
{
format(query, sizeof(query), "INSERT INTO `usercars` (`SQLID`, `Slot`, `AH_Typ`) VALUES ('%d', '%d','-1')", PlayerInfo[playerid][pSQLID], h);
mysql_query(query);
print("- Usercars - ");
}
return true;
}
forward PlayerCarConnect(playerid);
public PlayerCarConnect(playerid){
if(IsPlayerNPC(playerid)) return 1;
new string[258],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
for(new h = 0; h < MaxVeh[playerid]; h++)
{
format(string, sizeof(string),"SELECT * FROM `usercars` WHERE `SQLID` = '%d' AND `Slot` = '%d'", PlayerInfo[playerid][pSQLID], h);
self_mysql_queryEx(string);
mysql_store_result();
new val[ 256 ], Variable;
print("- Usercars2 - ");
while(mysql_fetch_row_format(string,"|"))
{
self_mysql_get_field("AH_Typ", val); Carlist[playerid][h][Typ] = strval( val );
self_mysql_get_field("AH_X", val); Carlist[playerid][h][pos_x] = strval( val );
self_mysql_get_field("AH_Y", val); Carlist[playerid][h][pos_y] = strval( val );
self_mysql_get_field("AH_Z", val); Carlist[playerid][h][pos_z] = strval( val );
self_mysql_get_field("AH_Rot", val); Carlist[playerid][h][z_angle] = strval( val );
self_mysql_get_field("AH_Status", val); Carlist[playerid][h][Status] = strval( val );
self_mysql_get_field("AH_Lock", val); Carlist[playerid][h][Lock] = strval( val );
self_mysql_get_field("AH_Paintjob", val); Carlist[playerid][h][Paintjob] = strval( val );
self_mysql_get_field("AH_Farbe1", val); Carlist[playerid][h][Farbe1] = strval( val );
self_mysql_get_field("AH_Farbe2", val); Carlist[playerid][h][Farbe2] = strval( val );
self_mysql_get_field("AH_mod1", val); Carlist[playerid][h][mod1] = strval( val );
self_mysql_get_field("AH_mod2", val); Carlist[playerid][h][mod2] = strval( val );
self_mysql_get_field("AH_mod3", val); Carlist[playerid][h][mod3] = strval( val );
self_mysql_get_field("AH_mod4", val); Carlist[playerid][h][mod4] = strval( val );
self_mysql_get_field("AH_mod5", val); Carlist[playerid][h][mod5] = strval( val );
self_mysql_get_field("AH_mod6", val); Carlist[playerid][h][mod6] = strval( val );
self_mysql_get_field("AH_mod7", val); Carlist[playerid][h][mod7] = strval( val );
self_mysql_get_field("AH_mod8", val); Carlist[playerid][h][mod8] = strval( val );
self_mysql_get_field("AH_mod9", val); Carlist[playerid][h][mod9] = strval( val );
self_mysql_get_field("AH_mod10", val); Carlist[playerid][h][mod10] = strval( val );
self_mysql_get_field("AH_mod11", val); Carlist[playerid][h][mod11] = strval( val );
self_mysql_get_field("AH_mod12", val); Carlist[playerid][h][mod12] = strval( val );
self_mysql_get_field("AH_mod13", val); Carlist[playerid][h][mod13] = strval( val );
self_mysql_get_field("AH_mod14", val); Carlist[playerid][h][mod14] = strval( val );
self_mysql_get_field("AH_mod15", val); Carlist[playerid][h][mod15] = strval( val );
self_mysql_get_field("AH_mod16", val); Carlist[playerid][h][mod16] = strval( val );
self_mysql_get_field("AH_mod17", val); Carlist[playerid][h][mod17] = strval( val );
self_mysql_get_field("AH_SpawnSaveX", val); Carlist[playerid][h][SpawnSaveX] = strval( val );
self_mysql_get_field("AH_SpawnSaveY", val); Carlist[playerid][h][SpawnSaveY] = strval( val );
self_mysql_get_field("AH_SpawnSaveZ", val); Carlist[playerid][h][SpawnSaveZ] = strval( val );
self_mysql_get_field("AH_SpawnSaveRot", val); Carlist[playerid][h][SpawnSaveRot] = strval( val );
self_mysql_get_field("AH_TankVolumen", val); Carlist[playerid][h][TankVolumen] = strval( val );
self_mysql_get_field("AH_Meter", val); Carlist[playerid][h][Meter] = strval( val );
self_mysql_get_field("AH_Kilometer", val); Carlist[playerid][h][KiloMeter] = strval( val );
self_mysql_get_field("AH_Neon", val); Variable = strval( val );
mysql_free_result();
}
if(Carlist[playerid][h][Typ] != -1 && Carlist[playerid][h][Status] == 0)
{
Carlist[playerid][h][Carid] = CreateTunedCar(playerid, h);
NeonObject[Carlist[playerid][h][Carid]][3] = Variable;
if(NeonObject[Carlist[playerid][h][Carid]][3] != -1)
{
print("- neon - ");
NeonObject[Carlist[playerid][h][Carid]][1] = CreateDynamicObjectEx(NeonObject[Carlist[playerid][h][Carid]][3], 0, 0, 0, 0, 0, 0);
NeonObject[Carlist[playerid][h][Carid]][2] = CreateDynamicObjectEx(NeonObject[Carlist[playerid][h][Carid]][3], 0, 0, 0, 0, 0, 0);
AttachDynamicObjectToVehicle(NeonObject[Carlist[playerid][h][Carid]][1], Carlist[playerid][h][Carid], -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
AttachDynamicObjectToVehicle(NeonObject[Carlist[playerid][h][Carid]][2], Carlist[playerid][h][Carid], 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
}
}
}
return 1;
}
forward PlayerCarUpdate(playerid);
public PlayerCarUpdate(playerid)
{
if(IsPlayerNPC(playerid)) return 1;
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
for(new h = 0; h < MaxVeh[playerid]; h++)
{
new endstring[4000];
new var[129];
print("- Usercars3 - ");
format(endstring, sizeof(endstring), "UPDATE `usercars` SET ");
format(var, sizeof(var), "`AH_Typ`='%d', ", Carlist[playerid][h][Typ]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_X`='%f', ", Carlist[playerid][h][pos_x]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_Y`='%f', ", Carlist[playerid][h][pos_y]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_Z`='%f', ", Carlist[playerid][h][pos_z]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_Rot`='%f', ", Carlist[playerid][h][z_angle]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_Kilometer`='%f', ", Kilometerstand[Carlist[playerid][h][Carid]]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_Status`='%d', ", Carlist[playerid][h][Status]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_Lock`='%d', ", Carlist[playerid][h][Lock]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_Paintjob`='%d', ", Carlist[playerid][h][Paintjob]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_Farbe1`='%d', ", Carlist[playerid][h][Farbe1]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_Farbe2`='%d', ", Carlist[playerid][h][Farbe2]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod1`='%d', ", Carlist[playerid][h][mod1]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod2`='%d', ", Carlist[playerid][h][mod2]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod3`='%d', ", Carlist[playerid][h][mod3]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod4`='%d', ", Carlist[playerid][h][mod4]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod5`='%d', ", Carlist[playerid][h][mod5]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod6`='%d', ", Carlist[playerid][h][mod6]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod7`='%d', ", Carlist[playerid][h][mod7]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod8`='%d', ", Carlist[playerid][h][mod8]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod9`='%d', ", Carlist[playerid][h][mod9]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod10`='%d', ", Carlist[playerid][h][mod10]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod11`='%d', ", Carlist[playerid][h][mod11]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod12`='%d', ", Carlist[playerid][h][mod12]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod13`='%d', ", Carlist[playerid][h][mod13]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod14`='%d', ", Carlist[playerid][h][mod14]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod15`='%d', ", Carlist[playerid][h][mod15]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod16`='%d', ", Carlist[playerid][h][mod16]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_mod17`='%d', ", Carlist[playerid][h][mod17]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_SpawnSaveX`='%f', ", Carlist[playerid][h][SpawnSaveX]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_SpawnSaveY`='%f', ", Carlist[playerid][h][SpawnSaveY]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_SpawnSaveZ`='%f', ", Carlist[playerid][h][SpawnSaveZ]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_SpawnSaveRot`='%f', ", Carlist[playerid][h][SpawnSaveRot]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_TankVolumen`='%f', ", Gas[Carlist[playerid][h][Carid]]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_Meter`='%d', ", Carlist[playerid][h][Meter]);
strcat(endstring, var);
format(var, sizeof(var), "`AH_Neon`='%d', ", NeonObject[Carlist[playerid][h][Carid]][3]);
strcat(endstring, var);
format(var, sizeof(var), "WHERE `SQLID`='%d' AND `Slot`='%d'", PlayerInfo[playerid][pSQLID], h);
strcat(endstring, var);
print("- Usercars4 - ");
mysql_query(endstring);
}
return 1;
}
forward PlayerCarDisconnect(playerid);
public PlayerCarDisconnect(playerid)
{
if(IsPlayerNPC(playerid)) return 1;
PlayerCarUpdate(playerid);
for(new h = 0; h < MaxVeh[playerid]; h++)
{
if(Carlist[playerid][h][Carid] != -1)
{
//Carlist[playerid][h][TankVolumen] = Gas[Carlist[playerid][h][Carid]];
//Carlist[playerid][h][KiloMeter] = Kilometerstand[Carlist[playerid][h][Carid]];
DestroyVehicleSelfmade(Carlist[playerid][h][Carid]);
Carlist[playerid][h][Carid] = -1;
print("- PlayerCarDisConnect - ");
}
}
if(Spectating[playerid] != -1)
{
ForAllPlayers(i)
{
SetVehicleParamsForPlayer(Kaufliste[Spectating[playerid]][Carid],i,0,0);
}
Spectating[playerid] = -1;
}
return 1;
}
Alles anzeigen
So Hier
Und hier in der Datenbank wenn Spieler Server verlässt und ein Auto gekauft hat und nichts in der Datenbank steht
Liebe Grüße