MOTD doesn't save when a server restarts.
#1

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

Код:
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
Reply
#3

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


Forum Jump:


Users browsing this thread: 1 Guest(s)