Matriculas xD
#1

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!
Reply
#2

fread, fwrite, fopen.
Reply
#3

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
Reply
#4

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);
  }
Reply
#5

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)