
   /*********************************************************************
   **
   * amx_ejl_announce_admins.sma      version 1.5       February  22/2002
   *  By:  Eric Lidman    Alias: Ludwig van       ejlmozart@hotmail.com
   *  Upgrade: http://lidmanmusic.com/cs/plugins.html
   *
   * This plugin announces admin's connect/disconnect from the server.
   *  When  an  admin  connects or disconnects, a csay hudmessage appears
   and
   *  a sound plays to all clients. Additionally, if the admin choses, he
   *  may  have  a  chat  triggerword  which  which  people  can play his
   entrance
   *  sound during the game (sank_sounds style). There are many options
   *  for  setup.  You  must  create a file called admin_announce.txt and
   place
   *  that file on your server in the ..addons/amx folder. This is where
   *  you  set  up  your  admins  for this plugin. The format (a * before
   all):
   *
   *   *1 *2 *3 *4 *5 *6 *7 *8
   *
   *    1 = AUTHID OR WONID ( IF IS A LAN SERVER: USE IPADDRESS INSTEAD )
   *    2 = OPTION FLAGS A-E (See below)
   *    3 = CONNECT SOUND FILE NAME
   *    4 = CHAT TRIGGER WORD FOR CONNECT SOUND
   *    5 = DISCONNECT SOUND FILE NAME
   *    6 = CHAT TRIGGER WORD FOR DISCONNECT SOUND
   *    7 = OPTIONAL CUSTOM CONNECT MESSAGE
   *    8 = OPTIONAL CUSTOM DISCONNECT MESSAGE
   *
   *   Flags: abcde
   *    a = Show a hudmessage to clients on this admin's connect
   *    b = Show a hudmessage to clients on this admin's disconnect
   *    c = Play a sound on this admin's connect
   *    d = Play a sound on this admin's disconnect
   *    e = Allow a this admin's sound to be triggerd by key chat words
   *
   *  If no custom connect/disconnect message is specified for an admin,
   *   the  plugin  uses  a  default  message.  When  setting  the custom
   message,
   *   make sure to include the whole connect or disconnect message in
   *   quotes. Also, where the admin's name is to appear in the message,
   *   put "%s". To make a line break in the message, do "^n". Right
   *   after the opening quote, put a "*". In fact, a * must be attached
   *   to the begining of the first 6 arguments in the format. If there
   *   is no content to an argument, just place a lone *. The last two
   *   arguments, the custom connect/disconnect messages are optional.
   *   Do not place a star on those 7 and 8 arguments if you do not
   *   intend to use them. Added, you may use sounds from the PAK file
   *   too  such  as  the  vox  sounds,  you  may  even  string vox words
   together.
   *   If you are using pak file sounds, preceed the word with "**" (2
   *   stars). If you are putting together words to be said, put quotes
   *   around them.
   *
   *  Example of working lines from admin_announce.txt:
   *
   *  *67254 *abcde *misc/lud.wav *Ludwig * * "*Hey! Its^n%s" "*Bye^n%s"
   *  *243522 *abc *misc/vod.wav *Vodka *misc/bye.wav *bye
   *  *745432 *e *misc/trinot.wav *Trinot * * "*Look out^n%s^nis here"
   *  *12352 *abce "**i control you" *supra * *
   *  *6722214 *abce **scientist/c1a0_sci_catscream *alex * *
   *
   *  To get the custom sounds to your clients (as they will not hear
   *   anything if you do not give them the wavs), either use .res files
   *   or use the Plugin: Sounds Download Managment from the AMXMod site.
   *
   **********************************************************************
   /
   #include <amxmod>
   new AdminID[64][40]
   new AdminFlags[64][8]
   new AdminSoundI[64][40]
   new AdminTriggerI[64][32]
   new AdminSoundO[64][40]
   new AdminTriggerO[64][32]
   new AdminCustomSayI[64][64]
   new AdminCustomSayO[64][64]
   new TotalAdmins
   new Float:SndFreq1[33]
   new bool:isLan = false
   public plugin_init(){
       register_plugin("Announce Admins Entrance", "1.5", "EJL")
       register_clcmd("say","HandleSay")
       if(file_exists("addons/amx/admin_announce.txt") == 1){
           new line = 0
           new data[350]
           new stextsize = 0
           while((line=read_file("addons/amx/admin_announce.txt",line,dat
   a,349,stextsize))!=0){
               if(equal(data,"*",1)){
                   TotalAdmins += 1
                   if(TotalAdmins < 64){
                       parse(data,        AdminID[TotalAdmins],       39,
   AdminFlags[TotalAdmins],        7,        AdminSoundI[TotalAdmins],39,
   AdminTriggerI[TotalAdmins],31,

   AdminSoundO[TotalAdmins],31,AdminTriggerO[TotalAdmins],39,AdminCustomS
   ayI[TotalAdmins],63,AdminCustomSayO[TotalAdmins],63)
                   }
               }
           }
       }
       if(get_cvar_num("sv_lan") == 1)
           isLan = true
       return PLUGIN_CONTINUE
   }
   public client_connect(id){
       if(is_user_bot(id))
           return PLUGIN_CONTINUE
       SndFreq1[id] = -100.0
       new User[32]
       new AUTHID[40]
       if(isLan)
           get_user_ip(id,AUTHID,39,1)
       else
           get_user_authid(id,AUTHID,39)
       get_user_name(id,User,32)
       new Message[192]
       for(new i = 0; i < TotalAdmins+1; i++) {
           if(equal(AdminID[i][1],AUTHID)){
               if(read_flags(AdminFlags[i][1]) & 4){
                   if(equal(AdminSoundI[i][1],"*",1))
                       client_cmd(0,"spk ^"%s^"",AdminSoundI[i][2])
                   else
                       client_cmd(0,"play %s",AdminSoundI[i][1])
               }
               if(!(read_flags(AdminFlags[i][1]) & 1))
                   continue
               if(equal(AdminCustomSayI[i],"*",1)){
                   new linec = strlen(AdminCustomSayI[i]) / 6
                   if(linec > 10)
                       linec = 10
                   for(new a = 1; a < linec; a++)
                       replace(AdminCustomSayI[i],191,"^^n","^n")
                   format(Message,191,AdminCustomSayI[i][1],User)
               }else{
                   format(Message,191,"You      had      better     watch
   out!!^n%s^nhas entered the game!",User)
               }
               set_hudmessage(12,125,12,  -1.0, 0.20, 0, 0.02, 5.0, 1.01,
   1.1, 4)
               show_hudmessage(0,Message)
           }
       }
       return PLUGIN_CONTINUE
   }
   public client_disconnect(id){
       if(is_user_bot(id))
           return PLUGIN_CONTINUE
       SndFreq1[id] = -100.0
       new User[32]
       new AUTHID[40]
       if(isLan)
           get_user_ip(id,AUTHID,39,1)
       else
           get_user_authid(id,AUTHID,39)
       get_user_name(id,User,32)
       new Message[192]
       for(new i = 0; i < TotalAdmins+1; i++) {
           if(equal(AdminID[i][1],AUTHID)){
               if(read_flags(AdminFlags[i][1]) & 8){
                   if(equal(AdminSoundO[i][1],"*",1))
                       client_cmd(0,"spk ^"%s^"",AdminSoundO[i][2])
                   else
                       client_cmd(0,"play %s",AdminSoundO[i][1])
               }
               if(!(read_flags(AdminFlags[i][1]) & 2))
                   continue
               if(equal(AdminCustomSayO[i],"*",1)){
                   new linec = strlen(AdminCustomSayO[i]) / 6
                   if(linec > 10)
                       linec = 10
                   for(new a = 1; a < linec; a++)
                       replace(AdminCustomSayO[i],191,"^^n","^n")
                   format(Message,191,AdminCustomSayO[i][1],User)
               }else{
                   format(Message,191,"So sorry to say that^n%s^nhas left
   the game!",User)
               }
               set_hudmessage(12,125,12,  -1.0, 0.20, 0, 0.02, 5.0, 1.01,
   1.1, 4)
               show_hudmessage(0,Message)
           }
       }
       return PLUGIN_CONTINUE
   }
   QuotaCheck(UserIndex){
       new User[32]
       if (!(get_user_flags(UserIndex)&ADMIN_MAP)){
           new Float:CurTime = get_gametime()
           if (CurTime <= SndFreq1[UserIndex] + 60.0){
               get_user_name(UserIndex,User,31)
               client_print(UserIndex,print_chat,"[AMX]  Sounds  are fun,
   but not if you use them too fast, %s",User)
               SndFreq1[UserIndex] = CurTime
               return 1
           }
           SndFreq1[UserIndex] = CurTime
       }
       return 0
   }
   public HandleSay(id){
       new Speech[192]
       new User[32]
       get_user_name(id,User,32)
       read_args(Speech,192)
       remove_quotes(Speech)
       for(new i = 0; i < TotalAdmins+1; i++) {
           if(!(read_flags(AdminFlags[i][1]) & 16))
               continue
           if(  (equali(Speech,  AdminTriggerI[i][1])) && (strlen(Speech)
   !=0) ){
               if (!QuotaCheck(id)){
                   client_print(0,print_chat,"<PlaySound>   %s  :    %s",
   User, Speech)
                   if(equal(AdminSoundI[i][1],"*",1))
                       client_cmd(0,"spk ^"%s^"",AdminSoundI[i][2])
                   else
                       client_cmd(0,"play %s",AdminSoundI[i][1])
                   return PLUGIN_HANDLED
               }
           }
           else     if(    (equali(Speech,    AdminTriggerO[i][1]))    &&
   (strlen(Speech) !=0) ){
               if (!QuotaCheck(id)){
                   client_print(0,print_chat,"<PlaySound>   %s  :    %s",
   User, Speech)
                   if(equal(AdminSoundO[i][1],"*",1))
                       client_cmd(0,"spk ^"%s^"",AdminSoundO[i][2])
                   else
                       client_cmd(0,"play %s",AdminSoundO[i][1])
                   return PLUGIN_HANDLED
               }
           }
       }
       return PLUGIN_CONTINUE
   }
