Код:
CMD:deletefaction(playerid, params[])
{
if(pInfo[playerid][pLevel] >= 5)
{
new slot,fac = FacCount,string[120];
if(sscanf(params,"i",slot)) return SCM(playerid,COLOR_ORANGE,"USAGE: /deletefaction (faction id)");
if(slot == 0) return SCM(playerid,COLOR_RED,"Invalid ID!");
for(new i=0; i<MAX_FACTIONS; i++) if(slot == FactionInfo[i][FacSlots])
{
FacCount--;
format(hf,sizeof(hf),"Factions/%i.ini",fac);
if(fexist(hf))
{
fremove(hf);
}
format(string,sizeof(string),"You have deleted %s faction.",FactionInfo[i][FacName]);
SCM(playerid,COLOR_RED,string);
format(FactionInfo[i][FacName], 50,"NONE");
}
fdeleteline("Factions/Names.ini", slot);
}
return 1;
}
CMD:factions(playerid, params[])
{
new strings[128],File: file = fopen("Factions/Names.ini", io_read);
while(fread(file, strings))
{
format(strings, sizeof(strings), "[%d] %s.", fa, strings);
SendClientMessage(playerid, COLOR_YELLOW, strings);
}
fclose(file);
return 1;
}
CMD:createfaction(playerid, params[])
{
if(pInfo[playerid][pLevel] >= 5)
{
new id,name[50],fac = FacCount,File: file = fopen("Factions/Names.ini", io_append);
if(sscanf(params,"us[50]",id,name)) return SCM(playerid,COLOR_ORANGE,"USAGE: /createfaction (playerid) (faction name)");
if(fac >= MAX_FACTIONS) return SCM(playerid,COLOR_RED,"Max faction limit reached!");
if(pInfo[id][flevel] == 0)
{
format(FactionInfo[fac][FacName], 50, "%s", name);
format(FactionInfo[fac][FacOwner], 20, "%s", PN(id));
FactionInfo[fac][FacRanks] = 5;
FactionInfo[fac][FacLevels] = 10;
FactionInfo[fac][FacSlots] = FacCount;
pInfo[id][flevel] = 10;
pInfo[id][frank] = 5;
pInfo[id][fname] = name;
pInfo[id][pfacno] = FacCount;
SaveStatus(id);
new string2[120];
format(string2,sizeof(string2),"[%d.] %s.\r\n",fac,name);
fwrite(file, string2);
fclose(file);
format(hf,sizeof(hf),"Factions/%i.ini",fac);
new INI:fac2 = INI_Open(hf);
INI_WriteString(fac2,"Name",FactionInfo[fac][FacName]);
INI_WriteString(fac2,"Owner",FactionInfo[fac][FacOwner]);
INI_WriteInt(fac2,"Slot",FactionInfo[fac][FacSlots]);
INI_WriteInt(fac2,"Taken",FactionInfo[fac][FacTaken]);
INI_WriteInt(fac2,"Ranks",FactionInfo[fac][FacRanks]);
INI_WriteInt(fac2,"Levels",FactionInfo[fac][FacLevels]);
INI_Close(fac2);
new string[120];
format(string,sizeof(string),"You created a faction for %s with name %s.",PN(id),name);
SCM(playerid,COLOR_YELLOW,string);
format(string,sizeof(string),"Administrator %s has created a faction for you with name %s.",PN(playerid),name);
SCM(id,COLOR_YELLOW,string);
FacCount++;
}
}
return 1;
}