SA-MP Forums Archive
Matriculas xD - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: Matriculas xD (/showthread.php?tid=208470)



Matriculas xD - Pepot - 08.01.2011

Perdonen, como puedo hacer que ponga esto:

pawn Код:
for(new vehicles = 0; vehicles < MAX_VEHICLES; vehicles++)
{
new random1 = random(99), random2 = random(9), string[250];
format(string, 256, "GS %d-%d", random1,random2);
SetVehicleNumberPlate(vehicleid, string);
}
Y cuando reiniciemos el server las matriculas sigan siendo las mismas (y guardadas en un block)..
Ej: Abrimos el server con el cуdigo ese, y al abrirlo, que se guarden las matriculas, y apartir de hay cada vez que lo abramos tenga la 1ra matricula que se le puso, y se guarden en un block de notas (cfg, txt o ini)..

Ojala me ayuden, saludos!



Re: Matriculas xD - The_Moddler - 08.01.2011

fread, fwrite, fopen.


Respuesta: Matriculas xD - [M]xFire - 08.01.2011

pawn Код:
new File:vehiculos = fopen("vehiculos.txt", io_readwrite);
fwrite(vehiculos,matricula);
fclose(vehiculos);
pawn Код:
new File:vehiculos = fopen("vehiculos.txt", io_read);
    while(fread(vehiculos, string))
    {
        if(strcmp(string, "Ban", true) == 0)
        {
            SetVehicleNumberPlate....
            SetVehicleToRespawn...
        }
    }
    fclose(vehiculos);
Talvez asi te sirva


Respuesta: Matriculas xD - Pepot - 09.01.2011

Pero, їcуmo y donde lo pongo?

їAsi?:

pawn Код:
for(new vehicles = 0; vehicles < MAX_VEHICLES; vehicles++)
{
new File:vehiculos = fopen("vehiculos.txt", io_readwrite);
fwrite(vehiculos,matricula);
fclose(vehiculos);
//==================================================\\
new File:vehiculos = fopen("vehiculos.txt", io_read);
    while(fread(vehiculos, string))
    {
        if(strcmp(string, "Ban", true) == 0)
        {
            new random1 = random(99), random2 = random(9), string[250];
            format(string, 256, "GS %d-%d", random1,random2);
            SetVehicleNumberPlate(vehicleid, string);
        }
    }
    fclose(vehiculos);
  }



Respuesta: Matriculas xD - [M]xFire - 09.01.2011

OnGameModeInit
pawn Код:
for(new vid = 0; vid < MAX_VEHICLES; vid++;) {
    new file[20];
    format(file, sizeof(file), "/Autos/%d.ini", vid);
    if(!fexist(file))
    {
        dini_Create(file);
        new random1 = random(99), random2 = random(9), string[250];
        format(string, 256, "GS %d-%d", random1,random2);
        dini_Set(file, "Matricula", string);
    }
}
Despues de haber creado los autos(en OnGameModeInit):
pawn Код:
for(new vid = 0; vid < MAX_VEHICLES; vid++;) {
    new file[40];
    format(file, sizeof(file), "/Autos/%d.ini", vid);
    if(fexist(file)) {
        new matricula[10] = dini_Get(file, "Matricula);
        SetVehicleNumberPlate(vid, matricula);
   }
}
No le entendi a fread y eso, mejor lo hago en dini =D le entiendo mejor