Not for newbies (files) -
NeroX98 - 10.06.2013
Hi !
I want to make an offline account checker without knowing his name... So example i want to make to show all leaders even if they are offline...
With this code i can check accounts on all
ONNLINE players:
pawn Код:
for(new i; i < MAX_PLAYERS; i++)
{
GetPlayerName(i, playername2, sizeof(playername2));
new File: UserFile = fopen(string2, io_read);
if (UserFile)
{
But how to check all
OFFLINE accounts ?!?!
Re: Not for newbies (files) -
Vince - 10.06.2013
Short answers: You cannot.
Long answer: It's possible, but it would be highly impractical due to the nature of file based systems and the extreme lag it would case. You should probably keep a separate files with names of leaders in there.
Problems like these are what SQL was invented for.
Re: Not for newbies (files) -
NeroX98 - 10.06.2013
Hehe thanks vince for the answer
REP +1
Re: Not for newbies (files) -
Aly - 10.06.2013
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!