
   /* AMX Mod script.
   *
   * Message of the Day
   *  by JustinHoMi
   *
   */
   #include <amxmod>
   #include <amxmisc>
   #define MAX_MOTD 10
   new motdmsg[MAX_MOTD][128]
   new motdred[MAX_MOTD]
   new motdgreen[MAX_MOTD]
   new motdblue[MAX_MOTD]
   new Float:motdhold[MAX_MOTD]
   new mnum
   new cur
   public admin_motd(id,level,cid){
       if (!cmd_access(id,level,cid,4))
           return PLUGIN_HANDLED
       new color[12],sholdtime[4]
       read_argv(1,motdmsg[mnum],127)
       read_argv(2,color,9)
       read_argv(3,sholdtime,3)
       new hostname[64]
       get_cvar_string("hostname",hostname,63)
       replace(motdmsg[mnum],127,"%hostname%",hostname)
       while(replace(motdmsg[mnum],127,"\n","^n")){
           // do nothing
       }
       motdblue[mnum] = strtonum(color[6])
       color[6] = 0
       motdgreen[mnum] = strtonum(color[3])
       color[3] = 0
       motdred[mnum] = strtonum(color)
       motdhold[mnum] = floatstr(sholdtime)
       ++mnum
       console_print(id,"Loading motd %d ^"%s^"", mnum , motdmsg[mnum] )
       return PLUGIN_CONTINUE
   }
   public display_motd(){
       if  (  cur  >=  mnum  ) // if index reach end or current is higher
   (from prev. map) than max.
           cur = 0
       set_hudmessage(motdred[cur],  motdgreen[cur], motdblue[cur], -1.0,
   0.3, 0, 6.0,
           motdhold[cur], 0.5, 0.15, 4)
       show_hudmessage(0,motdmsg[cur])
       cur++ // go to next message
       return PLUGIN_CONTINUE
   }
   public init_motd() {
       new arg[8]
       get_localinfo("last_cmmotd",arg,7)
       cur = strtonum(arg)
       set_localinfo("last_cmmotd","")
       new Float:motdtime = get_cvar_float("amx_motdtime") * 60.0
       set_task(motdtime,"display_motd",1,"",0,"b")
       return PLUGIN_CONTINUE
   }
   public plugin_end(){
       new arg[8]
       numtostr(cur,arg,7)
       set_localinfo("last_cmmotd",arg)
       return PLUGIN_CONTINUE
   }
   public plugin_init(){
       register_plugin("MOTD","0.8","JustinHoMi")
       register_srvcmd("amx_motd","admin_motd",0,"<message> <RRRGGGBBB> <hold time>")
       register_cvar("amx_motdtime","10")
       set_task(5.0,"init_motd")
       return PLUGIN_CONTINUE
   }
