
   /*********************************************************************
   *******
   * amx_ejl_hookmodcontrols.sma     version 1.9  Date: 2/21/2003
   *  Author: Eric Lidman      ejlmozart@hotmail.com
   *  Alias: Ludwig van        Upgrade:
   http://lidmanmusic.com/cs/plugins.html
   *
   *  If  you  have  hookmod  and want to give your admins the ability to
   contol it
   *  without  giving  them  RCON access or full cvar access, this plugin
   will be
   *  useful to you. Becasue the cvars are remebered from map to map, you
   will
   *  want  to  set all your default cvars for hookmod in your server.cfg
   so
   *  they will be reset on every map change to your desired defaults. If
   you
   *  are saying to yourself, "Huh? Hookmod?", check it out. Its so cool:
   *  http://www.adminop.net/modules.php?name=Downloads&d_op=viewdownload
   &cid=19
   *
   * PUBLIC COMMAND:
   *
   *  say  vote_hook        :  starts  a  vote to have hookmod enabled or
   disabled
   *
   * ADMIN COMMANDS:
   *
   *  amx_hookmod          :  toggles  hookmod  on  and off. Also if cvar
   mentioned
   *                         below    is    set    to    1,    it    also
   activates/deactivates
   *                         plugin  "out_of_bounds.amx" if you are using
   it
   *                         so  that  bounds limits are off when hook is
   on and
   *                         vice versa
   *  amx_hook_deployspeed : Contols how fast hook shoots
   *  amx_hook_speed       : controls how fast player is pulled
   *  amx_hook_ground      :  <0|1> controls if you can pulled toward the
   ground
   *  amx_hook_showspy     :  <0|1>  Controls  showing real team color on
   hook and
   *                         not disguised team color
   *  amx_hook_sound       : Controls the sound of the hook
   *  amx_hook_hold        :  Controls  how  many seconds you can stay on
   the hook
   *  amx_hook_sky         : <0|1> Controls hooking the sky
   *  amx_hook_players     : <0|1> Controls hooking onto players
   *  amx_hook_onlywalls   : <0|1> Controls hooking on to only walls
   *  amx_hook_color       : Controls hook color
   *  amx_hook_gravity     : Controls the hook's gravity as a multiple of
   the
   *                         current gravity
   *  amx_hook_mode        :  Controls  the hook's mode. 1 is launched, 2
   is
   *                         instant
   *  amx_hook_wait        : Controls how long in seconds a player has to
   wait
   *                         to use the hook again
   *  amx_hook_forcespeed  : Controls a forces speed of the hook
   *  amx_hook_width       : Controls the width of the hook
   *  amx_hook_noise       : Controls the noise of the hook, higher value
   is a
   *                         more static look
   *  amx_hook_count       : <# of hooks allowed per player round>
   *  amx_hookvote         :  toggles on/off ability for players to start
   votes
   *                         the default setting is on
   *  amx_hookvote_default  :  sets  the  current gunvote value as server
   default
   *                         auto-refreshed    at    every   map   change
   ADMIN_RCON
   *                         required to set server default
   *  stopvote             : stops vote in progress
   *
   * AMX CVARS:
   *
   *  amx_hb_pl_kill    --  If  you are running my "out_of_bounds" plugin
   you may
   *                       want  it disabled when you have the hook fully
   enabled
   *                       mening  DF_hook_wait  is  0.05. By default, if
   hook wait
   *                       is   0.05,   the   "out_of_bounds"  plugin  is
   disabled. If you
   *                       want  this  plugin  to  leave  "out_of_bounds"
   alone, then
   *                       set this cvar to 0 in your admin.cfg.
   *  amx_hvote_delay   --  Default  180.0 seconds. Delay between hookmod
   votes
   *                       allowed started by a non admin
   *  amx_hook_atspawn  --  Default  is 0 to enforce a 15 second delay on
   hooking
   *                       at   round   start  so  as  to  prevent  spawn
   massacres. Set
   *                       to one to ignore the delay.
   *  amx_hook_no_vip   -- default is 1 to not allow vip to use hook. Set
   that
   *                       cvar to 0 to allow free vip hooking
   *  amx_hooks_round   --  This  is number of times a player may use the
   hook each
   *                       round. Default is 100. I would suggest setting
   to 2 or
   *                       3  per  round  to encourage strategic usage of
   the hook
   *                       rather than just having it be total craziness.
   *  amx_rep_hcount    --  Switch to report number of hooks remaining in
   a round
   *                       to  a  player  if  that  numver drops to 10 or
   less. By
   *                       default  its  on  1, set to 0 to turn off this
   report.
   *
   **********************************************************************
   ********/
   #include <amxmod>
   #include <amxmisc>
   new ob_pl1,ob_pl2
   new vault_value[128]
   new votenumber = 0
   new votecontroller[33][2]
   new option[4]
   new Float:vote_ratio
   new st_vote = 0
   new totalvoters = 0
   new bool:bVoteToStop = false
   new bool:hvote_deny = false
   new bool:bHookvote = true
   new Float:hook_wc
   new round_st
   new IsVip[33]
   new HookCount[33]
   new restrict_override
   public amx_hc(id,level,cid){
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       new command[60]
       new variable[6]
       new name[32]
       get_user_name(id,name,31)
       read_argv(0,command,59)
       read_argv(1,variable,5)
       if(equali(command,"amx_hookmod")){
           if(get_cvar_float("DF_hook_wait") == 0.05){
               set_cvar_string("DF_hook_wait","10000.0")
               hook_wc = 10000.0
               client_print(id,print_console,"[AMX]   %s   has  been  set
   turned OFF",command)
               server_print("[AMX] %s has been set turned OFF",command)
               switch(get_cvar_num("amx_show_activity"))    {
                   case     2:    client_print(0,print_chat,"ADMIN    %s:
   Executed %s OFF",name,command)
                   case  1:    client_print(0,print_chat,"ADMIN: Executed
   %s OFF",command)
               }
               if(get_cvar_num("amx_hb_pl_kill") == 1){
                   if(ob_pl1 == 1){
                       unpause("ac","amx_ejl_outofbounds.amx")
                       log_message("[AMX] Plugin: amx_ejl_outofbounds.amx
   has been re-activated since DF_hook_wait is 0.05")
                   }
                   if(ob_pl2 == 1){
                       unpause("ac","out_of_bounds.amx")
                       log_message("[AMX]  Plugin:  out_of_bounds.amx has
   been re-activated since DF_hook_wait is 0.05")
                   }
               }
           }else{
               set_cvar_string("DF_hook_wait","0.05")
               hook_wc = 0.05
               client_print(id,print_console,"[AMX]   %s   has  been  set
   turned ON.",command)
               server_print("[AMX] %s has been set turned ON.",command)
               switch(get_cvar_num("amx_show_activity"))    {
                   case     2:    client_print(0,print_chat,"ADMIN    %s:
   Executed %s ON",name,command)
                   case  1:    client_print(0,print_chat,"ADMIN: Executed
   %s ON",command)
               }
               if(get_cvar_num("amx_hb_pl_kill") == 1){
                   if(ob_pl1 == 1){
                       pause("ac","amx_ejl_outofbounds.amx")
                       log_message("[AMX] Plugin: amx_ejl_outofbounds.amx
   has been deactivated since DF_hook_wait is not 0.05")
                   }
                   if(ob_pl2 == 1){
                       pause("ac","out_of_bounds.amx")
                       log_message("[AMX]  Plugin:  out_of_bounds.amx has
   been deactivated since DF_hook_wait is not 0.05")
                   }
               }
           }
           return PLUGIN_HANDLED
       }
       new argc = read_argc()
       if (argc == 2) {
           switch(get_cvar_num("amx_show_activity"))    {
               case  2:    client_print(0,print_chat,"ADMIN  %s: Executed
   %s %s",name,command,variable)
               case  1:    client_print(0,print_chat,"ADMIN:  Executed %s
   %s",command,variable)
           }
           format(command,70,"DF_%s",command[4])
           set_cvar_string(command,variable)
           client_print(id,print_console,"[AMX]   %s   has  been  set  to
   %s",command,variable)
       }else if (argc == 1) {
           format(command,70,"DF_%s",command[4])
           get_cvar_string(command,variable,5)
           client_print(id,print_console,"[AMX]    amx_%s   is   set   to
   %s",command[3],variable)
       }else {
           client_print(id,print_console,"[AMX]  Invalid  command  usage,
   re-enter command")
       }
       if(equali(command,"amx_hook_wait"))
           hook_wc = get_cvar_float("DF_hook_wait")
       return PLUGIN_HANDLED
   }
   public amx_hookvote(id,level,cid){
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       if(bHookvote == false) {
           bHookvote = true
           client_print(0,print_chat,"[AMX]  Admin has allowed players to
   initiate vote_hook")
           console_print(id,"[AMX]  You  have allowed players to initiate
   vote_hook")
       }else {
           bHookvote = false
           client_print(0,print_chat,"[AMX]  Admin  has forbidden players
   to initiate vote_hook")
           console_print(id,"[AMX]  You   have   forbidden   players   to
   initiate vote_hook")
       }
       if(id != 0){
       new authid[16],name[32]
       get_user_authid(id,authid,16)
       get_user_name(id,name,32)
       log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^"
   hookvote_mode",
           name,get_user_userid(id),authid)
       }
       return PLUGIN_HANDLED
   }
   public amx_hookvote_d(id,level,cid){
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       if(bHookvote == false){
           ejl_vault("WRITE","HOOK_VOTE","OFF")
           console_print(id,"[AMX]      Player      initiated     weapons
   voting  OFF   is now the default.")
       }else{
           ejl_vault("WRITE","HOOK_VOTE","ON")
           console_print(id,"[AMX]      Player      initiated     weapons
   voting  ON    is now the default.")
       }
       if(id != 0){
       new authid[16],name[32]
       get_user_authid(id,authid,16)
       get_user_name(id,name,32)
       log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^"
   hookvote_mode_d",
           name,get_user_userid(id),authid)
       }
       return PLUGIN_HANDLED
   }
   public admin_hook_count(id,level,cid){
       if (!cmd_access(id,level,cid,2))
           return PLUGIN_HANDLED
       new arg[8]
       read_argv(1,arg,7)
       if ((strtonum(arg) > 10000) || (strtonum(arg) < 1)){
           console_print(id,"[AMX]  Invalid  parameter.  Must be a number
   between 1 and 10000")
           return PLUGIN_HANDLED
       }
       new name[32]
       get_user_name(id,name,31)
       console_print(id,"[AMX] Hook count per round is now %s",arg)
       switch(get_cvar_num("amx_show_activity"))    {
           case   2:    client_print(0,print_chat,"ADMIN   %s:   Executed
   amx_hook_count %s",name,arg)
           case      1:    client_print(0,print_chat,"ADMIN:     Executed
   amx_hook_count %s",arg)
       }
       set_cvar_string("amx_hooks_round",arg)
       return PLUGIN_HANDLED
   }
   public HOOKVote(id) {
       if (round_st == 1){
           client_print(id,print_chat,"[AMX] Hook votes cannot be started
   during hook spawn delay.")
           return PLUGIN_HANDLED
       }
       if( (hvote_deny == true) && (!(get_user_flags(id)&ADMIN_MAP)) ){
           client_print(id,print_chat,"[AMX]  We  just  had  a hook vote.
   Wait a little longer.")
           return PLUGIN_HANDLED
       }
       if( (bHookvote == false) && (!(get_user_flags(id)&ADMIN_MAP)) ){
           client_print(id,print_chat,"[AMX]  Server  is set so that only
   admins can start this vote.")
           return PLUGIN_HANDLED
       }
       new Float:voting = get_cvar_float("amx_last_voting")
       if (voting > get_gametime()){
           client_print(id,print_chat,"There is already one voting...")
           return PLUGIN_HANDLED
       }
       if   (voting   &&   voting  +  get_cvar_float("amx_vote_delay")  >
   get_gametime()) {
           client_print(id,print_chat,"Voting not allowed at this time")
           return PLUGIN_HANDLED
       }
       new inprogress[32]
       get_cvar_string("amx_vote_inprogress",inprogress,32)
       if(equal(inprogress, "0",1)){
       new menu_msg[256]
       new keys
       format(menu_msg,256,"\yUse   HookMod?  \w^n^n1.  Yes,  I  want  to
   hook!^n2.  No, the hook is stupid!")
       keys = (1<<0)|(1<<1)
       new authid[16],name[32]
       get_user_authid(id,authid,16)
       get_user_name(id,name,32)
       log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" vote hook",
           name,get_user_userid(id),authid)
       new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
       set_cvar_float("amx_last_voting",  get_gametime() + vote_time )
       vote_ratio = get_cvar_float("amx_hookvote_ratio")
       for(new a = 0; a < 33; a++){
           votecontroller[a][1] = 0
       }
       votenumber++
       set_cvar_string("amx_vote_inprogress","1")
       ejl_vault("WRITE","CURRENT_VOTE","HOOKVOTE")
       bVoteToStop = true
       totalvoters = 0
       new Team[33]
       new maxpl = get_maxplayers()+1
       for(new k = 1; k < maxpl; k++){
           get_user_team(k,Team,33)
           if(!((equali(Team,"UNAS",4))   ||  (equali(Team,"SPEC",4))  ||
   (get_user_time(k)== 0) )){
               show_menu(k,keys,menu_msg,floatround(vote_time))
               totalvoters++
           }
       }
       set_task(vote_time,"HandleHOOKVote")
       client_print(id,print_console,"[AMX] Voting has started...")
       for(new j = 0; j < 4;++j) option[j] = 0
       }else{
       client_print(id,print_chat,"[AMX] Voting not allowed yet.")
       }
       return PLUGIN_HANDLED
   }
   public HandleHOOKVote() {
       set_hudmessage(63,187,239,  -1.0,  0.70, 2, 0.02, 10.0, 0.01, 0.1,
   2)
       hvote_deny = true
       set_task(get_cvar_float("amx_hvote_delay"),"hook_vote_deny")
       set_cvar_string("amx_vote_inprogress","0")
       ejl_vault("WRITE","CURRENT_VOTE","NULL")
       bVoteToStop = false
       for(new a = 0; a < 33; a++){
           votecontroller[a][1] = 0
       }
       if(st_vote == 1){
           st_vote = 0
           client_print(0,print_chat,"[AMX]  Voting           sucessfully
   stopped.")
           return PLUGIN_HANDLED
       }
       new best = 0
       new best_count = 0
       for(new a = 0; a < 4; ++a) {
           if (option[a] > best_count){
               best_count = option[a]
               best = a
           }
       }
       new inum = totalvoters
       new  Float:result_v = inum ? (float(option[best]) / float(inum)) :
   0.0
       if (result_v >= vote_ratio) {
           if(best == 0){
               client_print(0,print_chat,"[AMX]  Voing  over .... HookMod
   wins.")
               if(get_cvar_float("DF_hook_wait") == 0.05){
                   show_hudmessage(0,"Vote   over.^nHookMod   will   stay
   enabled.^n^n%d  votes  for  HookMod ON^n%d votes for HookMod OFF^n^n%d
   Total eligible voters",
                   option[0],option[1],totalvoters)
               } else {
                   if (round_st == 1){
                       client_print(0,print_chat,"[AMX]   Hookvote  wins.
   Full   results   hookmod   delayed   till  after  roundstart  time  is
   clear.")
                       set_task(15.0,"hook_vote_exec")
                   }else{
                       set_task(0.5,"hook_vote_exec")
                   }
               }
               log_to_file("addons/amx/admin.log","World        triggered
   ^"voting_success^"   (needed   ^"%.2f^")   (ratio   ^"%.2f^")  (result
   ^"hook^")",
                   vote_ratio,result_v)
           }else {
               client_print(0,print_chat,"[AMX]   Voting   over  ....  No
   HookMod.")
               if(get_cvar_float("DF_hook_wait") != 0.05){
                   show_hudmessage(0,"Vote   over.^nHookMod   will   stay
   disabled.^n^n%d  votes  for HookMod ON^n%d votes for HookMod OFF^n^n%d
   Total eligible voters",
                   option[0],option[1],totalvoters)
               } else {
                   show_hudmessage(0,"Vote  over.^nHookMod loses, no more
   hooks.^n^n%d  votes  for  HookMod  ON^n%d  votes for HookMod OFF^n^n%d
   Total eligible voters",
                   option[0],option[1],totalvoters)
                   set_cvar_string("DF_hook_wait","10000.0")
                   hook_wc = 10000.0
                   if(get_cvar_num("amx_hb_pl_kill") == 1){
                       if(ob_pl1 == 1){
                           unpause("ac","amx_ejl_outofbounds.amx")
                           log_message("[AMX]                     Plugin:
   amx_ejl_outofbounds.amx  has  been  re-activated since DF_hook_wait is
   0.05")
                       }
                       if(ob_pl2 == 1){
                           unpause("ac","out_of_bounds.amx")
                           log_message("[AMX]  Plugin:  out_of_bounds.amx
   has been re-activated since DF_hook_wait is 0.05")
                       }
                   }
               }
               log_to_file("addons/amx/admin.log","World        triggered
   ^"voting_failure^" (needed ^"%.2f^") (ratio ^"%.2f^")",
                   vote_ratio,result_v)
           }
       }else{
           client_print(0,print_chat,"[AMX]  Voting for hookmod failed...
   No clear majority.")
       }
       return PLUGIN_HANDLED
   }
   public hook_vote_exec(){
       set_hudmessage(63,187,239,  -1.0,  0.70, 2, 0.02, 10.0, 0.01, 0.1,
   2)
       show_hudmessage(0,"Vote  over.^nUse HookMod wins. Hook away!^n^n%d
   votes  for  HookMod  ON^n%d votes for HookMod OFF^n^n%d Total eligible
   voters",
       option[0],option[1],totalvoters)
       set_cvar_string("DF_hook_wait","0.05")
       hook_wc = 0.05
       if(get_cvar_num("amx_hb_pl_kill") == 1){
           if(ob_pl1 == 1){
               pause("ac","amx_ejl_outofbounds.amx")
               log_message("[AMX]   Plugin:  amx_ejl_outofbounds.amx  has
   been deactivated since DF_hook_wait is not 0.05")
           }
           if(ob_pl2 == 1){
               pause("ac","out_of_bounds.amx")
               log_message("[AMX]   Plugin:  out_of_bounds.amx  has  been
   deactivated since DF_hook_wait is not 0.05")
           }
       }
       return PLUGIN_CONTINUE
   }
   public HandleSay(id) {
       new Speech[192]
       read_args(Speech,192)
       remove_quotes(Speech)
       if (equal(Speech, "vote_hook")) {
           if (restrict_override == 1) {
               client_print(id,print_chat,"[AMX] Hook restrictions cannot
   be changed. Override is on.")
               return PLUGIN_HANDLED
           }
           HOOKVote(id)
       }
       else if( (restrict_override == 0) && (bHookvote == true) ){
           if(  (containi(Speech,  "hook")  !=  -1)  || (containi(Speech,
   "spider") != -1) || (containi(Speech, "swing") != -1) ){
               if(get_cvar_float("DF_hook_wait") == 0.05){
                   client_print(id,print_chat,     "[AMX]  HookMod     is
   enabled. To change say vote_hook     For help say /hook")
               }else{
                   client_print(id,print_chat,     "[AMX]  HookMod     is
   disabled. To change say vote_hook     For help say /hook")
               }
           }
       }
       return PLUGIN_CONTINUE
   }
   public vote_count(id,key)
   {
       ejl_vault("READ","CURRENT_VOTE","")
       if(equal(vault_value,"HOOKVOTE")){
       new name[32]
       get_user_name(id,name,32)
       if(votenumber != votecontroller[id][0]){
           votecontroller[id][0] = votenumber
           if (get_cvar_float("amx_vote_answers")) {
               client_print(0,print_chat,"[AMX]  %s  voted  for  option #
   %d",name,key+1)
           }
           option[key] += 1
       }else{
           votecontroller[id][1] +=1
       }
       }else{
           return PLUGIN_CONTINUE
       }
       return PLUGIN_HANDLED
   }
   public stopvote(id){
       if (!(get_user_flags(id)&ADMIN_MAP)){
           client_print(id,print_console,"[AMX]  You  have  no  access to
   that command")
           return PLUGIN_HANDLED
       }
       if(bVoteToStop == true){
           new name[32]
           get_user_name(id,name,32)
           st_vote = 1
           client_print(id,print_console,"[AMX]  ADMIN   !!!  Ignore  the
   unknown command message -- its ok")
           client_print(0,print_chat,"[AMX]  %s  has disabled the vote in
   progress.",name)
       }
       return PLUGIN_CONTINUE
   }
   public hook_vote_deny(){
       hvote_deny = false
       return PLUGIN_CONTINUE
   }
   public hook_spawn_delay(){
       if(round_st == 0) {
           round_st = 1
           if(get_cvar_num("amx_hook_atspawn") == 0){
               set_cvar_string("DF_hook_wait","1000.0")
               set_task(20.0,"roundstart_delay")
           }
           new maxplayers = get_maxplayers()+1
           for (new i=1; i<=maxplayers; i++) {
               HookCount[i] = 0
           }
       }
       return PLUGIN_CONTINUE
   }
   public roundstart_delay(){
       round_st = 0
       set_cvar_float("DF_hook_wait",hook_wc)
   }
   public client_connect(id){
       votecontroller[id][1] = 0
   }
   public client_disconnect(id){
       votecontroller[id][1] = 0
   }
   public mapbounds_killer(){
       hook_wc = get_cvar_float("DF_hook_wait")
       if(get_cvar_num("amx_hb_pl_kill") == 0)
           return PLUGIN_CONTINUE
       new nump = get_pluginsnum()
       new filename[64],name[64],version[32],author[32],status[32]
       for(new i=0;i<nump;++i){
           get_plugin(i,filename,63,name,63,version,31,author,31,status,3
   1)
           if(equali(filename,"amx_ejl_outofbounds.amx")){
               ob_pl1 = 1
               if(get_cvar_float("DF_hook_wait") == 0.05){
                   pause("ac","amx_ejl_outofbounds.amx")
                   log_message("[AMX] Plugin: amx_ejl_outofbounds.amx has
   been deactivated since DF_hook_wait is 0.05")
               }
           }
           else if(equali(filename,"out_of_bounds.amx")){
               ob_pl2 = 1
               if(get_cvar_float("DF_hook_wait") == 0.05){
                   pause("ac","out_of_bounds.amx")
                   log_message("[AMX]  Plugin: out_of_bounds.amx has been
   deactivated since DF_hook_wait is 0.05")
               }
           }
       }
       return PLUGIN_CONTINUE
   }
   public make_sure(id[]){
       client_cmd(id[0],"-hook")
       return PLUGIN_CONTINUE
   }
   public check_hookcommand(id){
       new hooks_round_cvar
       if(IsVip[id] == 1){
           client_print(id,print_chat,  "[AMX]  Hooking  by  the  vip  is
   prohibited.")
           set_user_health(id,get_user_health(id)-10)
           client_cmd(id,"-hook")
           new csid[1]
           csid[0] = id
           set_task(0.1,"make_sure",0,csid,1)
           return PLUGIN_HANDLED
       }
       else if(round_st == 1){
           set_cvar_string("DF_hook_wait","1000.0")
           client_print(id,print_chat,  "[AMX]  Hooking  during the first
   15 seconds of a round is prohibited.")
           client_cmd(id,"-hook")
           new csid[1]
           csid[0] = id
           set_task(0.1,"make_sure",0,csid,1)
           return PLUGIN_HANDLED
       }
       if( (is_user_alive(id) == 1) && (get_cvar_float("DF_hook_wait") ==
   0.05) ){
           HookCount[id] +=1
           hooks_round_cvar = get_cvar_num("amx_hooks_round")
           if(HookCount[id] > hooks_round_cvar){
               client_print(id,print_chat,  "[AMX]  You  are  all  out of
   hooks. Wait until next round or I hurt you.")
               set_user_health(id,get_user_health(id)-10)
               client_cmd(id,"-hook")
               new csid[1]
               csid[0] = id
               set_task(0.1,"make_sure",0,csid,1)
               return PLUGIN_HANDLED
           }else{
               if(     (get_cvar_num("amx_rep_hcount")     ==    1)    &&
   (hooks_round_cvar-HookCount[id] < 10) ){
                   if(hooks_round_cvar-HookCount[id] == 0)
                       client_print(id,print_chat,  "[AMX]  That was your
   last hook for this round.")
                   else
                       client_print(id,print_chat,  "[AMX]  You  have  %d
   hooks left, use them wisely.",hooks_round_cvar-HookCount[id])
               }
           }
       }
       return PLUGIN_CONTINUE
   }
   public vip_spawn(id){
       if(get_cvar_num("amx_hook_no_vip") == 1){
           new maxplayers = get_maxplayers()+1
           for (new i=1; i<=maxplayers; i++) {
               IsVip[i] = 0
           }
           new inum
           new players[32]
           get_players(players, inum ,"c")
           if(inum > 1){
               IsVip[id] = 1
           }
       }
       return PLUGIN_CONTINUE
   }
   public hook_motd(id){
       new hk_motd[1300]
       new temp[768]
       temp = "Bind a key to +hook. Go to your console, choose a key^n\
               for hooking. Lets say we want to use q. Do this:^n^n\
               bind q +hook^n^n\
               Enter  that  and  now  whenever  you  press  the q key, it
   launches^n\
               your  hook.  Make  sure  to  hold  the key down as long as
   you^n"
       add(hk_motd,1299,temp)
       temp  =  "want to be on the hook. Release the key when you want to
   get^n\
               off of the hook.^n^n\
               HookMod  has  to  be  enabled  for you to use the hook. If
   server^n\
               admin  allows  it,  you  may  say  vote_hook to get a hook
   vote^n\
               in   progress   to   enable   the   hook.   Under   normal
   circumstances^n"
       add(hk_motd,1299,temp)
       temp  =  "when  hookmod  is  enabled,  vip's  in CS cannot use the
   hook,^n\
               and  the  hook may not be used for the first 15 seconds of
   a^n\
               round in CS. Happy hooking!"
       add(hk_motd,1299,temp)
       show_motd(id,hk_motd,"HookMod Help:")
       return PLUGIN_CONTINUE
   }
   public plugin_init(){
       register_plugin("HookMod Admin Commands","0.9","EJL")
       register_concmd("amx_hookmod","amx_hc",ADMIN_LEVEL_H,":    toggles
   hookmod on and off")
       register_concmd("amx_hook_deployspeed","amx_hc",ADMIN_LEVEL_H,"150
   0 : Contols how fast hook shoots")
       register_concmd("amx_hook_speed","amx_hc",ADMIN_LEVEL_H,"1.5     :
   controls how fast player is pulled")
       register_concmd("amx_hook_ground","amx_hc",ADMIN_LEVEL_H,"<0|1>  :
   controls if you can pulled toward the ground")
       register_concmd("amx_hook_showspy","amx_hc",ADMIN_LEVEL_H,"<0|1> :
   Controls  showing  real  team  color  on  hook  and not disguised team
   color.")
       register_concmd("amx_hook_sound","amx_hc",ADMIN_LEVEL_H,"1       :
   Controls the sound of the hook.")
       register_concmd("amx_hook_hold","amx_hc",ADMIN_LEVEL_H,"15       :
   Controls how many seconds you can stay on the hook.")
       register_concmd("amx_hook_sky","amx_hc",ADMIN_LEVEL_H,"<0|1>     :
   Controls hooking the sky.")
       register_concmd("amx_hook_players","amx_hc",ADMIN_LEVEL_H,"<0|1> :
   Controls hooking onto players.")
       register_concmd("amx_hook_onlywalls","amx_hc",ADMIN_LEVEL_H,"<0|1>
   : Controls hooking on to only walls.")
       register_concmd("amx_hook_color","amx_hc",ADMIN_LEVEL_H,"1       :
   Controls hook color.")
       register_concmd("amx_hook_gravity","amx_hc",ADMIN_LEVEL_H,"0.5   :
   Controls the hook's gravity as a multiple of the current gravity.")
       register_concmd("amx_hook_mode","amx_hc",ADMIN_LEVEL_H,"1        :
   Controls the hook's mode. 1 is launched, 2 is instant.")
       register_concmd("amx_hook_wait","amx_hc",ADMIN_LEVEL_H,"0.05     :
   Controls  how  long  in  seconds  a player has to wait to use the hook
   again.")
       register_concmd("amx_hook_forcespeed","amx_hc",ADMIN_LEVEL_H,"0  :
   Controls a forces speed of the hook.")
       register_concmd("amx_hook_width","amx_hc",ADMIN_LEVEL_H,"20      :
   Controls the width of the hook.")
       register_concmd("amx_hook_noise","amx_hc",ADMIN_LEVEL_H,"1       :
   Controls the noise of the hook. Higher value is a more static look")
       register_concmd("amx_hookvote","amx_hookvote",ADMIN_LEVEL_H,":
   toggles ability for players to start hook votes on and off")
       register_concmd("amx_hookvote_default","amx_hookvote_d",ADMIN_RCON
   ,": sets the current hookvote mode to server default")
       register_concmd("amx_hook_count","admin_hook_count",ADMIN_LEVEL_H,
   ": <# of hooks allowed to each player per round>")
       register_clcmd("say","HandleSay")
       register_clcmd("say /hook","hook_motd")
       register_clcmd("stopvote","stopvote")
       register_menucmd(register_menuid("Use          HookMod?         ")
   ,(1<<0)|(1<<1)|(1<<2)|(1<<3),"vote_count")
       register_cvar("amx_hookvote_ratio","0.51")
       register_cvar("amx_vote_time","15")
       register_cvar("amx_vote_answers","1")
       register_cvar("amx_vote_delay","1")
       register_cvar("amx_last_voting","0")
       register_cvar("amx_vote_inprogress","0")
       register_cvar("amx_hvote_delay","180.0")
       register_cvar("amx_hook_atspawn","0")
       register_cvar("amx_hook_no_vip","1")
       register_cvar("amx_hooks_round","100")
       register_cvar("amx_rep_hcount","1")
       set_cvar_string("amx_hooks_round","100")
       set_cvar_string("amx_hook_atspawn","0")
       set_cvar_string("amx_hook_no_vip","1")
       set_cvar_string("amx_rep_hcount","1")
       set_cvar_string("amx_hvote_delay","180.0")
       register_clcmd("+hook", "check_hookcommand")
       register_event("Battery","vip_spawn","b","1=200")
       register_event("SendAudio","hook_spawn_delay","a","2=%!MRAD_terwin
   ","2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
       register_event("TextMsg","hook_spawn_delay","a","2&#Game_C","2&#Ga
   me_w")
       ejl_vault("READ","HOOK_VOTE","")
       if(equal(vault_value,"OFF"))
           bHookvote = false
       else
           bHookvote = true
       register_cvar("amx_hb_pl_kill","1")
       set_task(4.0,"mapbounds_killer")
       return PLUGIN_CONTINUE
   }
   public ejl_vault(rw[],key[],value[]){
       new data[192]
       new stxtsize = 0
       new line = 0
       new skip = 0
       new vkey[64]
       new vvalue[128]
       new vaultwrite[192]
       if(equal(rw,"READ")){
           if(file_exists("addons/amx/ejl_vault.ini") == 1){
               copy(vault_value,128,"")
               while((line=read_file("addons/amx/ejl_vault.ini",line,data
   ,192,stxtsize))!=0){
                   parse(data,vkey,64,vvalue,128)
                   if(equal(vkey,key)){
                       copy(vault_value,128,vvalue)
                   }
               }
           }else{
               write_file("addons/amx/ejl_vault.ini",  "****  Plugins use
   to store values -- immune to crashes and map changes ****", 0)
           }
       }
       else if(equal(rw,"WRITE")){
           if(file_exists("addons/amx/ejl_vault.ini") == 1){
               format(vaultwrite,192,"%s %s",key,value)
               while((line=read_file("addons/amx/ejl_vault.ini",line,data
   ,192,stxtsize))!=0){
                   parse(data,vkey,64,vvalue,128)
                   if(skip == 0){
                       if( (equal(data,"")) || (equal(vkey,key)) ){
                           skip = 1
                           write_file("addons/amx/ejl_vault.ini",vaultwri
   te,line-1)
                       }
                   }
                   else if(equal(vkey,key)){
                       write_file("addons/amx/ejl_vault.ini","",line-1)
                   }
               }
               if(skip == 0){
                   write_file("addons/amx/ejl_vault.ini",vaultwrite,-1)
               }
           }
       }
       return PLUGIN_CONTINUE
   }
