MOTD doesn't save when a server restarts. - 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: MOTD doesn't save when a server restarts. (
/showthread.php?tid=592381)
MOTD doesn't save when a server restarts. -
rangerxxll - 24.10.2015
I have a MOTD that is changeable via /motd. However, when players connect - they see it. But when the server reloads, the MOTD is set to "MOTD" and appears as "[MOTD]: MOTD" in-game. It's a bit strange, tbh.
pawn Код:
enum sInfo
{
sMOTD[128]
}
#define SERVERPATH "Server/%s.ini"
new ServerInfo[sInfo];
forward LoadServer_data( name[], value[]);
public LoadServer_data( name[], value[] )
{
INI_String("MOTD", ServerInfo[sMOTD], 128);
return 1;
}
// under ongamemodeinit
//Loading MOTD
INI_ParseFile("Server/server.ini", "LoadServer_data", .bExtra = true, .extra = false);
CMD:motd(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 4) return SCM(pid, COLOR_GREY, ERROR);
new string[128], message[128];
if(sscanf(params,"s[128]", message)) return SCM(pid,COLOR_WHITE, "USAGE: /motd [message]");
format(string,sizeof(string), "%s", message);
ServerInfo[sMOTD] = string;
new INI:file = INI_Open("Server/server.ini");
INI_SetTag(file, "data");
INI_WriteString(file, "MOTD", string);
INI_Close(file);
SCM(pid,COLOR_GREEN, "You have successfully set the message of the day.");
return 1;
}
If anyone can spot out the issue as to why this isn't loading correctly, that'd be great. And as I mentioned - when the server gmx's, the MOTD is set to "MOTD" as if some INI_STRING parameters are wrong.
Re: MOTD doesn't save when a server restarts. -
Sabur - 24.10.2015
Код:
enum sInfo
{
sMOTD[128]
};
new ServerInfo[sInfo];
forward LoadServer_data(name[], value[]);
public LoadServer_data(name[], value[])
{
INI_String("MOTD", ServerInfo[sMOTD], 128);
return 1;
}
// under ongamemodeinit
//Loading MOTD
// it was wrong, now paste this.
INI_ParseFile("Server/server.ini", "LoadServer_data");
CMD:motd(playerid, params[])
{
new string[128], message[128];
if(PlayerInfo[playerid][pAdmin] < 4)
return SCM(pid, COLOR_GREY, ERROR);
if(sscanf(params, "s[128]", message))
return SCM(pid, COLOR_WHITE, "USAGE: /motd [message]");
ServerInfo[sMOTD] = message;
new INI:file = INI_Open("Server/server.ini");
INI_SetTag(file, "data");
INI_WriteString(file, "MOTD", message);
INI_Close(file);
format(string, sizeof(string), "You have set the MOTD to %s.", message);
SCM(pid, COLOR_GREEN, string);
return 1;
}
https://sampwiki.blast.hk/wiki/YSI:INI
Re: MOTD doesn't save when a server restarts. -
Smileys - 24.10.2015
Its been a long time since I used y_ini, but I dont believe you have to use parsefile for something like this, only when you dont know the filename etc in advance you should use parsefile.