new FactionARanks[MAX_FACTIONS][13][32];
SaveFaction(factionid) { new filename[64], line[256]; format(filename, sizeof(filename), FACTION_FILE_PATH "f%d.ini", factionid); new File:handle = fopen(filename, io_write); for(new j = 0; j < 13; j++) { format(line, sizeof(line), "FactionSkins[%d]=%d\r\n", j+1 ,FacInfo[factionid][FactionSkins][j]); fwrite(handle, line); format(line, sizeof(line), "FactionARanks[%d]=%s\r\n", j+1 ,FactionARanks[factionid][j]); fwrite(handle, line); } fclose(handle); }
LoadFactions() { new File:handle, count; new filename[64], line[256], s, key[64]; for(new i=0; i < MAX_FACTIONS; i++) { format(filename, sizeof(filename), FACTION_FILE_PATH "f%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++); for(new j = 0; j < 13; j++) { if(strcmp(key, "FactionSkins") == 0) FacInfo[i][FactionSkins][j] = strval(line[s]); else if(strcmp(key, "FactionARanks") == 0) sscanf(line[s], "s[32]", FactionARanks[i][j]); } } fclose(handle); if(FacIDTaken[i]) count++; } printf(" Loaded %d factions", count); }
StripNL(line);
pawn Код:
|
for(new j = 0; j < 13; j++) { if(strcmp(key, "FactionSkins") == 0) FacInfo[i][FactionSkins][j] = strval(line[s]); else if(strcmp(key, "FactionARanks") == 0) sscanf(line[s], "s[32]", FactionARanks[i][j]);
else if(strcmp(key, "FactionARanks") == 0) sscanf(line[s], "s[32]", FactionARanks[i][j]);
// ** INCLUDES
#include <a_samp>
// ** MAIN
main()
{
print("Loaded \"get_values_in_file.amx\".");
new File:file, line[128], length_whitespace, length_equal, var[3], count;
file = fopen("get_values_in_file.ini", io_read);
while(fread(file, line))
{
length_whitespace = strfind(line, "\r\n", false);
if(length_whitespace != -1)
{
strdel(line, length_whitespace, (length_whitespace + 4));
}
length_equal = strfind(line, "=", false);
if(length_equal != -1)
{
strdel(line, 0, (length_equal + 2));
}
var[count] = strval(line);
printf("var[0] = %d", var[count]);
count ++;
}
fclose(file);
}
// ** CALLBACKS
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
var[0] = 10
var[1] = 20
var[2] = 50
var[0] = 10
var[0] = 20
var[0] = 50