Sistema de guardado y Cargado de autos
#1

Bien esto es lo que he hecho para mi sistema de compra de autos pero no se por que no se guardan aca lo que e hecho:

pawn Код:
forward Cargarv();

public Cargarv()
{

new float:xp,float:yp,float:zp,float:z_angle;


    new INI: file = INI_Open("Autos/Carros.cfg");
    new idx = DESDE;
    new playerid;

      if (file)
      {
      AutoInfo[DESDE][Modelo] = GetPlayerVehicleID(playerid);
      AutoInfo[DESDE][Posx] = xp;
      AutoInfo[DESDE][Posy] = yp;
      AutoInfo[DESDE][Posz] = zp;
      }

return 1;
}

forward GuardarC();

public GuardarC()
{

 new File: file3 = fopen("Autos/Carros.cfg", io_write);
 new float:xp,float:yp,float:zp,float:z_angle;
 new playerid;
 new coordsstring[256];
 new idx = DESDE;
 
 if (file3)
      {
      format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f\n",
      AutoInfo[DESDE][Modelo] = GetPlayerVehicleID(playerid),
      AutoInfo[DESDE][Posx] = xp,
      AutoInfo[DESDE][Posy] = yp,
      AutoInfo[DESDE][Posz] = zp);
      }
return Cargarv();
}
Y el comando

pawn Код:
zcmd(cv,playerid,params[])
    {
    DestroySelectionMenu(playerid);
       
        SetPVarInt(playerid, "vspawner_active", 1);
        //SetPVarInt(playerid, "vspawner_page", 0); // will reset the page back to the first
   
        CreateSelectionMenu(playerid);
        SelectTextDraw(playerid, 0xACCBF1FF);
    return 1;
    }
pawn Код:
SpawnVehicle_InfrontOfPlayer(playerid, vehiclemodel, color1, color2)
{
    new Float:x,Float:y,Float:z;
    new Float:facing;
    new Float:distance;

    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, facing);

    new Float:size_x,Float:size_y,Float:size_z;
    GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);
   
    distance = size_x + 0.5;

    x += (distance * floatsin(-facing, degrees));
    y += (distance * floatcos(-facing, degrees));

    facing += 90.0;
    if(facing > 360.0) facing -= 360.0;
    CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
   
    return GuardarC();
}
Alguien sabe por que no me guardan?
Reply
#2

De veras nadie sabe? :S
Reply
#3

їUsas mSelection? їo el selector por defecto?
Reply
#4

El selector por defecto, pero ese no es el problema el problema es que no se guardan los datos del auto.
Reply
#5

pawn Код:
public GuardarC()
{

 new File: file3 = fopen("Autos/Carros.cfg", io_append);
 new float:xp,float:yp,float:zp,float:z_angle;
 new playerid;
 new coordsstring[256];
 new idx = DESDE;
 
 if (file3)
      {
      format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f\n",
      AutoInfo[DESDE][Modelo] = GetPlayerVehicleID(playerid),
      AutoInfo[DESDE][Posx] = xp,
      AutoInfo[DESDE][Posy] = yp,
      AutoInfo[DESDE][Posz] = zp);
      fwrite(file3,coordsstring);
      }
      fclose(file3); //Siempre se cierra el archivo
return Cargarv();
}
Reply
#6

Excelente man pero los guarda en 0 osea todo se guarda en 0 xD las posiciones y todo se quedane n 0

Код:
0,0.000000,0.000000,0.000000
0,0.000000,0.000000,0.000000
0,0.000000,0.000000,0.000000
0,0.000000,0.000000,0.000000
0,0.000000,0.000000,0.000000
0,0.000000,0.000000,0.000000
0,0.000000,0.000000,0.000000
0,0.000000,0.000000,0.000000
Reply
#7

pawn Код:
public GuardarC()
{

 new File: file3 = fopen("Autos/Carros.cfg", io_append);
 new float:xp,float:yp,float:zp,float:z_angle;
 new veh = GetPlayerVehicleID(playerid);
 GetVehiclePos(veh, xp,yp,zp);
 GetVehicleZAngle(veh, z_angle);
 new playerid;
 new coordsstring[256];
 new idx = DESDE;
 
 if (file3)
      {
      format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f\n",
      AutoInfo[DESDE][Modelo] = veh,
      AutoInfo[DESDE][Posx] = xp,
      AutoInfo[DESDE][Posy] = yp,
      AutoInfo[DESDE][Posz] = zp);
      fwrite(file3,coordsstring);
      }
      fclose(file3); //Siempre se cierra el archivo
return Cargarv();
}
Reply
#8

Nada sigue guardandodo en 0 :S
Reply
#9

Quote:
Originally Posted by Daniel_Ruiz
Посмотреть сообщение
Nada sigue guardandodo en 0 :S
new veh = GetPlayerVehicleID(playerid);

new playerid? lol

Tiene que definir bien playerid de lo contrario no funcionarб.
Pon el parбmetro al callback y llбmala cuando lo necesites.
Reply
#10

Quote:
Originally Posted by GROVE22
Посмотреть сообщение
new veh = GetPlayerVehicleID(playerid);

new playerid? lol

Tiene que definir bien playerid de lo contrario no funcionarб.
Pon el parбmetro al callback y llбmala cuando lo necesites.
el playerid no lo estoy usando xD.

El problema es que me bota en 0,00000 todas las coordenadas
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)