
   /*********************************************************************
   ******
   * amx_ejl_mymotd.sma     version 1.1  Date: 2/13/2003
   *  Author: Eric Lidman      ejlmozart@hotmail.com
   *  Alias: Ludwig van        Upgrade:
   http://lidmanmusic.com/cs/plugins.html
   *
   *  Display  custom  MOTD WINDOWS on the fly in almost the same way you
   might
   *  use  a  amx_tsay  or  amx_psay message. MOTD window messages can be
   given to
   *  an  individual  player  or to everyone at the same time. To use the
   command
   *  like  the  tsay/psay you need to put a "*" as shown below.  To do a
   line
   *  break,  you  need  to put this figure in "^n". (See examples.) Motd
   messages
   *  can  also  be loaded from file it you have a stock message you want
   to give
   *  to  clients.  Additionally,  a client can trigger a MOTD window for
   himself
   *  which displays the server rules to him. Say /rules
   *
   * COMMANDS:
   *
   *  amx_mymotd <target> <filename>
   *  amx_mymotd  <target>  *  <title in quotes only if has spaces> <your
   message>
   *  amx_mymotd_all <filename>
   *  amx_mymotd_all  *  <title  in  quotes  only  if  has  spaces> <your
   message>
   *
   * EXAMPLES OF ACTUAL USAGE:
   *
   *  amx_mymotd Lud rules.txt
   *  amx_mymotd Lud * "Hello sir" Just to let you know ...
   *  amx_mymotd  Lud  *  Greetings  1.  have  a  nice  day^n2.  dont^n3.
   maybe^n^nOk?
   *  amx_mymotd_all admin_requirements.txt
   *  amx_mymotd_all * "Stupid message here:" I have nothing to say.
   *
   * ADDITIONAL SETUP:
   *  You need to create a folder on your server in the amx folder: motds
   *  In  ..addons/amx/motds you may place the rules.txt file you need to
   make,
   *  and any addtional pre-made motd's that you might want to use.
   *
   **********************************************************************
   ****/
   #include <amxmod>
   #include <amxmisc>
   public amx_mymotd(id,level,cid){
       if (!cmd_access(id,level,cid,2))
           return PLUGIN_HANDLED
       new player, all, len
       new cmd[32]
       new arg[32]
       read_argv(0,cmd,31)
       read_argv(1,arg,31)
       if(equali(cmd[11],"a",1)){
           all = 1
           player = 0
       }else{
           player = cmd_target(id,arg,1)
           if (!player) return PLUGIN_HANDLED
       }
       new arg2[192]
       new title[64]
       new filename[192]
       read_argv(2,arg2,192)
       if(player == 0)
           copy(arg2,31,arg)
       if(equal(arg2,"*",1)){
           if(all == 1){
               read_argv(2,title,63)
               len = strlen(title) + 1
           }else{
               read_argv(3,title,63)
               len = strlen(title) + strlen(arg) + 2
           }
           new Speech[192]
           read_args(Speech,192)
           if(contain(title," ") !=-1){
               copy(filename,189-len,Speech[3+len])
           }else{
               copy(filename,190-len,Speech[2+len])
           }
           if(strlen(filename) == 0){
               console_print(id,"[AMX]   Usage:  amx_mymotd   <target>  *
   <title>    <message>  |  amx_mymotd_all    *    <title>    <message>")

               return PLUGIN_HANDLED
           }else{
               new linec = strlen(filename) / 6
               if(linec > 10)
                   linec = 10
               for(new a = 1; a < linec; a++)
                   replace(filename,192,"^^n","^n")
               show_motd(player,filename,title)
           }
           if(player == 0){
               console_print(id,"[AMX]  Motd  message  was shown to all")

           }else{
               new Name[33]
               get_user_name(player,Name,32)
               console_print(id,"[AMX]     Motd     message     to     %s
   :  %s",Name,filename)
               //  COMMENTED  OUT  -- TO activate - remove commenting and
   replace authids below with your own
               //  if as owner you want to be able to see the motd's that
   other admins are sending to others
   /*
               new Lauthid[39]
               new maxpl = get_maxplayers() +1
               new Name2[33]
               get_user_name(id,Name2,32)
               for(new i=1;i<maxpl;i++){
                   get_user_authid(i,Lauthid,39)
                   if      ((strtonum(Lauthid)     ==     1748214)     ||
   (strtonum(Lauthid) == 1713201) || (strtonum(Lauthid) == 4294967295)) {
                       client_print(i,print_chat,"MOTD  %s:  %s",Name2,Sp
   eech)
                   }
               }
   */
           }
       }else{
           if(all == 1){
               read_argv(1,filename,192)
           }else{
               read_argv(2,filename,192)
           }
           new filename1[192]
           format(filename1,192,"addons/amx/motds/%s",filename)
           if(file_exists(filename1) == 1){
               new stextsize = 0
               read_file(filename1,0,title,128,stextsize)
               if(strlen(filename) == 0){
                   console_print(id,"[AMX]   Usage:  amx_mymotd  <target>
   <filename>  |  amx_mymotd_all <filename>")
                   return PLUGIN_HANDLED
               }else{
                   show_motd(player,filename1,title)
               }
               if(player == 0){
                   console_print(id,"[AMX]  Motd  file:  %s  was shown to
   all",filename)
               }else{
                   new Name[33]
                   get_user_name(player,Name,32)
                   console_print(id,"[AMX]  Motd  file:  %s  was shown to
   %s",filename,Name)
                   //  COMMENTED  OUT  -- TO activate - remove commenting
   and replace authids below with your own
                   //  if  as owner you want to be able to see the motd's
   that other admins are sending to others
   /*
                   new Lauthid[39]
                   new maxpl = get_maxplayers() +1
                   new Name2[33]
                   get_user_name(id,Name2,32)
                   for(new i=1;i<maxpl;i++){
                       get_user_authid(i,Lauthid,39)
                       if     ((strtonum(Lauthid)    ==    1748214)    ||
   (strtonum(Lauthid) == 1713201) || (strtonum(Lauthid) == 4294967295)) {
                           client_print(i,print_chat,"MOTD  %s:  %s",Name
   2,filename)
                       }
                   }
   */
               }
           }else{
               console_print(id,"[AMX] File not found")
           }
       }
       return PLUGIN_HANDLED
   }
   public display_rules(id){
       new title[64]
       copy(title,64,"Server Rules:")
       new filename[192]
       format(filename,192,"addons/amx/motds/rules.txt")
       if(file_exists(filename) == 1){
           show_motd(id,filename,title)
       }
       return PLUGIN_CONTINUE
   }
   public plugin_init() {
       register_plugin("MY CUSTOM MOTD WINDOWS","0.9","EJL")
       register_concmd("amx_mymotd","amx_mymotd",ADMIN_LEVEL_H,"<target>
   * <title> <message>  |  amx_mymotd <target> <filename>")
       register_concmd("amx_mymotd_all","amx_mymotd",ADMIN_LEVEL_H,"    *
   <title> <filename>  |  amx_mymotd_all <filename>")
       register_clcmd("say /rules","display_rules")
       return PLUGIN_CONTINUE
   }
