SA-MP Forums Archive
Server info in file? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Server info in file? (/showthread.php?tid=581212)



Server info in file? - Mouiz - 11.07.2015

How to save this server info in file?

Код:
enum sAcc
{
    Announce,
	ReadPms,
	MaxPing,
	ReadCmds,
	AutoLog,
	sLocked,
	sPass[129],
	Chat,
	ReporterName[MAX_PLAYER_NAME],
	TargetName[MAX_PLAYER_NAME],
	Reason[128],
	Accountid,
	H,
	M,
	S
};



Re: Server info in file? - M4D - 11.07.2015

Use Y_INI


Re: Server info in file? - Mouiz - 11.07.2015

Quote:
Originally Posted by M4D
Посмотреть сообщение
Use Y_INI
I know i can use it,but i dont know how to use it,can you explain?


Re: Server info in file? - Mouiz - 11.07.2015

Quote:
Originally Posted by Mouiz
Посмотреть сообщение
I know i can use it,but i dont know how to use it,can you explain?
I just want to know that how to create a file and also in my account system,i used this Loaduser_data but what will i use for the serverinfo?

Код:
public LoadUser_data(playerid,name[],value[])
{
    ...
}



Re: Server info in file? - Threshold - 11.07.2015

https://sampforum.blast.hk/showthread.php?tid=570957

This will teach you how y_ini works.


Re: Server info in file? - M4D - 11.07.2015

ok i'll give you an example, but can you explain what is this system ?
its for players or global ?

and a Question.. why you don't use MySQL or SQLite ?



[Edit]: i got it .. please wait i'll give you an example


Re: Server info in file? - M4D - 11.07.2015

i explained code with comments ... read them

Код:
enum sAcc
{
    Announce,
	ReadPms,
	MaxPing,
	ReadCmds,
	AutoLog,
	sLocked,
	sPass[129],
	Chat,
	ReporterName[MAX_PLAYER_NAME],
	TargetName[MAX_PLAYER_NAME],
	Reason[128],
	Accountid,
	H,
	M,
	S
};

new YourVariable[sAcc]; //data will store in this variable

forward Load(name[], value[]); //>Loading Data function
public Load(name[], value[])
{
	INI_Int("Announce",YourVariable[Announce]); //Loading "Announce" value into "YourVariable[Announce]" as integer
	INI_Int("ReadPms",YourVariable[ReadPms]);
	INI_Int("MaxPing",YourVariable[MaxPing]);
	INI_Int("ReadCmds",YourVariable[ReadCmds]);
	INI_Int("AutoLog",YourVariable[AutoLog]);
	INI_Int("sLocked",YourVariable[sLocked]);
	INI_String("sPass",ServerInfo[sPass], 129);
	INI_Int("Chat",YourVariable[Chat]);
	INI_String("ReporterName",ServerInfo[ReporterName], 24);
	INI_String("TargetName",ServerInfo[TargetName], 24);
	INI_String("Reason",ServerInfo[Reason], 128);
	INI_Int("Accountid",YourVariable[Accountid]);
	INI_Int("H",YourVariable[H]);
	INI_Int("M",YourVariable[M]);
	INI_Int("S",YourVariable[S]);
    return 1;
}

//>When You Want load file data into variables, Use Following Function. for example, in OnGameModeInit

INI_ParseFile(/*Your File PATH Here*/, "Load", .bExtra = false, .extra = 0);

//>saving variables data into file is like player data saving...
//example:

new INI:File = INI_Open(/*Your PATH*/);
INI_SetTag(File, /*Your Tag*/);
INI_WriteInt(File,"Announce",ServerInfo[YourVariable[Announce]]);
//>and other things...
INI_Close(File);
it's like player data saving, just remove playerid parameter

i suggest you use MySQL to have an easier life


Re: Server info in file? - Mouiz - 11.07.2015

Quote:
Originally Posted by M4D
Посмотреть сообщение
i explained code with comments ... read them

Код:
enum sAcc
{
    Announce,
	ReadPms,
	MaxPing,
	ReadCmds,
	AutoLog,
	sLocked,
	sPass[129],
	Chat,
	ReporterName[MAX_PLAYER_NAME],
	TargetName[MAX_PLAYER_NAME],
	Reason[128],
	Accountid,
	H,
	M,
	S
};

new YourVariable[sAcc]; //data will store in this variable

forward Load(name[], value[]); //>Loading Data function
public Load(name[], value[])
{
	INI_Int("Announce",YourVariable[Announce]); //Loading "Announce" value into "YourVariable[Announce]" as integer
	INI_Int("ReadPms",YourVariable[ReadPms]);
	INI_Int("MaxPing",YourVariable[MaxPing]);
	INI_Int("ReadCmds",YourVariable[ReadCmds]);
	INI_Int("AutoLog",YourVariable[AutoLog]);
	INI_Int("sLocked",YourVariable[sLocked]);
	INI_String("sPass",ServerInfo[sPass], 129);
	INI_Int("Chat",YourVariable[Chat]);
	INI_String("ReporterName",ServerInfo[ReporterName], 24);
	INI_String("TargetName",ServerInfo[TargetName], 24);
	INI_String("Reason",ServerInfo[Reason], 128);
	INI_Int("Accountid",YourVariable[Accountid]);
	INI_Int("H",YourVariable[H]);
	INI_Int("M",YourVariable[M]);
	INI_Int("S",YourVariable[S]);
    return 1;
}

//>When You Want load file data into variables, Use Following Function. for example, in OnGameModeInit

INI_ParseFile(/*Your File PATH Here*/, "Load", .bExtra = false, .extra = 0);

//>saving variables data into file is like player data saving...
//example:

new INI:File = INI_Open(/*Your PATH*/);
INI_SetTag(File, /*Your Tag*/);
INI_WriteInt(File,"Announce",ServerInfo[YourVariable[Announce]]);
//>and other things...
INI_Close(File);
it's like player data saving, just remove playerid parameter

i suggest you use MySQL to have an easier life
Thanks,i understood it easily by your help