Ich arbeite grade an meinen ersten Fiterscript, doch habe ich ein problem beim Filesystem.
Der File des Players ist nach dem Auslogen, also nach dem Update befehl, immer komplet leer.
Vielleicht weis einer woran das liegen könnte da alles andere geht einlogen etc.
public OnPlayerCarUpdate(playerid)
{
if(IsPlayerConnected(playerid))
{
if(Dtc_PlayerHaveCar[playerid])
{
DestroyVehicle(PlayerCar[playerid][CarId]);
new string3[128];
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
format(string3, sizeof(string3), "/DT_Cars/%s.dtcar", playername3);
new File: hFile = fopen(string3, io_write);
if (hFile)
{
new var[32];
format(var, 32, "CarId=%d\n",PlayerCar[playerid][CarId]);fwrite(hFile, var);
format(var, 32, "CarModel=%d\n",PlayerCar[playerid][CarModel]);fwrite(hFile, var);
format(var, 32, "CarPos_x=%.3f\n",PlayerCar[playerid][CarPos_x]);fwrite(hFile, var);
format(var, 32, "CarPos_y=%.3f\n",PlayerCar[playerid][CarPos_y]);fwrite(hFile, var);
format(var, 32, "CarPos_z=%.3f\n",PlayerCar[playerid][CarPos_z]);fwrite(hFile, var);
format(var, 32, "CarRotate=%.3f\n",PlayerCar[playerid][CarRotate]);fwrite(hFile, var);
format(var, 32, "CarNitro=%d\n",PlayerCar[playerid][CarNitro]);fwrite(hFile, var);
format(var, 32, "CarHyd=%d\n",PlayerCar[playerid][CarHyd]);fwrite(hFile, var);
format(var, 32, "CarWheel=%d\n",PlayerCar[playerid][CarWheel]);fwrite(hFile, var);
format(var, 32, "CarAusp=%d\n",PlayerCar[playerid][CarAusp]);fwrite(hFile, var);
format(var, 32, "CarSideL=%d\n",PlayerCar[playerid][CarSideL]);fwrite(hFile, var);
format(var, 32, "CarSideR=%d\n",PlayerCar[playerid][CarSideR]);fwrite(hFile, var);
format(var, 32, "CarFB=%d\n",PlayerCar[playerid][CarFB]);fwrite(hFile, var);
format(var, 32, "CarRB=%d\n",PlayerCar[playerid][CarRB]);fwrite(hFile, var);
format(var, 32, "CarSpoiler=%d\n",PlayerCar[playerid][CarSpoiler]);fwrite(hFile, var);
format(var, 32, "CarRoof=%d\n",PlayerCar[playerid][CarRoof]);fwrite(hFile, var);
format(var, 32, "CarHood=%d\n",PlayerCar[playerid][CarHood]);fwrite(hFile, var);
format(var, 32, "CarVents=%d\n",PlayerCar[playerid][CarVents]);fwrite(hFile, var);
format(var, 32, "CarLamps=%d\n",PlayerCar[playerid][CarLamps]);fwrite(hFile, var);
format(var, 32, "CarPJ=%d\n",PlayerCar[playerid][CarPJ]);fwrite(hFile, var);
format(var, 32, "CarC1=%d\n",PlayerCar[playerid][CarC1]);fwrite(hFile, var);
format(var, 32, "CarC2=%d\n",PlayerCar[playerid][CarC2]);fwrite(hFile, var);
format(var, 32, "Preis=%d\n",PlayerCar[playerid][CarPreis]);fwrite(hFile, var);
}
}
}
}
Und zum Vergleich hier die CarBuy Funktion.
public OnPlayerBuyCar(playerid,Model,Preis)
{
if(IsPlayerConnected(playerid) && !Dtc_PlayerHaveCar[playerid])
{
SetParkPlatz(playerid,Model);
new name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, sizeof name);
format(str, sizeof str, "/DT_Cars/%s.dtcar", name);
new File: hFile = fopen(str, io_write);
if (hFile)
{
new var[32];
format(var, 32, "CarId=0\n");fwrite(hFile, var);
format(var, 32, "CarModel=%d\n",Model);fwrite(hFile, var);
format(var, 32, "CarPos_x=%.3f\n",PlayerCar[playerid][CarPos_x]);fwrite(hFile, var);
format(var, 32, "CarPos_y=%.3f\n",PlayerCar[playerid][CarPos_y]);fwrite(hFile, var);
format(var, 32, "CarPos_z=%.3f\n",PlayerCar[playerid][CarPos_z]);fwrite(hFile, var);
format(var, 32, "CarRotate=%.3f\n",PlayerCar[playerid][CarRotate]);fwrite(hFile, var);
format(var, 32, "CarNitro=0\n");fwrite(hFile, var);
format(var, 32, "CarHyd=0\n");fwrite(hFile, var);
format(var, 32, "CarWheel=0\n");fwrite(hFile, var);
format(var, 32, "CarAusp=0\n");fwrite(hFile, var);
format(var, 32, "CarSideL=0\n");fwrite(hFile, var);
format(var, 32, "CarSideR=0\n");fwrite(hFile, var);
format(var, 32, "CarFB=0\n");fwrite(hFile, var);
format(var, 32, "CarRB=0\n");fwrite(hFile, var);
format(var, 32, "CarSpoiler=0\n");fwrite(hFile, var);
format(var, 32, "CarRoof=0\n");fwrite(hFile, var);
format(var, 32, "CarHood=0\n");fwrite(hFile, var);
format(var, 32, "CarVents=0\n");fwrite(hFile, var);
format(var, 32, "CarLamps=0\n");fwrite(hFile, var);
format(var, 32, "CarPJ=-1\n");fwrite(hFile, var);
format(var, 32, "CarC1=-1\n");fwrite(hFile, var);
format(var, 32, "CarC2=-1\n");fwrite(hFile, var);
format(var, 32, "Preis=%d\n",Preis);fwrite(hFile, var);
fclose(hFile);
}
OnPlayerCarLogin(playerid);
}
}
Erledigt habe fclose(hFile); bei onplayerupdate vergessen...