Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Someone please explain me this?

$
0
0
Hi,
how this two codes work?
Code:

LoadDealerships()
{
        new File:handle, count;
        new filename[64], line[256], s, key[64];
        for(new i=1; i < MAX_DEALERSHIPS; i++)
        {
                format(filename, sizeof(filename), DEALERSHIP_FILE_PATH "d%d.ini", i);
                if(!fexist(filename)) continue;
                handle = fopen(filename, io_read);
                while(fread(handle, line))
                {
                        StripNL(line);
                        s = strfind(line, "=");
                        if(!line[0] || s < 1) continue;
                        strmid(key, line, 0, s++);
                        if(strcmp(key, "Created") == 0) DealershipCreated[i] = strval(line[s]);
                        else if(strcmp(key, "Pos") == 0) sscanf(line[s], "p,fff", DealershipPos[i][0],
                                DealershipPos[i][1], DealershipPos[i][2]);
                }
                fclose(handle);
                if(DealershipCreated[i]) count++;
        }
        printf("  Loaded %d dealerships", count);
}

Code:

SaveDealership(dealerid)
{
        new filename[64], line[256];
        format(filename, sizeof(filename), DEALERSHIP_FILE_PATH "d%d.ini", dealerid);
        new File:handle = fopen(filename, io_write);
        format(line, sizeof(line), "Created=%d\r\n", DealershipCreated[dealerid]); fwrite(handle, line);
        format(line, sizeof(line), "Pos=%.3f,%.3f,%.3f\r\n", DealershipPos[dealerid][0],
                DealershipPos[dealerid][1], DealershipPos[dealerid][2]);
        fwrite(handle, line);
        fclose(handle);
}


Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>