13.02.2013, 14:55
Hola amigos, bueno tengo una duda.. sobre un Archivo, bueno.. os explicare bien y completamente para que me entendais y ver si pueden ayudarme mas facilmente.. bueno
Tengo Creado..
Lo siguiente:
Bueno, Tengo los dos primeros Forward en el CallBack OnPlayerConnect
Y en en el CallBack OnPlayerDisconnect los otros
Y los public..
Bueno, Supuestamente, Deberнa Guardar los archivos en scriptfiles en la carpeta Vehiculos/Auto1 y Auto2 Bueno, el archivo se crea pero de esta manera: '.car' Sin el Nombre del Usuario cosa que no se porque Si antes lo guardaba... En realidad no se que sucede o que interfiere їsera la nueva version y nuevos Includes? aunque no creo porque no cambia casi nada.. en los Includes... coloque un prinft en SaveCar1 para ver si salia el Error.. pero sale esto:
Espero me ayuden, porque no se que sucede :// Gracias de Antemano
Tengo Creado..
Lo siguiente:
pawn Код:
forward LoadCar1(playerid);
forward LoadCar2(playerid);
forward SaveCar1(playerid);
forward SaveCar2(playerid);
pawn Код:
public OnPlayerConnect(playerid)
{
LoadCar1(playerid);
LoadCar2(playerid);
return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid)
{
SaveCar1(playerid);
SaveCar2(playerid);
return 1;
}
pawn Код:
public LoadCar1(playerid)
{
/* Carga las variables del Auto #1 */
new dateiname[MAX_PLAYER_NAME+25], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
format(dateiname, sizeof(dateiname), "/Vehiculos/Auto1/%s.car", playername);
if (fexist(dateiname))
{
new File: CarFile = fopen(dateiname, io_read);
if ( CarFile )
{
new key[ 256 ], Data[ 256 ];
while ( fread( CarFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey(Data);
if(strcmp(key,"AH_Typ",true)==0) { Carlist[playerid][Typ] = strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_X",true)==0) { Carlist[playerid][PaX]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Y",true)==0) { Carlist[playerid][PaY]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Z",true)==0) { Carlist[playerid][PaZ]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Rot",true)==0) { Carlist[playerid][Rotation]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Status",true)==0) { Carlist[playerid][Status]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Lock",true)==0) { Carlist[playerid][Lock]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Color1",true)==0) { Carlist[playerid][Color1]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Color2",true)==0) { Carlist[playerid][Color2]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Nitro",true)==0) { Carlist[playerid][Nitro]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Hidraulica",true)==0) { Carlist[playerid][Hidraulica]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Spoiler",true)==0) { Carlist[playerid][Spoiler]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Ruedas",true)==0) { Carlist[playerid][Ruedas]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"FaldonDerecho",true)==0) { Carlist[playerid][FaldonDerecho]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Escape",true)==0) { Carlist[playerid][Escape]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Techo",true)==0) { Carlist[playerid][Techo]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"ParachoquesT",true)==0) { Carlist[playerid][ParachoquesT]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"ParachoquesD",true)==0) { Carlist[playerid][ParachoquesD]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Vinilo",true)==0) { Carlist[playerid][Vinilo]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Estereo",true)==0) { Carlist[playerid][Estereo]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"FaldonIzquierdo",true)==0) { Carlist[playerid][FaldonIzquierdo]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Bullbars",true)==0) { Carlist[playerid][Bullbars]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod14",true)==0) { Carlist[playerid][mod14]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod15",true)==0) { Carlist[playerid][mod15]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod16",true)==0) { Carlist[playerid][mod16]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod17",true)==0) { Carlist[playerid][mod17]=strval(ini_GetValue(Data)); }
}
}
fclose(CarFile);
if(Carlist[playerid][Typ]!=-1 && Carlist[playerid][Status]==1) { Carlist[playerid][Carid]=CreateTunedCar(playerid); }
}
SetTimerEx("DelaySetVehicleParams",10000,0,"i",playerid);
}
public LoadCar2(playerid)
{
/* Carga las variables del Auto #2 */
new Archivo[MAX_PLAYER_NAME+25], Usuario[MAX_PLAYER_NAME];
GetPlayerName(playerid, Usuario, sizeof(Usuario));
format(Archivo, sizeof(Archivo), "/Vehiculos/Auto2/%s.car2", Usuario);
if (fexist(Archivo))
{
new File: CarFile2 = fopen(Archivo, io_read);
if ( CarFile2 )
{
new key[ 256 ], Data[ 256 ];
while ( fread( CarFile2 , Data , sizeof( Data ) ) )
{
key = ini_GetKey(Data);
if(strcmp(key,"AH_Typ",true)==0) { Carlist2[playerid][Typ] = strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_X",true)==0) { Carlist2[playerid][PaX]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Y",true)==0) { Carlist2[playerid][PaY]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Z",true)==0) { Carlist2[playerid][PaZ]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Rot",true)==0) { Carlist2[playerid][Rotation]=floatstr(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Status",true)==0) { Carlist2[playerid][Status]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Lock",true)==0) { Carlist2[playerid][Lock]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Color1",true)==0) { Carlist2[playerid][Color1]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_Color2",true)==0) { Carlist2[playerid][Color2]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Nitro",true)==0) { Carlist2[playerid][Nitro]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Hidraulica",true)==0) { Carlist2[playerid][Hidraulica]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Spoiler",true)==0) { Carlist2[playerid][Spoiler]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Ruedas",true)==0) { Carlist2[playerid][Ruedas]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"FaldonDerecho",true)==0) { Carlist2[playerid][FaldonDerecho]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Escape",true)==0) { Carlist2[playerid][Escape]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Techo",true)==0) { Carlist2[playerid][Techo]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"ParachoquesT",true)==0) { Carlist2[playerid][ParachoquesT]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"ParachoquesD",true)==0) { Carlist2[playerid][ParachoquesD]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Vinilo",true)==0) { Carlist2[playerid][Vinilo]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Estereo",true)==0) { Carlist2[playerid][Estereo]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"FaldonIzquierdo",true)==0) { Carlist2[playerid][FaldonIzquierdo]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"Bullbars",true)==0) { Carlist2[playerid][Bullbars]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod14",true)==0) { Carlist2[playerid][mod14]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod15",true)==0) { Carlist2[playerid][mod15]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod16",true)==0) { Carlist2[playerid][mod16]=strval(ini_GetValue(Data)); }
else if(strcmp(key,"AH_mod17",true)==0) { Carlist2[playerid][mod17]=strval(ini_GetValue(Data)); }
}
}
fclose(CarFile2);
if(Carlist2[playerid][Typ]!=-1 && Carlist2[playerid][Status]==1) { Carlist2[playerid][Carid]=CreateTunedCarEx(playerid); }
}
SetTimerEx("DelaySetVehicleParamsEx",10000,0,"i",playerid);
}
public SaveCar1(playerid)
{
new dateiname[MAX_PLAYER_NAME+25], playername[MAX_PLAYER_NAME], var[256];
GetPlayerName(playerid, playername, sizeof(playername));
format(dateiname, sizeof(dateiname), "/Vehiculos/Auto1/%s.car", playername);
print(dateiname);
new File: CarFile = fopen(dateiname, io_write);
format(var, 256, "AH_Typ=%i\n", Carlist[playerid][Typ]); fwrite(CarFile, var);
format(var, 256, "AH_X=%f\n", Carlist[playerid][PaX]); fwrite(CarFile, var);
format(var, 256, "AH_Y=%f\n", Carlist[playerid][PaY]); fwrite(CarFile, var);
format(var, 256, "AH_Z=%f\n", Carlist[playerid][PaZ]); fwrite(CarFile, var);
format(var, 256, "AH_Rot=%f\n", Carlist[playerid][Rotation]); fwrite(CarFile, var);
format(var, 256, "AH_Status=%i\n", Carlist[playerid][Status]); fwrite(CarFile, var);
format(var, 256, "AH_Lock=%i\n", Carlist[playerid][Lock]); fwrite(CarFile, var);
format(var, 256, "AH_Color1=%i\n", Carlist[playerid][Color1]); fwrite(CarFile, var);
format(var, 256, "AH_Color2=%i\n", Carlist[playerid][Color2]); fwrite(CarFile, var);
format(var, 256, "Nitro=%i\n", Carlist[playerid][Nitro]); fwrite(CarFile, var);
format(var, 256, "Hidraulica=%i\n", Carlist[playerid][Hidraulica]); fwrite(CarFile, var);
format(var, 256, "Spoiler=%i\n", Carlist[playerid][Spoiler]); fwrite(CarFile, var);
format(var, 256, "Ruedas=%i\n", Carlist[playerid][Ruedas]); fwrite(CarFile, var);
format(var, 256, "FaldonDerecho=%i\n", Carlist[playerid][FaldonDerecho]); fwrite(CarFile, var);
format(var, 256, "Escape=%i\n", Carlist[playerid][Escape]); fwrite(CarFile, var);
format(var, 256, "Techo=%i\n", Carlist[playerid][Techo]); fwrite(CarFile, var);
format(var, 256, "ParachoquesT=%i\n", Carlist[playerid][ParachoquesT]); fwrite(CarFile, var);
format(var, 256, "ParachoquesD=%i\n", Carlist[playerid][ParachoquesD]); fwrite(CarFile, var);
format(var, 256, "Vinilo=%i\n", Carlist[playerid][Vinilo]); fwrite(CarFile, var);
format(var, 256, "Estereo=%i\n", Carlist[playerid][Estereo]); fwrite(CarFile, var);
format(var, 256, "FaldonIzquierdo=%i\n", Carlist[playerid][FaldonIzquierdo]); fwrite(CarFile, var);
format(var, 256, "Bullbars=%i\n", Carlist[playerid][Bullbars]); fwrite(CarFile, var);
format(var, 256, "AH_mod14=%i\n", Carlist[playerid][mod14]); fwrite(CarFile, var);
format(var, 256, "AH_mod15=%i\n", Carlist[playerid][mod15]); fwrite(CarFile, var);
format(var, 256, "AH_mod16=%i\n", Carlist[playerid][mod16]); fwrite(CarFile, var);
format(var, 256, "AH_mod17=%i\n", Carlist[playerid][mod17]); fwrite(CarFile, var);
fclose(CarFile);
if(Carlist[playerid][Carid]!=-1)
{
SetVehicleParamsForAll(Carlist[playerid][Carid],0,0);
DestroyVehicle(Carlist[playerid][Carid]);
Carlist[playerid][Carid]=-1;
}
}
public SaveCar2(playerid)
{
new NArchivo[MAX_PLAYER_NAME+25], Usuario[MAX_PLAYER_NAME], save[256];
GetPlayerName(playerid, Usuario, sizeof(Usuario));
format(NArchivo, sizeof(NArchivo), "/Vehiculos/Auto2/%s.car2", Usuario);
print(NArchivo);
new File: CarFile2 = fopen(NArchivo, io_write);
format(save, 256, "AH_Typ=%i\n", Carlist2[playerid][Typ]); fwrite(CarFile2, save);
format(save, 256, "AH_X=%f\n", Carlist2[playerid][PaX]); fwrite(CarFile2, save);
format(save, 256, "AH_Y=%f\n", Carlist2[playerid][PaY]); fwrite(CarFile2, save);
format(save, 256, "AH_Z=%f\n", Carlist2[playerid][PaZ]); fwrite(CarFile2, save);
format(save, 256, "AH_Rot=%f\n", Carlist2[playerid][Rotation]); fwrite(CarFile2, save);
format(save, 256, "AH_Status=%i\n", Carlist2[playerid][Status]); fwrite(CarFile2, save);
format(save, 256, "AH_Lock=%i\n", Carlist2[playerid][Lock]); fwrite(CarFile2, save);
format(save, 256, "AH_Color1=%i\n", Carlist2[playerid][Color1]); fwrite(CarFile2, save);
format(save, 256, "AH_Color2=%i\n", Carlist2[playerid][Color2]); fwrite(CarFile2, save);
format(save, 256, "Nitro=%i\n", Carlist2[playerid][Nitro]); fwrite(CarFile2, save);
format(save, 256, "Hidraulica=%i\n", Carlist2[playerid][Hidraulica]); fwrite(CarFile2, save);
format(save, 256, "Spoiler=%i\n", Carlist2[playerid][Spoiler]); fwrite(CarFile2, save);
format(save, 256, "Ruedas=%i\n", Carlist2[playerid][Ruedas]); fwrite(CarFile2, save);
format(save, 256, "FaldonDerecho=%i\n", Carlist2[playerid][FaldonDerecho]); fwrite(CarFile2, save);
format(save, 256, "Escape=%i\n", Carlist2[playerid][Escape]); fwrite(CarFile2, save);
format(save, 256, "Techo=%i\n", Carlist2[playerid][Techo]); fwrite(CarFile2, save);
format(save, 256, "ParachoquesT=%i\n", Carlist2[playerid][ParachoquesT]); fwrite(CarFile2, save);
format(save, 256, "ParachoquesD=%i\n", Carlist2[playerid][ParachoquesD]); fwrite(CarFile2, save);
format(save, 256, "Vinilo=%i\n", Carlist2[playerid][Vinilo]); fwrite(CarFile2, save);
format(save, 256, "Estereo=%i\n", Carlist2[playerid][Estereo]); fwrite(CarFile2, save);
format(save, 256, "FaldonIzquierdo=%i\n", Carlist2[playerid][FaldonIzquierdo]); fwrite(CarFile2, save);
format(save, 256, "Bullbars=%i\n", Carlist2[playerid][Bullbars]); fwrite(CarFile2, save);
format(save, 256, "AH_mod14=%i\n", Carlist2[playerid][mod14]); fwrite(CarFile2, save);
format(save, 256, "AH_mod15=%i\n", Carlist2[playerid][mod15]); fwrite(CarFile2, save);
format(save, 256, "AH_mod16=%i\n", Carlist2[playerid][mod16]); fwrite(CarFile2, save);
format(save, 256, "AH_mod17=%i\n", Carlist2[playerid][mod17]); fwrite(CarFile2, save);
fclose(CarFile2);
if(Carlist2[playerid][Carid]!=-1)
{
SetVehicleParamsForAll(Carlist2[playerid][Carid],0,0);
DestroyVehicle(Carlist2[playerid][Carid]);
Carlist2[playerid][Carid]=-1;
}
}
Espero me ayuden, porque no se que sucede :// Gracias de Antemano