Not for newbies (files)
#4

OK , so it is possible.I will try to make a quick script for you using Y_INI:
First we'll need this variable and define:
pawn Код:
#define MAX_FACTIONS 4 //Put the number of factions that you have
enum fInfo
{
 fLeader[MAX_PLAYER_NAME],
 fName[128],
 etc,
};
new FactionsInfo[MAX_FACTIONS][fInfo];
Ok , now when the leader changes you'll call this function:
pawn Код:
forward ChangeLeader(factionid,pname[]);
public ChangeLeader(factionid,pname[])
{
 format(FactionsInfo[factionid][fLeader],MAX_PLAYER_NAME,"%s",pname);
 new path[24]; format(path,24,"leaders.ini");
 new INI:File = INI_Open(path);
 INI_SetTag(File,"Leaders");
 if(factionid == 1) INI_WriteInt(File,"PD",FactionsInfo[factionid][fLeader]);
 else if(factionid == 2) INI_WriteInt(File,"FBI",FactionsInfo[factionid][fLeader]);
 else if(factionid == 3) INI_WriteInt(File,"NG",FactionsInfo[factionid][fLeader]);
 //Do this for every faction that you have
 INI_Close(File);
 return 1;
}
//Calling the public function on CMD:/makeleader [playerid] [ID of the faction]
ChangeLeader(1,playername); // 1 - ID of the faction; playername - Player's name;
Now to load the file:
pawn Код:
OnGameModeInit()
{
 new path[24];
 format(path,24,"leaders.ini");
 INI_ParseFile(path,"LoadFactions_%s");
}

forward LoadFactions_Leaders(name[],value[]);
public LoadFactions_Leaders(name[],value[])
{
 INI_String("PD",FactionsInfo[1][fLeader],MAX_PLAYER_NAME); // 1 - ID of PD faction
 INI_String("FBI",FactionsInfo[2][fLeader],MAX_PLAYER_NAME); // 2 - ID of FBI
 INI_String("NG",FactionsInfo[3][fLeader],MAX_PLAYER_NAME); // 3 - ID of N.G
 //etc
 return 1;
}
And now cmd:/leaders(I don't know if you're using ZMCD...)
pawn Код:
if(strcmp(cmd,"/leaders",true) == 0)
{
 new str[128];
 format(str,128,"PD: %s",FactionsInfo[1][fLeader]);
 SCM(playerid,0xFFFFFFFF,str);
 format(str,128,"FBI: %s",FactionsInfo[2][fLeader]);
 SCM(playerid,0xFFFFFFFF,str);
 format(str,128,"NG: %s",FactionsInfo[3][fLeader]);
 SCM(playerid,0xFFFFFFFF,str);
 return 1;
}
Not tested!
Reply


Messages In This Thread
Not for newbies (files) - by NeroX98 - 10.06.2013, 11:08
Re: Not for newbies (files) - by Vince - 10.06.2013, 11:25
Re: Not for newbies (files) - by NeroX98 - 10.06.2013, 11:33
Re: Not for newbies (files) - by Aly - 10.06.2013, 11:49

Forum Jump:


Users browsing this thread: 4 Guest(s)