diff --git a/plugins/welcomemsg.sma b/plugins/welcomemsg.sma index c563b68b..2363284e 100755 --- a/plugins/welcomemsg.sma +++ b/plugins/welcomemsg.sma @@ -9,6 +9,8 @@ #include #include +#define MOTD_LENGTH 1024 + // Settings (comment unwanted options) #define SHOW_MODS #define READ_FROM_FILE @@ -29,10 +31,20 @@ public plugin_init() #endif } -new g_Bar[] = "==============" +public plugin_cfg() +{ + set_cvar_string("motdfile","") +} -public client_connect(id) { - new name[32], hostname[64], nextmap[32], mapname[32] +public client_putinserver(id) { + new param[1] + param[0] = id + set_task(2.5,"alt_motd",0,param,1) +} + +public alt_motd(param[]) { + new id = param[0] + new motdBody[MOTD_LENGTH], name[32], hostname[64], nextmap[32], mapname[32] get_cvar_string("hostname",hostname,63) get_user_name(id,name,31) @@ -40,83 +52,84 @@ public client_connect(id) { get_mapname(mapname,31) get_cvar_string("amx_nextmap",nextmap,31) - client_cmd(id, "echo ;echo %s%s%s%s",g_Bar,g_Bar,g_Bar,g_Bar) - client_cmd(id, "echo ^" Hello %s, welcome to %s^"",name,hostname) + new len = copy(motdBody,MOTD_LENGTH,"") + len += format(motdBody[len],MOTD_LENGTH-len,"Hello %s, welcome to %s") // Server Mods #if defined SHOW_MODS new mod_ver[32] - client_cmd(id, "echo ;echo ^" Server mods:^"") + len += copy(motdBody[len],MOTD_LENGTH-len,"
Server mods:") #endif // Info. from custom file #if defined READ_FROM_FILE if (file_exists(g_motdFile)) { - new message[192], len, line = 0 - client_cmd(id, "echo %s%s%s%s",g_Bar,g_Bar,g_Bar,g_Bar) - while(read_file(g_motdFile,line++,message,191,len)) - client_cmd(id,"echo ^"%s^"",message) + new message[192], len2, line = 0 + len += format(motdBody[len],MOTD_LENGTH-len,"
") + while(read_file(g_motdFile,line++,message,191,len2)) + len += copy(motdBody[len],MOTD_LENGTH-len,message) } #endif - - client_cmd(id, "echo %s%s%s%s",g_Bar,g_Bar,g_Bar,g_Bar) + len += copy(motdBody[len],MOTD_LENGTH-len,"") + show_motd(id,motdBody) } \ No newline at end of file