26.11.2014, 22:22
Coming back from a lengthy break from coding, and I forgot a good portion of Y_Ini.
How would one create a dynamic MOTD for his server? I'll add the code I have managed to put together below.
Also, how would you use ini parsefile in this type of scenario when loading from a file?
Thank you for any help.
How would one create a dynamic MOTD for his server? I'll add the code I have managed to put together below.
Also, how would you use ini parsefile in this type of scenario when loading from a file?
pawn Код:
#define ServerPath "Server/%s.ini"
enum ServerInfo
{
sServerMessage[100]
};
new sInfo[ServerInfo];
//This is a very basic command I have created to create the actual file.
CMD:motdtest(playerid, params[])
{
new path[128];
format(path,sizeof(path), ServerPath);
if(fexist(path))
{
INI_ParseFile(path(server),"LoadServer_data", .bExtra = true, .extra = ?);
}
else
{
new INI:file = INI_Open(path);
INI_SetTag(file, "Server");
INI_WriteString(file, "ServerMessage", "Change me via /servermessage.");
INI_Close(file);
}
return 1;
}
public LoadServer_data(name[], value[])
{
INI_String("ServerMessage", sInfo[sServerMessage], 100);
return 1;
}