
   /* AMX Mod script.
   *  Plugin: Training_Day ,work on AMX 0.7.3
   *  code by nTimes^^beetle
   *  only test with podbot
   *  thanks to tcquest78,I can't finish it without his help
   */
   /*  cvars:
   *   amx_training_mode < 0 | 1 >
   *   set to 1 is turn on training mode
   *   or run the command "amx_tmode on"
   *
   *   cmds:
   *   giveme < help | {weapon name} | ammo | armor | life >
   *   {weapon  name}:  he, fb, usp, deagle, mp5, ak47, sg552, m4a1, aug,
   scout, awp
   *   sometimes,you  will lose crosshair when you use "giveme life",just
   run it again
   *   you can bind cmd to key,for example:
   *
   *   bind DELETE "giveme life"
   *   bind END "giveme armor"
   *   bind PGDW "giveme ammo"
   *   bind 4 "giveme he;slot4"
   *
   *   amx_tmode < on | off >
   *   amx_nopass - remove server password(client-side)
   *   sv_nopassword (server-side)
   *   amx_kickall - kick all public players (client-side)
   *   kickall (server-side)
   */
   #include <amxmod>
   //who can get items, I set to ADMIN_RESERVATION,
   //because all our team members have the right RESERVATION)
   #define ACCESS ADMIN_RESERVATION
   //who can turn on(off) training mode,letter "t"
   #define ACCESS2 ADMIN_LEVEL_H
   public god_give_me(id){
       if(!get_cvar_float("amx_training_mode"))
           return PLUGIN_HANDLED

       if(!(get_user_flags(id)&ACCESS)) {
           client_print(id,print_console,"[AMX]  You  have  no  access to
   that command")
           return PLUGIN_HANDLED
       }

       if (read_argc() < 2) {
           client_print(id,print_console,"[AMX]  giveme  < help | {weapon
   name} | ammo | armor | life >")
           return PLUGIN_HANDLED
       }
       new mywish[32]
       read_argv(1,mywish,32)

       //get help
       if (equal(mywish,"help")) {
           new helpmsg[1024]
           add(helpmsg,1024,"Please  DO use this plugin for team training
   only !!^n")
           add(helpmsg,1024,"With  the  plugin,you  can  direct  get some
   weapons,ammo,even life^n")
           add(helpmsg,1024,"Not all weapons are valid,because I think no
   one want to use g3sg1 in match^n^n")
           add(helpmsg,1024,"COMMANDS:^ngiveme    help   (to   see   this
   message)^ngiveme ammo (to get full ammo)^n")
           add(helpmsg,1024,"giveme armor (to get a kevlar)^n")
           add(helpmsg,1024,"giveme  ak47 (to get ak,your can replace the
   name with other weapon,see below)^n")
           add(helpmsg,1024,"giveme  life  (to  respawn,if  your  haven't
   crosshair,run command again,GOD lose it^^n")
           add(helpmsg,1024,"WEAPONS:^n[  usp,  deagle, mp5, ak47, sg552,
   m4a1, aug, scout, awp ,he, fb ]^n")
           show_motd(id,helpmsg,"[AMX Training Day] HELP")
       }

       //get life
       if (equal(mywish,"life")) {
           user_spawn(id)
       }

       //get armor
       if (equal(mywish,"armor")) {
           new cur_armor=get_user_armor(id)
           if (cur_armor == 0){
               give_item(id,"item_kevlar")
           }
       }

       if(is_user_alive(id)){

           //get ammo
           if (equal(mywish,"ammo")) {
               new i=0
               while(i<5){
                   give_item(id,"ammo_45acp")
                   give_item(id,"ammo_50ae")
                   give_item(id,"ammo_9mm")
                   give_item(id,"ammo_762nato")
                   give_item(id,"ammo_556nato")
                   give_item(id,"ammo_338magnum")
                   i++
               }
           }


           //get weapons, maybe here code looks stupid,but really work
           //here  no  smokegrenade,I  don't want to play cstrike with 20
   fps
           //if u want to get a glock,find it on T base
           if (equal(mywish,"knife")) {
               give_item(id,"weapon_knife")
           }
           if (equal(mywish,"he")) {
               give_item(id,"weapon_hegrenade")
           }
           if (equal(mywish,"fb")) {
               give_item(id,"weapon_flashbang")
           }
           if (equal(mywish,"usp")) {
               give_item(id,"weapon_usp")
           }
           if (equal(mywish,"deagle")) {
               give_item(id,"weapon_deagle")
           }
           if (equal(mywish,"mp5")) {
               give_item(id,"weapon_mp5navy")
           }
           if (equal(mywish,"ak47")) {
               give_item(id,"weapon_ak47")
           }
           if (equal(mywish,"m4a1")) {
               give_item(id,"weapon_m4a1")
           }
           if (equal(mywish,"sg552")) {
               give_item(id,"weapon_sg552")
           }
           if (equal(mywish,"aug")) {
               give_item(id,"weapon_aug")
           }
           if (equal(mywish,"scout")) {
               give_item(id,"weapon_scout")
           }
           if (equal(mywish,"awp")) {
               give_item(id,"weapon_awp")
           }
       }
       return PLUGIN_CONTINUE
   }
   public turn_training_mode(id){
       if(!(get_user_flags(id)&ACCESS2)) {
           client_print(id,print_console,"[AMX]  You  have  no  access to
   that command")
           return PLUGIN_HANDLED
       }
       if (read_argc() < 2) {
           client_print(id,print_console,"[AMX] amx_tmode < on | off >")
           return PLUGIN_HANDLED
       }

       new i[4]
       read_argv(1,i,4)

       if (equal(i,"on")) {
           set_cvar_float("amx_training_mode",1.0)
           client_print(0,print_chat,"[AMX] Training Mode is ON")
       }else{
           set_cvar_float("amx_training_mode",0.0)
           client_print(0,print_chat,"[AMX] Training Mode is OFF")
       }

       return PLUGIN_CONTINUE
   }
   /* Addons
   *  our  clan  runing  a  cs  server,we open it for public from 7:00 to
   20:00
   *  and  we  start training at 20:00,so we need to lock server and kick
   the public players
   *  how  can  you  exec  that  automatic,first,you must have the plugin
   "Task Scheduler" by JustinHoMi
   *  add these tasks:
   *  amx_task 7:00 "sv_nopassword" tr
   *  amx_task 7:03 "sv_nopassword" tr
   *  amx_task 19:50 "sv_password 123456" tr
   *  amx_task 19:53 "sv_password 123456" tr
   *  amx_task 20:00 "kickall" tr
   *  amx_task 20:03 "kickall" tr
   *  why  do  I add duplicate task,because the task not exec when server
   is changing map
   *
   *  sv_nopassword, kickall are server-side commands
   *  amx_nopass, amx_kickall are client-side commands
   */
   public sv_nopass(id){
       if ((id != 0) && (!(get_user_flags(id)&ADMIN_PASSWORD)) ){
           client_print(id,print_console,"[AMX]  You  have  no  access to
   that command")
           return PLUGIN_HANDLED
       }

       set_cvar_string("sv_password","")
       return PLUGIN_CONTINUE
   }
   public sv_kick_all(id){

       if ((id != 0) && (!(get_user_flags(id)&ADMIN_KICK)) ){
           client_print(id,print_console,"[AMX]  You  have  no  access to
   that command")
           return PLUGIN_HANDLED
       }

       new players[32], i
       get_players(players,i)
       for(new a = 0; a < i; a++) {
           if (get_user_flags(players[a])&ACCESS)  // don't kick our team
   member
               continue

           if (is_user_bot(players[a])) {
               server_cmd("kick #%d",get_user_userid(players[a]))
           }else{
               client_cmd(players[a],"echo  [AMX]  Server  run a KICK_ALL
   command ,if server locked, please try later.;disconnect")
           }
       }
       return PLUGIN_CONTINUE
   }
   public plugin_init()
   {
       register_plugin("AMX Training Day","0.7.3","beetle")
       register_cvar("amx_training_mode","0")
       register_clcmd("giveme","god_give_me",ACCESS,"giveme   <   help  |
   {weapon name} | ammo | armor | life >")
       register_clcmd("amx_tmode","turn_training_mode",ACCESS2,"amx_tmode
   < on | off >  - turn on/off training mode")
       register_srvcmd("sv_nopassword","sv_nopass")
       register_clcmd("amx_nopass","sv_nopass",ADMIN_PASSWORD,"amx_nopass
   - remove server password")
       register_srvcmd("kickall","sv_kick_all")
       register_clcmd("amx_kickall","sv_kick_all",ADMIN_KICK,"amx_kickall
   - kick all players")
       return PLUGIN_CONTINUE
   }
