Hallo Breadfish-Communty,
ich habe ein folgendes Problem und zwar hatte ich vor einen Fraktionsautohaus zu scripten und ich habe dabei ein folgendes Problem, das wenn ich es verkaufen (mit /fcarsell) verschwindet das Auto es ist auch in der Datenbank dann gespeichert man bekommt aber nicht die Hälfte des Preises...
Der Befehl lautet:
if(strcmp(cmdtext,"/lfa",true)==0){
if(GetPlayerAdminLevel(playerid) >= NEEDED_ADMINLEVEL){
for(new fc;fc<sizeof(FactionCars);fc++){
if(FactionCars[fc][fVehid] >= 400 && FactionCars[fc][fVehid] <= 611){
new Float:fX,Float:fY,Float:fZ;
GetVehiclePos(FactionCars[fc][fCarid],fX,fY,fZ);
if(IsPlayerInRangeOfPoint(playerid,4.0,fX,fY,fZ)){
FactionCars[fc][fVehid] = -255;
if(DestroyVehicle(FactionCars[fc][fCarid])){
FactionCars[fc][fCarid] = -255;
}return SendClientMessage(playerid,FACTION_COL_YELLOW,"Du hast das Fraktionsfahrzeug entfernt.");
}
}
}
}else SendClientMessage(playerid,FACTION_COL_GREY,"Du bist nicht berechtigt diesen Befehl anzuwenden.");
return true;
}
das dazugehöriges Enum:
enum fCar
{
fCarid,
fVehid,
Float:fPos[4],
fCol[2],
fFaction[5],
fTuning[14],
fPrice,
fCarArrest,
#if defined FACTION_CARS_LOCKABLE
bool:fLock
#endif
};
Forwards zum Abspeichern:
forward LoadFactionCars();
forward SaveFactionCars(bool:destroy);
forward LockFactionCarDoors();
forward DestroyAndCreateFactionCar(fc);
Hier die Speicherfunktion:
public LoadFactionCars(){
if(!fexist(FACTION_CAR_FILE)){
new File:tfFile=fopen(FACTION_CAR_FILE,io_write);
fclose(tfFile);
}
new File:fFile=fopen(FACTION_CAR_FILE,io_read),Content[1024],fc;
while(fread(fFile,Content) && fc<sizeof(FactionCars)){
StripNewLine(Content);
sscanf(Content,"dffffdddddddddddddddddddddd",
FactionCars[fc][fVehid],
FactionCars[fc][fPos][0],
FactionCars[fc][fPos][1],
FactionCars[fc][fPos][2],
FactionCars[fc][fPos][3],
FactionCars[fc][fCol][0],
FactionCars[fc][fCol][1],
FactionCars[fc][fFaction][0],
FactionCars[fc][fFaction][1],
FactionCars[fc][fFaction][2],
FactionCars[fc][fFaction][3],
FactionCars[fc][fFaction][4],
FactionCars[fc][fTuning][0],
FactionCars[fc][fTuning][1],
FactionCars[fc][fTuning][2],
FactionCars[fc][fTuning][3],
FactionCars[fc][fTuning][4],
FactionCars[fc][fTuning][5],
FactionCars[fc][fTuning][6],
FactionCars[fc][fTuning][7],
FactionCars[fc][fTuning][8],
FactionCars[fc][fTuning][9],
FactionCars[fc][fTuning][10],
FactionCars[fc][fTuning][11],
FactionCars[fc][fTuning][12],
FactionCars[fc][fTuning][13],
FactionCars[fc][fPrice]);
if(FactionCars[fc][fVehid] >= 400 && FactionCars[fc][fVehid] <= 611){
FactionCars[fc][fCarid] = CreateVehicle(FactionCars[fc][fVehid],FactionCars[fc][fPos][0],FactionCars[fc][fPos][1],FactionCars[fc][fPos][2],FactionCars[fc][fPos][3],FactionCars[fc][fCol][0],FactionCars[fc][fCol][1],-255);
#if defined FACTION_CARS_LOCKABLE
fLockCar(FactionCars[fc][fCarid]);
FactionCars[fc][fLock] = true;
#endif
#if defined FACTION_CARS_TUNEABLE
if(IsAllowedFactionToTune(FactionCars[fc][fFaction][0])){
if(FactionCars[fc][fTuning][0] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][0]); }
if(FactionCars[fc][fTuning][1] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][1]); }
if(FactionCars[fc][fTuning][2] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][2]); }
if(FactionCars[fc][fTuning][3] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][3]); }
if(FactionCars[fc][fTuning][4] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][4]); }
if(FactionCars[fc][fTuning][5] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][5]); }
if(FactionCars[fc][fTuning][6] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][6]); }
if(FactionCars[fc][fTuning][7] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][7]); }
if(FactionCars[fc][fTuning][8] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][8]); }
if(FactionCars[fc][fTuning][9] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][9]); }
if(FactionCars[fc][fTuning][10] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][10]); }
if(FactionCars[fc][fTuning][11] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][11]); }
if(FactionCars[fc][fTuning][12] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][12]); }
if(FactionCars[fc][fTuning][13] != 0) { AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][13]); }
}
#endif
fc++;
}
}fclose(fFile);
return printf(" '%d' Fraktionsfahrzeuge wurden geladen & erstellt.",fc);
}
public SaveFactionCars(bool:destroy){
if(fexist(FACTION_CAR_FILE)) fremove(FACTION_CAR_FILE);
new File:fFile=fopen(FACTION_CAR_FILE,io_append),Content[1024];
for(new fc;fc<sizeof(FactionCars);fc++){
if(FactionCars[fc][fVehid] >= 400 && FactionCars[fc][fVehid] <= 611){
format(Content,sizeof(Content),"%d %.3f %.3f %.3f %.3f %03d %03d %02d %02d %02d %02d %02d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\r\n",
FactionCars[fc][fVehid],
FactionCars[fc][fPos][0],
FactionCars[fc][fPos][1],
FactionCars[fc][fPos][2],
FactionCars[fc][fPos][3],
FactionCars[fc][fCol][0],
FactionCars[fc][fCol][1],
FactionCars[fc][fFaction][0],
FactionCars[fc][fFaction][1],
FactionCars[fc][fFaction][2],
FactionCars[fc][fFaction][3],
FactionCars[fc][fFaction][4],
FactionCars[fc][fTuning][0],
FactionCars[fc][fTuning][1],
FactionCars[fc][fTuning][2],
FactionCars[fc][fTuning][3],
FactionCars[fc][fTuning][4],
FactionCars[fc][fTuning][5],
FactionCars[fc][fTuning][6],
FactionCars[fc][fTuning][7],
FactionCars[fc][fTuning][8],
FactionCars[fc][fTuning][9],
FactionCars[fc][fTuning][10],
FactionCars[fc][fTuning][11],
FactionCars[fc][fTuning][12],
FactionCars[fc][fTuning][13],
FactionCars[fc][fPrice]);
fwrite(fFile,Content);
if(destroy == true){
if(DestroyVehicle(FactionCars[fc][fCarid]))
FactionCars[fc][fCarid] = -255;
}
}
}fclose(fFile);
return true;
}#
Ich bitte um Hilfe, wiegesagt ich möchte nur einstellen das man die hälfte zurückbekommt
Vielen Dank vorraus