Guten Tag,
Ich bin zeit gestern an einem Autohaus dran und habe probleme beim speichern, in der tabelle wird
nix gespeichert hir der cod vom stock speichern und ocmd:buycar und ocmd:park:
buycar:
ocmd:buycar(playerid, params[])
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
for(new i=0; i<sizeof(autokauf); i++)
{
new cpreis =autokauf[i][CarPreis];
new str[128];
format(str,sizeof(str),"Du besitzt zuwenig geld du benötigst %i", cpreis);
new autohaus=autokauf[i][Autohaus];
if(pAutoInfo[playerid][pKey] == 0)
{
if(autokauf[i][VEHID]==GetPlayerVehicleID(playerid))
{
if(cpreis <= GetPlayerMoney(playerid))
{
GivePlayerMoney(playerid,-cpreis);
pAutoInfo[playerid][pAUTOPoS_X]=Autospawns[autohaus][pos_x];
pAutoInfo[playerid][pAUTOPoS_Y]=Autospawns[autohaus][pos_y];
pAutoInfo[playerid][pAUTOPoS_Z]=Autospawns[autohaus][pos_z];
pAutoInfo[playerid][pAUTOPoS_A]=Autospawns[autohaus][z_angle];
pAutoInfo[playerid][Preis]=cpreis;
pAutoInfo[playerid][ModelID]=autokauf[i][ModelID];
pAutoInfo[playerid][pKey]=1;
pAutoInfo[playerid][Carid] = AddStaticVehicle(pAutoInfo[playerid][ModelID],pAutoInfo[playerid][pAUTOPoS_X],pAutoInfo[playerid][pAUTOPoS_Y],pAutoInfo[playerid][pAUTOPoS_Z],pAutoInfo[playerid][pAUTOPoS_A],-1,-1);
SendClientMessage(playerid, Gruen, "Mit /carlock kannst du dein Fahrzeug für andere Leute freigeben oder abschließen.");
SendClientMessage(playerid, Gelb, "Dein Auto steht am Ausgabepunkt bereit! Viel Spaß beim Fahren! Und Beachte die StVo!");
TogglePlayerControllable(playerid,1);
RemovePlayerFromVehicle(playerid);
CreateCar(playerid);
SaveAuto(playerid);
break;
}
else{SendClientMessage(playerid,Rot,str);}
}
}
else{SendClientMessage(playerid,Rot,"** Du besitzt doch schon ein Fahrzeug.");}
}
}
else{SendClientMessage(playerid,Rot,"Du bist in keinem Autohaus Auto!");}
return 1;
}
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
for(new i=0; i<sizeof(autokauf); i++)
{
new cpreis =autokauf[i][CarPreis];
new str[128];
format(str,sizeof(str),"Du besitzt zuwenig geld du benötigst %i", cpreis);
new autohaus=autokauf[i][Autohaus];
if(pAutoInfo[playerid][pKey] == 0)
{
if(autokauf[i][VEHID]==GetPlayerVehicleID(playerid))
{
if(cpreis <= GetPlayerMoney(playerid))
{
GivePlayerMoney(playerid,-cpreis);
pAutoInfo[playerid][pAUTOPoS_X]=Autospawns[autohaus][pos_x];
pAutoInfo[playerid][pAUTOPoS_Y]=Autospawns[autohaus][pos_y];
pAutoInfo[playerid][pAUTOPoS_Z]=Autospawns[autohaus][pos_z];
pAutoInfo[playerid][pAUTOPoS_A]=Autospawns[autohaus][z_angle];
pAutoInfo[playerid][Preis]=cpreis;
pAutoInfo[playerid][ModelID]=autokauf[i][ModelID];
pAutoInfo[playerid][pKey]=1;
pAutoInfo[playerid][Carid] = AddStaticVehicle(pAutoInfo[playerid][ModelID],pAutoInfo[playerid][pAUTOPoS_X],pAutoInfo[playerid][pAUTOPoS_Y],pAutoInfo[playerid][pAUTOPoS_Z],pAutoInfo[playerid][pAUTOPoS_A],-1,-1);
SendClientMessage(playerid, Gruen, "Mit /carlock kannst du dein Fahrzeug für andere Leute freigeben oder abschließen.");
SendClientMessage(playerid, Gelb, "Dein Auto steht am Ausgabepunkt bereit! Viel Spaß beim Fahren! Und Beachte die StVo!");
TogglePlayerControllable(playerid,1);
RemovePlayerFromVehicle(playerid);
CreateCar(playerid);
SaveAuto(playerid);
break;
}
else{SendClientMessage(playerid,Rot,str);}
}
}
else{SendClientMessage(playerid,Rot,"** Du besitzt doch schon ein Fahrzeug.");}
}
}
else{SendClientMessage(playerid,Rot,"Du bist in keinem Autohaus Auto!");}
return 1;
}
park:
ocmd:park(playerid, params[])
{
if(pAutoInfo[playerid][Carid]==GetPlayerVehicleID(playerid))
{
new Float:X,Float:Z,Float:Y,Float:A;
GetVehiclePos(pAutoInfo[playerid][Carid],X,Y,Z);
GetVehicleZAngle(pAutoInfo[playerid][Carid],A);
pAutoInfo[playerid][pAUTOPoS_X] = X;
pAutoInfo[playerid][pAUTOPoS_Y] = Y;
pAutoInfo[playerid][pAUTOPoS_Z] = Z;
pAutoInfo[playerid][pAUTOPoS_A] = A;
SendClientMessage(playerid, Gruen, "Fahrzeug geparkt!");
SaveAuto(playerid);
}else{SendClientMessage(playerid,Rot,"Dieses Fahrzeug gehört dir nicht!");}
return 1;
}
{
if(pAutoInfo[playerid][Carid]==GetPlayerVehicleID(playerid))
{
new Float:X,Float:Z,Float:Y,Float:A;
GetVehiclePos(pAutoInfo[playerid][Carid],X,Y,Z);
GetVehicleZAngle(pAutoInfo[playerid][Carid],A);
pAutoInfo[playerid][pAUTOPoS_X] = X;
pAutoInfo[playerid][pAUTOPoS_Y] = Y;
pAutoInfo[playerid][pAUTOPoS_Z] = Z;
pAutoInfo[playerid][pAUTOPoS_A] = A;
SendClientMessage(playerid, Gruen, "Fahrzeug geparkt!");
SaveAuto(playerid);
}else{SendClientMessage(playerid,Rot,"Dieses Fahrzeug gehört dir nicht!");}
return 1;
}
stock speichern und load:
stock CreateCar(playerid)
{
new query[256],Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
mysql_real_escape_string(Name,Name);
format(query, sizeof(query), "INSERT INTO `cars` (`Name`) VALUES ('%s')", Name);
mysql_query(query);
return true;
}
stock loadCar(playerid)
{
if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
{
if(GetPVarInt(playerid,"Eingeloggt") == 1)
{
GetPlayerName(playerid, pAutoInfo[playerid][sName], MAX_PLAYER_NAME);
pAutoInfo[playerid][pKey] = mysql_GetInt("cars", "Key", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][pAUTOPoS_X] = mysql_GetFloat("cars", "AutoX", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][pAUTOPoS_Y] = mysql_GetFloat("cars", "AutoY", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][pAUTOPoS_Z] = mysql_GetFloat("cars", "AutoZ", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][pAUTOPoS_A] = mysql_GetFloat("cars", "AutoA", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][ModelID] = mysql_GetInt("cars", "ModelID", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][Farbe1] = mysql_GetInt("cars", "cFarbe1", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][Farbe2] = mysql_GetInt("cars", "cFabe2", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][Preis] = mysql_GetInt("cars", "VKPreis", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][Carid] = CreateVehicle(pAutoInfo[playerid][ModelID],pAutoInfo[playerid][pAUTOPoS_X],pAutoInfo[playerid][pAUTOPoS_Y],pAutoInfo[playerid][pAUTOPoS_Z],pAutoInfo[playerid][pAUTOPoS_A],pAutoInfo[playerid][Farbe1],pAutoInfo[playerid][Farbe2],-1);
printf("--> The Vehicles from %s Loaded From MySQL", pAutoInfo[playerid][sName]);
}
}
return 1;
}
stock SaveAuto(playerid)
{
if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
{
if(GetPVarInt(playerid,"Eingeloggt") == 1)
{
GetPlayerName(playerid, pAutoInfo[playerid][sName], MAX_PLAYER_NAME);
mysql_SetInt("cars", "Key",pAutoInfo[playerid][pKey], "Name", pAutoInfo[playerid][sName]);
mysql_SetInt("cars","VKPreis",pAutoInfo[playerid][Preis], "Name", pAutoInfo[playerid][sName]);
mysql_SetInt("cars","ModelID",GetPlayerVehicleID(pAutoInfo[playerid][ModelID]), "Name",pAutoInfo[playerid][sName]);
GetPlayerName(playerid, pAutoInfo[playerid][sName], MAX_PLAYER_NAME);
mysql_SetFloat("cars", "AutoX",pAutoInfo[playerid][pAUTOPoS_X], "Name", pAutoInfo[playerid][sName]);
mysql_SetFloat("cars", "AutoY",pAutoInfo[playerid][pAUTOPoS_Y], "Name", pAutoInfo[playerid][sName]);
mysql_SetFloat("cars", "AutoZ",pAutoInfo[playerid][pAUTOPoS_Z], "Name", pAutoInfo[playerid][sName]);
mysql_SetFloat("cars", "AutoA",pAutoInfo[playerid][pAUTOPoS_A], "Name", pAutoInfo[playerid][sName]);
printf("--> The Vehicles from %s Save From MySQL", pAutoInfo[playerid][sName]);
}
}
return 1;
}
{
new query[256],Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
mysql_real_escape_string(Name,Name);
format(query, sizeof(query), "INSERT INTO `cars` (`Name`) VALUES ('%s')", Name);
mysql_query(query);
return true;
}
stock loadCar(playerid)
{
if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
{
if(GetPVarInt(playerid,"Eingeloggt") == 1)
{
GetPlayerName(playerid, pAutoInfo[playerid][sName], MAX_PLAYER_NAME);
pAutoInfo[playerid][pKey] = mysql_GetInt("cars", "Key", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][pAUTOPoS_X] = mysql_GetFloat("cars", "AutoX", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][pAUTOPoS_Y] = mysql_GetFloat("cars", "AutoY", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][pAUTOPoS_Z] = mysql_GetFloat("cars", "AutoZ", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][pAUTOPoS_A] = mysql_GetFloat("cars", "AutoA", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][ModelID] = mysql_GetInt("cars", "ModelID", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][Farbe1] = mysql_GetInt("cars", "cFarbe1", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][Farbe2] = mysql_GetInt("cars", "cFabe2", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][Preis] = mysql_GetInt("cars", "VKPreis", "Name", pAutoInfo[playerid][sName]);
pAutoInfo[playerid][Carid] = CreateVehicle(pAutoInfo[playerid][ModelID],pAutoInfo[playerid][pAUTOPoS_X],pAutoInfo[playerid][pAUTOPoS_Y],pAutoInfo[playerid][pAUTOPoS_Z],pAutoInfo[playerid][pAUTOPoS_A],pAutoInfo[playerid][Farbe1],pAutoInfo[playerid][Farbe2],-1);
printf("--> The Vehicles from %s Loaded From MySQL", pAutoInfo[playerid][sName]);
}
}
return 1;
}
stock SaveAuto(playerid)
{
if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
{
if(GetPVarInt(playerid,"Eingeloggt") == 1)
{
GetPlayerName(playerid, pAutoInfo[playerid][sName], MAX_PLAYER_NAME);
mysql_SetInt("cars", "Key",pAutoInfo[playerid][pKey], "Name", pAutoInfo[playerid][sName]);
mysql_SetInt("cars","VKPreis",pAutoInfo[playerid][Preis], "Name", pAutoInfo[playerid][sName]);
mysql_SetInt("cars","ModelID",GetPlayerVehicleID(pAutoInfo[playerid][ModelID]), "Name",pAutoInfo[playerid][sName]);
GetPlayerName(playerid, pAutoInfo[playerid][sName], MAX_PLAYER_NAME);
mysql_SetFloat("cars", "AutoX",pAutoInfo[playerid][pAUTOPoS_X], "Name", pAutoInfo[playerid][sName]);
mysql_SetFloat("cars", "AutoY",pAutoInfo[playerid][pAUTOPoS_Y], "Name", pAutoInfo[playerid][sName]);
mysql_SetFloat("cars", "AutoZ",pAutoInfo[playerid][pAUTOPoS_Z], "Name", pAutoInfo[playerid][sName]);
mysql_SetFloat("cars", "AutoA",pAutoInfo[playerid][pAUTOPoS_A], "Name", pAutoInfo[playerid][sName]);
printf("--> The Vehicles from %s Save From MySQL", pAutoInfo[playerid][sName]);
}
}
return 1;
}
Dank im vorraus.
mfg. Fabi.StaR