Server info in file?
#1

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
};
Reply
#2

Use Y_INI
Reply
#3

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?
Reply
#4

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[])
{
    ...
}
Reply
#5

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

This will teach you how y_ini works.
Reply
#6

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
Reply
#7

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
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)