
   /* AMX Mod script.
   *
   * (c) Copyright 2002, OLO
   * This file is provided as is (no warranties).
   *
   */
   /* Displays MOTD with actual server state
   *  after puting to the server. */
   #include <amxmod>
   /* Some settings */
   #define SHOW_MODS             0
   #define READ_FROM_FILE     0
   #if READ_FROM_FILE == 1
       new motdfromfile[] = "addons/amx/conmotd.txt"
   #endif
   /* End of settings */
   new dmotd[2048]
   new dpos
   public plugin_init() {
       register_plugin("Dynamic MOTD","0.9.3","default")
       return PLUGIN_CONTINUE
   }
   public generate_motd(param[]) {
       new id = param[0]
       new name[32], authid[32], ip[32], hostname[64]
       new nextmap[32], time[64], mapname[32]
       get_cvar_string("hostname",hostname,63)
       get_user_name(id,name,31)
       get_user_authid(id,authid,31)
       get_user_ip(id,ip,31)
       get_time("Today is %A %B %d, %Y - %H:%M:%S",time,63)
       get_mapname(mapname,31)
       get_cvar_string("amx_nextmap",nextmap,31)

       dpos = 0
       dpos   =   format(dmotd[dpos],2047-dpos,  "Hello  %s,  welcome  to
   %s^n",name,hostname)
       dpos += format(dmotd[dpos],2047-dpos,"%s^n",time)
       dpos += format(dmotd[dpos],2047-dpos,"You are playing from %s with
   authid %s^n",ip,authid)

       dpos       +=      format(dmotd[dpos],2047-dpos,"^nPlayers      on
   server:  %d/%d^n",get_playersnum(),get_maxplayers())
       dpos  +=  format(dmotd[dpos],2047-dpos,"Played  map  is %s and the
   next will be %s^n",mapname,nextmap)

       // Time limit and time remaining
       new Float:mp_timelimit = get_cvar_float("mp_timelimit")
       if (mp_timelimit){
           new timeleft = get_timeleft()
           if (timeleft > 0)
               dpos   +=   format(dmotd[dpos],2047-dpos,"Time   Remaining
   %d:%02d of %.0f minutes^n",timeleft / 60, timeleft % 60,mp_timelimit)
       }
       else
           dpos   +=   format(dmotd[dpos],2047-dpos,"There   is  no  time
   limit^n")
       dpos  +=  format(dmotd[dpos],2047-dpos,"Friendly  fire  is  %s^n",
   get_cvar_float("mp_friendlyfire") ? "ON" : "OFF")
       dpos  +=  format(dmotd[dpos],2047-dpos,"C4  timer  is  set to %.0f
   sec.^n",get_cvar_float("mp_c4timer"))

       // Info. about privileges and amx_help command
       new flags = get_user_flags(id)
       if (flags){
           new sflags[32]
           get_flags(flags,sflags,31)
           dpos  +=  format(dmotd[dpos],2047-dpos,"^nYour access is %s %s
   immunity^n",
               sflags,(flags&ADMIN_IMMUNITY)?"with":"without")
       }
       else {
           dpos  += format(dmotd[dpos],2047-dpos,"^nYou are not logged as
   admin or user with privileges^n")
       }
       dpos   +=  format(dmotd[dpos],2047-dpos,"Type  'amx_help'  in  the
   console to see available commands^n")

       // Server Mods
   #if SHOW_MODS == 1
       new mod_ver[32]
       dpos += format(dmotd[dpos],2047-dpos, "^nServer mods:^n")
       get_cvar_string("amx_version",mod_ver,31)
       if  (mod_ver[0])      dpos  += format(dmotd[dpos],2047-dpos,"* AMX
   Mod %s^n",mod_ver)
       get_cvar_string("statsme_version",mod_ver,31)
       if   (mod_ver[0])       dpos   +=  format(dmotd[dpos],2047-dpos,"*
   StatsMe %s^n",mod_ver)
       get_cvar_string("clanmod_version",mod_ver,31)
       if   (mod_ver[0])       dpos   +=  format(dmotd[dpos],2047-dpos,"*
   ClanMod %s^n",mod_ver)
       get_cvar_string("admin_mod_version",mod_ver,31)
       if   (mod_ver[0])       dpos   +=  format(dmotd[dpos],2047-dpos,"*
   AdminMod %s^n",mod_ver)
       get_cvar_string("chicken_version",mod_ver,31)
       if   (mod_ver[0])       dpos   +=  format(dmotd[dpos],2047-dpos,"*
   Chicken %s^n",mod_ver)
       get_cvar_string("csguard_version",mod_ver,31)
       if   (mod_ver[0])       dpos   +=  format(dmotd[dpos],2047-dpos,"*
   CSGuard %s^n",mod_ver)
       get_cvar_string("hlguard_version",mod_ver,31)
       if   (mod_ver[0])       dpos   +=  format(dmotd[dpos],2047-dpos,"*
   HLGuard %s^n",mod_ver)
       get_cvar_string("plbot_version",mod_ver,31)
       if  (mod_ver[0])     dpos += format(dmotd[dpos],2047-dpos,"* PLBot
   %s^n",mod_ver)
       get_cvar_string("booster_version",mod_ver,31)
       if   (mod_ver[0])       dpos   +=  format(dmotd[dpos],2047-dpos,"*
   HL-Booster %s^n",mod_ver)
       get_cvar_string("axn_version",mod_ver,31)
       if  (mod_ver[0])    dpos  +=  format(dmotd[dpos],2047-dpos,"*  AXN
   %s^n",mod_ver)
       get_cvar_string("bmx_version",mod_ver,31)
       if  (mod_ver[0])      dpos  += format(dmotd[dpos],2047-dpos,"* BMX
   %s^n",mod_ver)
       get_cvar_string("atac_version",mod_ver,31)
       if  (mod_ver[0])      dpos += format(dmotd[dpos],2047-dpos,"* ATAC
   %s^n",mod_ver)
   #endif
     // Info. from custom file
   #if READ_FROM_FILE == 1
       if (file_exists(motdfromfile)) {
           new message[192], len, line = 0
           dpos += format(dmotd[dpos],2047-dpos, "----------^n")
           while(read_file(motdfromfile,line++,message,191,len))
                   dpos += format(dmotd[dpos],2047-dpos,"%s^n",message)
       }
   #endif
       show_motd(id,dmotd,hostname)
       return PLUGIN_CONTINUE
   }
   public client_putinserver(id){
       new param[2]
       param[0] = id
       set_task(0.5,"generate_motd",0,param,1)
       return PLUGIN_CONTINUE
   }
