
   /*********************************************************************
   ******
   * amx_ejl_laserweapon.sma   version 2.7.1     Date: 3/2/2003
   *  Author: Eric Lidman      ejlmozart@hotmail.com
   *  Alias: Ludwig van        Upgrade:
   http://lidmanmusic.com/cs/plugins.html
   *
   *  Add  a  laser  weapon to Half-Life mod. Fire a laser beam that acts
   like
   *   a  real weapon. Takes different damage depending what body zone it
   hits.
   *   All  mods  can  use  the laser, but if you run Counter-Strike, the
   plugin
   *   keeps  track  of all laser related stats in a statsme style. Laser
   stats
   *   restart  on  the  first day of every month. There is FX like smoke
   clouds,
   *   the laserbeams themselves, explosions, laser burns where laserbeam
   *   strikes,  etc.  (burn  decals may be an issue with latest hlds, if
   so, you
   *   can  turn  burn  decals  with  a  cvar). If you run the CS missile
   plugin,
   *   the lasers can shoot down the missiles. Also, stats can be tracked
   by
   *   AUTHID or IP address meaning now lan CS servers can take advantage
   of
   *   the  stats. Also lasers are sensitive to the mp_friendlyfire cvar.
   If
   *   freindly  fire  is on, lasers can hurt your teammates, and if off,
   team-
   *   mates  can  be  shot  without  damage. This plugin has built in TK
   punish
   *   features that can be set to light punishments, or severe.
   *
   *  PODBOT:  If  using  my  podbots controller, podbots use this plugin
   too.
   *
   *  Admin Commands:
   *
   *    amx_lasers             -- toggles on and off lasers enabled
   *    amx_laserbuying        --   toggles   on   and   off   laser  buy
   requirements
   *    amx_write_laserstats   --  forces  laser  stats  to be printed to
   file
   *                              on     the     next     map     change.
   ejl_laser_stats.ini
   *                              file  is not deleted. Note that the log
   file
   *                              produced by this command is a text file
   *                              which can be posted on your website.
   *    amx_del_laserstats     --  prints laser stats to file immediately
   then
   *                              deletes  ejl_laser_stats.ini and clears
   all
   *                              laser stats from memory
   *
   *  Client Command:
   *
   *    amx_firelasergun  <color>  --  bind  a  key to it and use as fire
   button
   *
   *   You  can  use  the colors: white,red,green,blue,yellow,magenta,and
   cyan.
   *   If you dont specify a color, a default color will be used. You can
   *   also  specify  a  custom  color by making one out of the 3 primary
   colors
   *   red,  green,  and  blue. Preceed your color # with an exclaimation
   point,
   *   then  without  any  spaces type three 3 digit numbers ranging from
   0-255.
   *   Example: (255 red, 10 green, 189 blue)
   *
   *     bind mouse1 "amx_firelasergun !255010189"
   *
   *  More client commands:
   *
   *    say  /laser                --  show window with info about use of
   laser
   *    say   /laserstats           --   show   window  with  top  15  in
   laserstats
   *    say /laserstats2          -- show window with laserstats for map
   *    say  /laserstatsme         --  show  window  with  your  personal
   laserstats
   *
   *  CVARs:  put in your admin.cfg for your defaults
   *
   *    amx_luds_lasers 1         --0 to disable lasers
   *    amx_laserstats_on 1       --0 to not use any of the laser stats
   *    amx_laser_buy   0           --1   requires   laser  shots  to  be
   purchased
   *    amx_laser_cost 100        --ammount of money taken each time you
   *                                shoot the laser
   *    amx_laser_maxtemp 3440    --temperature at which point your laser
   *                                overheats  and  explodes thus killing
   you
   *    amx_laser_ammo 50         --number of laser shots given per round
   *                                for  free to clients in amx_laser_buy
   is 0
   *    amx_laser_burndecals 1    --default is set to use decals so there
   is
   *                                an appearance of a burn where a laser
   *                                shot strikes, but because HL has some
   *                                decal  inconsistencies  from  copy to
   copy,
   *                                the wrong decals might be used making
   the
   *                                plugin  look stupid. Set this cvar to
   0
   *                                if   you   are   having  laser  decal
   problems
   *    amx_laser_allowinvis    1    --default    is    set    to   allow
   invisble/nearly
   *                                invisible laser beams. Set to 0 so
   *                                clients   cannot   set   their  laser
   invisible
   *    amx_laser_obeyffcvar 1    --if mp_friendlyfire is 1 and this cvar
   is
   *                                set to 0, this plugin will act as if
   *                                friendlyfire  is  off ... even if its
   on.
   *    amx_laser_tkpunish1 1     --if friendlyfire is on, this sets the
   *                                ammount of automatic retribution for
   *                                shooting  teammates  in mirror damage
   stlye
   *                                   0 = no damage to team hurter
   *                                   1  =  exact  mirror damage to team
   hurter
   *                                   2 = double damage to team hurter
   *    amx_laser_tkpunish2  1     --if friendlyfire is on, this sets the
   type
   *                                of  punishment  given  if  you kill a
   certain
   *                                number  of teammates detemined by the
   cvar
   *                                amx_laser_tkpunish3. Can be set 0, 1,
   or 2
   *                                   0 = no action
   *                                   1 = kick off server
   *                                   2 = ban for 3 hours
   *    amx_laser_tkpunish3  3     --if  friendlyfire  is  on, on killing
   this
   *                                many  of  your  teammates, the plugin
   takes
   *                                the action set by amx_laser_tkpunish2
   cvar
   *    amx_laser_trackbyip  0     --for  the laserstats, by default this
   plugin
   *                                tries   to  track  players  stats  by
   AUTHID, if
   *                                set  to  1,  it will use IP addresses
   instead
   *                                If  you  run a lan server, the plugin
   auto-
   *                                matically   choses  to  track  by  IP
   address.
   *    amx_laser_showip  0        --for  the  laserstats,  if you do the
   command
   *                                to  write  the  stats  to  a file for
   display
   *                                or  wait  for  the  one  that is made
   auto-
   *                                matically  at  the end of each month,
   you
   *                                may  want  to  hide  players personal
   info
   *                                like  thier IP address. Default is to
   hide
   *                                set to 1 to show IPs or AUTHIDs
   *   amx_laser_botaimdiffuse  16  --the  higher this number is set, the
   worse a
   *                                bot's laser aim will be. Set to 0 for
   bots
   *                                to   have  near  godlike  laser  aim.
   Default 16
   *
   *  Additional info:
   *
   *   Laser  kills  and  damage  are  sent to the sever logs in the same
   format
   *   as  normal  kills  and  damage.  A  log parser (like pysychostats)
   should be
   *   able to take the log output of this plugin and include them in the
   *   stats output. Laser kills count on the CS scoreboard, but are only
   *   refeshed at the end of each round. This is for CS only by the way.
   *   Plugin  may  cause some lag at round end depending on the size and
   power
   *   of  the  server,  but  it  never does anything to cause lag during
   gameplay.
   *   If its a problem, turn off the amx_laserstats_on cvar (set to 0).
   *
   *   If you have the module from SpaceDude's warcraft3 plugin (war3_ms)
   you
   *   can  make  the  deahtmessages  look more real, so laser kills look
   like an
   *   actual  player  killing another player instead of a suicide on the
   part
   *   of the killed player. To enable this, you need to change the code
   *   below.  Simply change the value to 1 where it has #define use_war3
   0
   *   Its  simple, a one line change, thats it, compile and its ready to
   go.
   *
   **********************************************************************
   ****/
   /*  To get the better deathmessages. Change this one  */
   /*  line so it looks like:    #define use_war3 1      */
   #define use_war3 0
   /*  Enable laser damage to entities other than players. Change this */
   /*  line so it looks like:    #define use_vexd 1                    */
   /* DONT SET VEXD TO 1 HERE!!!! NOT DONE*/
   #define use_vexd 0
   /*  Laser damage is determined here. */
   #define h1_dam 100  // head
   #define h2_dam 56   // chest
   #define h3_dam 46   // stomach
   #define h4_dam 24   // arms
   #define h6_dam 31   // legs
   #define tkh1_dam 50 // head - half mirror damage for team friendlyfire
   punsishments
   #define   tkh2_dam   28  //  chest  -  half  mirror  damage  for  team
   friendlyfire punsishments
   #define  tkh3_dam  23  //  stomach  -  half  mirror  damage  for  team
   friendlyfire punsishments
   #define tkh4_dam 12 // arms - half mirror damage for team friendlyfire
   punsishments
   #define tkh6_dam 15 // legs - half mirror damage for team friendlyfire
   punsishments
   /*********************************************************************
   ***************
   *
                *
   *  *end*  customizable section of code. other changes can be done with
   the cvars    *                                            *
   *
                *
   **********************************************************************
   **************/
   #include <amxmod>
   #include <amxmisc>
   #if use_war3 == 1
   #include <war3>
   new gmsgDeathMsg
   new redundant_plug
   #endif
   #if use_vexd == 1
   #include <Vexd_Utilities>
   #endif
   new vault_value[128]
   new white
   new fire
   new smoke
   new laser
   new l_warning[33][2]
   new tdead[33]
   new DoOnce = 0
   new DoneInit = 0
   new writeonce = 0
   new laser_heat[33]
   new Float:last_laser_time[33]
   new Float:SwitchControl[33]
   new laser_shots[33]
   new  laser_stats[450][56]  //  0=kills  1=deaths 2=damage 3=overheat /
   4=authid / 24=name
   new  laser_statst[450][58]  //  0=kills 1=deaths 2=damage 3=overheat /
   4=authid / 24=name / 56=mapch-connect / 57=lowstat
   new laser_statst_c[33][4]
   new laser_stats_r1[33][56]
   new laser_stats_r2[33][4]
   new mlaser_stats[33][56]
   new tauthid[20],tname[32]
   new tempstats[4]
   new l_rank[33],l_t_ranks
   new bool:force_stats = false
   new bool:cstrike_running
   new bool:dod_running
   new tkcount[33]
   new dod_team[33]
   #define MAX_CLR 8
   new ncolors[MAX_CLR][] =
   {"!","white","red","green","blue","yellow","magenta","cyan"}
   new vcolors[MAX_CLR][3] =
   {{255,255,255},{255,255,255},{255,0,0},{0,255,0},{0,0,255},{255,255,0}
   ,{255,0,255},{0,255,255}}
   new adcolors[33][4]
   new adscolors[64][43]
   explode(vec1[3]){
       // blast circles
       message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec1)
       write_byte( 21 )
       write_coord(vec1[0])
       write_coord(vec1[1])
       write_coord(vec1[2] + 16)
       write_coord(vec1[0])
       write_coord(vec1[1])
       write_coord(vec1[2] + 1936)
       write_short( white )
       write_byte( 0 ) // startframe
       write_byte( 0 ) // framerate
       write_byte( 3 ) // life 2
       write_byte( 20 ) // width 16
       write_byte( 0 ) // noise
       write_byte( 188 ) // r
       write_byte( 220 ) // g
       write_byte( 255 ) // b
       write_byte( 255 ) //brightness
       write_byte( 0 ) // speed
       message_end()
       //Explosion2
       message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
       write_byte( 12 )
       write_coord(vec1[0])
       write_coord(vec1[1])
       write_coord(vec1[2])
       write_byte( 188 ) // byte (scale in 0.1's) 188
       write_byte( 10 ) // byte (framerate)
       message_end()
       //TE_Explosion
       message_begin( MSG_BROADCAST,SVC_TEMPENTITY,vec1)
       write_byte( 3 )
       write_coord(vec1[0])
       write_coord(vec1[1])
       write_coord(vec1[2]+20)
       write_short( fire )
       write_byte( 40 ) // byte (scale in 0.1's) 188
       write_byte( 10 ) // byte (framerate)
       write_byte( 0 ) // byte flags
       message_end()
   }
   public laser_sw_con(vIndex){
       new aIndex = get_user_attacker(vIndex)
       SwitchControl[aIndex] = get_gametime()
       return PLUGIN_CONTINUE
   }
   public bot_interface(){
       new sid[8],id
       read_argv(1,sid,7)
       id = strtonum(sid)
       if(get_cvar_num("amx_luds_lasers") == 0)
           return PLUGIN_HANDLED
       if(is_user_alive(id) == 0)
           return PLUGIN_HANDLED
       if(SwitchControl[id] > get_gametime() - 0.75){
           engclient_cmd(id,"weapon_knife")
           return PLUGIN_HANDLED
       }
       if(get_cvar_num("amx_laser_buy") == 1){
           new umoney = get_user_money(id)
           new l_cost = get_cvar_num("amx_laser_cost")
           if(umoney < l_cost)
               return PLUGIN_HANDLED
           else
               set_user_money(id,umoney-l_cost,1)
       }else{
           if(laser_shots[id] < 1)
               return PLUGIN_HANDLED
           laser_shots[id] -= 1
       }
       engclient_cmd(id,"weapon_knife")
       new tid,tbody,a
       new choose_decal,decal_id
       new aimvec[3]
       new
   namea[32],namev[32],authida[20],authidv[20],teama[16],teamv[16]
       get_user_name(id,namea,31)
       new iteama = get_user_team(id,teama,15)
       if(dod_running)
           iteama = dod_team[id]
       get_user_authid(id,authida,19)
       new Float:curtime = get_gametime()
       if(last_laser_time[id] < curtime - 4.0)
           laser_heat[id] = 0
       else if(last_laser_time[id] < curtime - 2.5)
           laser_heat[id] -=3
       else if(last_laser_time[id] < curtime - 2.0)
           laser_heat[id] -=2
       else if(last_laser_time[id] < curtime - 1.5)
           laser_heat[id] -=1
       else if(last_laser_time[id] > curtime - 0.1)
           laser_heat[id] +=7
       else if(last_laser_time[id] > curtime - 0.3)
           laser_heat[id] +=3
       else if(last_laser_time[id] > curtime - 0.8)
           laser_heat[id] +=2
       else if(last_laser_time[id] > curtime - 1.5)
           laser_heat[id] +=1
       if(laser_heat[id] < 0)
           laser_heat[id] = 0
       else if(laser_heat[id] > (get_cvar_num("amx_laser_maxtemp") - 500)
   / 147 ){
           new origin[3]
           get_user_origin(id,origin)
           explode(origin)
           user_kill(id,1)
           log_message("^"%s<%d><%s><%s>^"  killed  self ^"by overheating
   his laser^"",
           namea,get_user_userid(id),authida,teama)
           laser_stats_r1[id][3] +=1
           laser_stats_r2[id][3] +=1
           #if use_war3 == 1
           stop_dm(id,id,0,9876)
           #endif
       }
       last_laser_time[id] = get_gametime()
       emit_sound(id,CHAN_ITEM,  "weapons/electro5.wav",  1.0, ATTN_NORM,
   0, PITCH_NORM)
       new botaimcvar = get_cvar_num("amx_laser_botaimdiffuse")
       new botaimfactor = random_num(-botaimcvar,botaimcvar)
       get_user_origin(id,aimvec,3)
       aimvec[0] += botaimfactor
       aimvec[1] += botaimfactor
       aimvec[2] += botaimfactor
       get_user_aiming(id,tid,tbody,9999)
       if(tbody){
           if(botaimfactor < 0)
               botaimfactor = botaimfactor * -1
           tbody = tbody + (botaimfactor / 7)
       }
       new iteamv = get_user_team(tid,teamv,15)
       if(dod_running){
           if(tid > 0 && tid < 33)
               iteamv = dod_team[tid]
       }
       get_user_name(tid,namev,31)
       get_user_authid(tid,authidv,19)
       new color[11]
       read_argv(2,color,10)
       if(equal(color[0],"!",1)){
           new sred[4],sgreen[4],sblue[4],ired,igreen,iblue
           if( (strlen(color) < 2) && (adcolors[id][3] == 1) ){
               vcolors[0][0] = adcolors[id][0]
               vcolors[0][1] = adcolors[id][1]
               vcolors[0][2] = adcolors[id][2]
           }else{
               copy(sred,3,color[1])
               copy(sgreen,3,color[4])
               copy(sblue,3,color[7])
               ired = strtonum(sred)
               igreen = strtonum(sgreen)
               iblue = strtonum(sblue)
               if(ired < 0 || ired > 255)
                   ired = 255
               if(igreen < 0 || igreen > 255)
                   igreen = 255
               if(iblue < 0 || iblue > 255)
                   iblue = 255
               if(  (strlen(sred)  ==  0)  ||  (strlen(sgreen)  ==  0) ||
   (strlen(sblue) == 0) )
                   ired = 255,igreen=255,iblue=255
               vcolors[0][0] = ired
               vcolors[0][1] = igreen
               vcolors[0][2] = iblue
               adcolors[id][0] = ired
               adcolors[id][1] = igreen
               adcolors[id][2] = iblue
               adcolors[id][3] = 1
           }
       }else{
           switch(iteama){
               case 1: a = 6
               case 2: a = 3
               case 3: a = 2
               case 4: a = 4
           }
           for(new i=1;i<MAX_CLR;++i){
               if (equal(color,ncolors[i])) {
                   a = i
                   break
               }
           }
       }
       if(!get_cvar_num("amx_laser_allowinvis")){
           if(vcolors[a][0] + vcolors[a][1] + vcolors[a][2] < 100)
               a = 5
       }
       choose_decal = random_num(0,3)
       switch(choose_decal){
           case 0: decal_id = 28
           case 1: decal_id = 103
           case 2: decal_id = 198
           case 3: decal_id = 199
       }
       //BEAMENTPOINT
       message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
       write_byte ( 1 )     //TE_BEAMENTPOINT 1
       write_short (id)     // ent
       write_coord(aimvec[0])
       write_coord(aimvec[1])
       write_coord(aimvec[2])
       write_short( laser )
       write_byte( 1 ) // framestart
       write_byte( 5 ) // framerate
       write_byte( 2 ) // life
       write_byte( 10 ) // width
       write_byte( 0 ) // noise
       write_byte( vcolors[a][0] ) // r, g, b
       write_byte( vcolors[a][1] ) // r, g, b
       write_byte( vcolors[a][2] ) // r, g, b
       write_byte( 200 ) // brightness
       write_byte( 200 ) // speed
       message_end()
       //Sparks
       message_begin( MSG_PVS, SVC_TEMPENTITY)
       write_byte( 9 )
       write_coord( aimvec[0] )
       write_coord( aimvec[1] )
       write_coord( aimvec[2] )
       message_end()
       //Smoke
       message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
       write_byte( 5 ) // 5
       write_coord(aimvec[0])
       write_coord(aimvec[1])
       write_coord(aimvec[2])
       write_short( smoke )
       write_byte( 22 )  // 10
       write_byte( 10 )  // 10
       message_end()
       if(get_cvar_num("amx_laser_burndecals") == 1){
           //TE_GUNSHOTDECAL
           message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
           write_byte( 109 ) // decal and ricochet sound
           write_coord( aimvec[0] ) //pos
           write_coord( aimvec[1] )
           write_coord( aimvec[2] )
           write_short (0) // I have no idea what thats supposed to be
           write_byte (decal_id) //decal
            message_end()
       }
       if((tid > 0) && (tid < 33)){
           if(cvar_exists("mp_friendlyfire")){
               new ffcvar = get_cvar_num("mp_friendlyfire")
               if(    (ffcvar    ==    0)    ||   ((ffcvar   ==   1)   &&
   (get_cvar_num("amx_laser_obeyffcvar") == 0)) ){
                   if(iteama != iteamv)
                       do_laserdamage(id,tid,tbody,namea,namev,teama,team
   v,authida,authidv,0)
               }else{
                   if(iteama != iteamv)
                       do_laserdamage(id,tid,tbody,namea,namev,teama,team
   v,authida,authidv,0)
                   else
                       do_laserdamage(id,tid,tbody,namea,namev,teama,team
   v,authida,authidv,1)
               }
           }else{
               do_laserdamage(id,tid,tbody,namea,namev,teama,teamv,authid
   a,authidv,0)
           }
       }else{
   //        if(tid != 0){
   //            if(!check_otherentities(id,namea,tid,tbody))
                   server_cmd("lasermissile_chk %d %d",tid,id)
   //        }
       }
       return PLUGIN_HANDLED
   }
   public fire_laser(id){
       if(get_cvar_num("amx_luds_lasers") == 0){
           client_print(id,print_chat,"[AMX]   Laser  guns  are  disabled
   right now")
           return PLUGIN_HANDLED
       }
       if(is_user_alive(id) == 0){
           client_print(id,print_chat,"[AMX]  You cannot use a laser when
   you are dead.")
           return PLUGIN_HANDLED
       }
       if(SwitchControl[id] > get_gametime() - 0.75){
           engclient_cmd(id,"weapon_knife")
           return PLUGIN_HANDLED
       }
       if(get_cvar_num("amx_laser_buy") == 1){
           new umoney = get_user_money(id)
           new l_cost = get_cvar_num("amx_laser_cost")
           if(umoney < l_cost){
               client_print(id,print_chat,"[AMX]  Sorry,     you     have
   insufficient funds. It's %d money per laser shot",l_cost)
               return PLUGIN_HANDLED
           }else{
               set_user_money(id,umoney-l_cost,1)
           }
       }else{
           if(laser_shots[id] < 1){
               client_print(id,print_chat,"[AMX]   No  more  power,  your
   laser is dead")
               return PLUGIN_HANDLED
           }
           else if(laser_shots[id] < 11){
               if(l_warning[id][1] == 0){
                   l_warning[id][1] = 1
                   client_print(id,print_chat,"[AMX] Warning, laser power
   level low, 10 shots left")
                   client_cmd(id,"spk     ^"fvox/alert,    power_level_is
   ten^"")
               }
           }
           laser_shots[id] -= 1
       }
       engclient_cmd(id,"weapon_knife")
       new tid,tbody,found,a
       new choose_decal,decal_id
       new color[10]
       new aimvec[3]
       new
   namea[32],namev[32],authida[20],authidv[20],teama[16],teamv[16]
       get_user_name(id,namea,31)
       new iteama = get_user_team(id,teama,15)
       if(dod_running)
           iteama = dod_team[id]
       get_user_authid(id,authida,19)
       new Float:curtime = get_gametime()
       if(last_laser_time[id] < curtime - 4.0)
           laser_heat[id] = 0
       else if(last_laser_time[id] < curtime - 2.5)
           laser_heat[id] -=3
       else if(last_laser_time[id] < curtime - 2.0)
           laser_heat[id] -=2
       else if(last_laser_time[id] < curtime - 1.5)
           laser_heat[id] -=1
       else if(last_laser_time[id] > curtime - 0.1)
           laser_heat[id] +=7
       else if(last_laser_time[id] > curtime - 0.3)
           laser_heat[id] +=3
       else if(last_laser_time[id] > curtime - 0.8)
           laser_heat[id] +=2
       else if(last_laser_time[id] > curtime - 1.5)
           laser_heat[id] +=1
       if(laser_heat[id] < 0)
           laser_heat[id] = 0
       else if(laser_heat[id] > (get_cvar_num("amx_laser_maxtemp") - 500)
   / 147 ){
           new origin[3]
           get_user_origin(id,origin)
           explode(origin)
           user_kill(id,1)
           client_print(id,print_chat,"[AMX]  You died because your laser
   overheated and exploded.")
           log_message("^"%s<%d><%s><%s>^"  killed  self ^"by overheating
   his laser^"",
           namea,get_user_userid(id),authida,teama)
           laser_stats_r1[id][3] +=1
           laser_stats_r2[id][3] +=1
           #if use_war3 == 1
           stop_dm(id,id,0,9876)
           #endif
       }
       else  if(laser_heat[id]  <  ((get_cvar_num("amx_laser_maxtemp")  -
   500) / 147)-5){
           if(get_cvar_num("amx_laser_buy") == 1)
               client_print(id,print_center,"^n^nLaser   Temperature:  %d
   degrees F",(laser_heat[id] * 147)+ 500)
           else
               client_print(id,print_center,"Laser   Power   Pack   Level
   %d^n^nLaser Temperature: %d degrees F",laser_shots[id],(laser_heat[id]
   * 147)+ 500)
       }else{
           if(l_warning[id][0] == 0){
               l_warning[id][0] = 1
               client_cmd(id,"spk ^"fvox/warning heat_damage^"")
           }
           client_print(id,print_center,"WARNING: Laser Overheating!!!!")
       }
       last_laser_time[id] = get_gametime()
       emit_sound(id,CHAN_ITEM,  "weapons/electro5.wav",  1.0, ATTN_NORM,
   0, PITCH_NORM)
       get_user_origin(id,aimvec,3)
       get_user_aiming(id,tid,tbody,9999)
       new iteamv = get_user_team(tid,teamv,15)
       if(dod_running){
           if(tid > 0 && tid < 33)
               iteamv = dod_team[tid]
       }
       get_user_name(tid,namev,31)
       get_user_authid(tid,authidv,19)
       read_argv(1,color,10)
       if(equal(color[0],"!",1)){
           found = 1
           new sred[4],sgreen[4],sblue[4],ired,igreen,iblue
           if( (strlen(color) < 2) && (adcolors[id][3] == 1) ){
               vcolors[0][0] = adcolors[id][0]
               vcolors[0][1] = adcolors[id][1]
               vcolors[0][2] = adcolors[id][2]
           }else{
               copy(sred,3,color[1])
               copy(sgreen,3,color[4])
               copy(sblue,3,color[7])
               ired = strtonum(sred)
               igreen = strtonum(sgreen)
               iblue = strtonum(sblue)
               if(ired < 0 || ired > 255)
                   ired = 255
               if(igreen < 0 || igreen > 255)
                   igreen = 255
               if(iblue < 0 || iblue > 255)
                   iblue = 255
               if(  (strlen(sred)  ==  0)  ||  (strlen(sgreen)  ==  0) ||
   (strlen(sblue) == 0) )
                   ired = 255,igreen=255,iblue=255
               vcolors[0][0] = ired
               vcolors[0][1] = igreen
               vcolors[0][2] = iblue
               adcolors[id][0] = ired
               adcolors[id][1] = igreen
               adcolors[id][2] = iblue
               adcolors[id][3] = 1
           }
       }else{
           switch(iteama){
               case 1: a = 6
               case 2: a = 3
               case 3: a = 2
               case 4: a = 4
           }
           for(new i=1;i<MAX_CLR;++i){
               if (equal(color,ncolors[i])) {
                   a = i
                   found = 1
                   break
               }
           }
           if((found != 1) && (id !=0)){
               get_user_authid(id,authida,16)
               for(new i=0;i<64;++i){
                   if(equal(authida,adscolors[i][3])) {
                       vcolors[0][0] = adscolors[i][0]
                       vcolors[0][1] = adscolors[i][1]
                       vcolors[0][2] = adscolors[i][2]
                       a = 0
                       break
                   }
               }
           }
       }
       if(!get_cvar_num("amx_laser_allowinvis")){
           if(vcolors[a][0] + vcolors[a][1] + vcolors[a][2] < 100)
               a = 5
       }
       choose_decal = random_num(0,3)
       switch(choose_decal){
           case 0: decal_id = 28
           case 1: decal_id = 103
           case 2: decal_id = 198
           case 3: decal_id = 199
       }
       //BEAMENTPOINT
       message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
       write_byte ( 1 )     //TE_BEAMENTPOINT 1
       write_short (id)     // ent
       write_coord(aimvec[0])
       write_coord(aimvec[1])
       write_coord(aimvec[2])
       write_short( laser )
       write_byte( 1 ) // framestart
       write_byte( 5 ) // framerate
       write_byte( 2 ) // life
       write_byte( 10 ) // width
       write_byte( 0 ) // noise
       write_byte( vcolors[a][0] ) // r, g, b
       write_byte( vcolors[a][1] ) // r, g, b
       write_byte( vcolors[a][2] ) // r, g, b
       write_byte( 200 ) // brightness
       write_byte( 200 ) // speed
       message_end()
       //Sparks
       message_begin( MSG_PVS, SVC_TEMPENTITY)
       write_byte( 9 )
       write_coord( aimvec[0] )
       write_coord( aimvec[1] )
       write_coord( aimvec[2] )
       message_end()
       //Smoke
       message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
       write_byte( 5 ) // 5
       write_coord(aimvec[0])
       write_coord(aimvec[1])
       write_coord(aimvec[2])
       write_short( smoke )
       write_byte( 22 )  // 10
       write_byte( 10 )  // 10
       message_end()
       if(get_cvar_num("amx_laser_burndecals") == 1){
           //TE_GUNSHOTDECAL
           message_begin( MSG_BROADCAST,SVC_TEMPENTITY)
           write_byte( 109 ) // decal and ricochet sound
           write_coord( aimvec[0] ) //pos
           write_coord( aimvec[1] )
           write_coord( aimvec[2] )
           write_short (0) // I have no idea what thats supposed to be
           write_byte (decal_id) //decal
            message_end()
       }
       if((tid > 0) && (tid < 33)){
           if(cvar_exists("mp_friendlyfire")){
               new ffcvar = get_cvar_num("mp_friendlyfire")
               if(    (ffcvar    ==    0)    ||   ((ffcvar   ==   1)   &&
   (get_cvar_num("amx_laser_obeyffcvar") == 0)) ){
                   if(iteama != iteamv)
                       do_laserdamage(id,tid,tbody,namea,namev,teama,team
   v,authida,authidv,0)
               }else{
                   if(iteama != iteamv)
                       do_laserdamage(id,tid,tbody,namea,namev,teama,team
   v,authida,authidv,0)
                   else
                       do_laserdamage(id,tid,tbody,namea,namev,teama,team
   v,authida,authidv,1)
               }
           }else{
               do_laserdamage(id,tid,tbody,namea,namev,teama,teamv,authid
   a,authidv,0)
           }
       }else{
   //        if(tid != 0){
   //            if(!check_otherentities(id,namea,tid,tbody))
                   server_cmd("lasermissile_chk %d %d",tid,id)
   //        }
       }
       return PLUGIN_HANDLED
   }
   do_laserdamage(id,tid,tbody,namea[],namev[],teama[],teamv[],authida[],
   authidv[],tker){
       new healthv = get_user_health(tid)
       if(tbody == 1){
           if(tker){
               if(get_cvar_num("mp_logdetail") == 3){
                   log_message("^"%s<%d><%s><%s>^"               attacked
   ^"%s<%d><%s><%s>^"  with  ^"Laser Gun^" (hit ^"head^") (damage ^"%d^")
   (health ^"%d^")",
                   namea,get_user_userid(id),authida,teama,namev,get_user
   _userid(tid),authidv,teamv,tkh1_dam,healthv-tkh1_dam)
               }
           }else{
               laser_stats_r1[id][2] += h1_dam
               laser_stats_r2[id][2] += h1_dam
               if(get_cvar_num("mp_logdetail") == 3){
                   log_message("^"%s<%d><%s><%s>^"               attacked
   ^"%s<%d><%s><%s>^"  with  ^"Laser Gun^" (hit ^"head^") (damage ^"%d^")
   (health ^"%d^")",
                   namea,get_user_userid(id),authida,teama,namev,get_user
   _userid(tid),authidv,teamv,h1_dam,healthv-h1_dam)
               }
           }
           user_kill(tid,1)
           tdead[tid] += 1
       }
       else if(tbody == 2){
           if(tker){
               if(healthv < tkh2_dam+1){
                   user_kill(tid,1)
                   tdead[tid] += 1
               }else{
                   set_user_health(tid,healthv-tkh2_dam)
                   if(get_cvar_num("mp_logdetail") == 3){
                       log_message("^"%s<%d><%s><%s>^"           attacked
   ^"%s<%d><%s><%s>^"  with ^"Laser Gun^" (hit ^"chest^") (damage ^"%d^")
   (health ^"%d^")",
                       namea,get_user_userid(id),authida,teama,namev,get_
   user_userid(tid),authidv,teamv,tkh2_dam,healthv-tkh2_dam)
                   }
               }
           }else{
               laser_stats_r1[id][2] += h2_dam
               laser_stats_r2[id][2] += h2_dam
               if(healthv < h2_dam+1){
                   user_kill(tid,1)
                   tdead[tid] += 1
               }else{
                   set_user_health(tid,healthv-h2_dam)
                   if(get_cvar_num("mp_logdetail") == 3){
                       log_message("^"%s<%d><%s><%s>^"           attacked
   ^"%s<%d><%s><%s>^"  with ^"Laser Gun^" (hit ^"chest^") (damage ^"%d^")
   (health ^"%d^")",
                       namea,get_user_userid(id),authida,teama,namev,get_
   user_userid(tid),authidv,teamv,h2_dam,healthv-h2_dam)
                   }
               }
           }
       }
       else if(tbody == 3){
           if(tker){
               if(healthv < tkh3_dam+1){
                   user_kill(tid,1)
                   tdead[tid] += 1
               }else{
                   set_user_health(tid,healthv-tkh3_dam)
                   if(get_cvar_num("mp_logdetail") == 3){
                       log_message("^"%s<%d><%s><%s>^"           attacked
   ^"%s<%d><%s><%s>^"   with  ^"Laser  Gun^"  (hit  ^"stomach^")  (damage
   ^"%d^") (health ^"%d^")",
                       namea,get_user_userid(id),authida,teama,namev,get_
   user_userid(tid),authidv,teamv,tkh3_dam,healthv-tkh3_dam)
                   }
               }
           }else{
               laser_stats_r1[id][2] += h3_dam
               laser_stats_r2[id][2] += h3_dam
               if(healthv < h3_dam+1){
                   user_kill(tid,1)
                   tdead[tid] += 1
               }else{
                   set_user_health(tid,healthv-h3_dam)
                   if(get_cvar_num("mp_logdetail") == 3){
                       log_message("^"%s<%d><%s><%s>^"           attacked
   ^"%s<%d><%s><%s>^"   with  ^"Laser  Gun^"  (hit  ^"stomach^")  (damage
   ^"%d^") (health ^"%d^")",
                       namea,get_user_userid(id),authida,teama,namev,get_
   user_userid(tid),authidv,teamv,h3_dam,healthv-h3_dam)
                   }
               }
           }
       }
       else if(tbody == 4 || tbody == 5){
           if(tker){
               if(healthv < tkh4_dam+1){
                   user_kill(tid,1)
                   tdead[tid] += 1
               }else{
                   set_user_health(tid,healthv-tkh4_dam)
                   if(get_cvar_num("mp_logdetail") == 3){
                       log_message("^"%s<%d><%s><%s>^"           attacked
   ^"%s<%d><%s><%s>^"  with  ^"Laser Gun^" (hit ^"arms^") (damage ^"%d^")
   (health ^"%d^")",
                       namea,get_user_userid(id),authida,teama,namev,get_
   user_userid(tid),authidv,teamv,tkh4_dam,healthv-tkh4_dam)
                   }
               }
           }else{
               laser_stats_r1[id][2] += h4_dam
               laser_stats_r2[id][2] += h4_dam
               if(healthv < h4_dam+1){
                   user_kill(tid,1)
                   tdead[tid] += 1
               }else{
                   set_user_health(tid,healthv-h4_dam)
                   if(get_cvar_num("mp_logdetail") == 3){
                       log_message("^"%s<%d><%s><%s>^"           attacked
   ^"%s<%d><%s><%s>^"  with  ^"Laser Gun^" (hit ^"arms^") (damage ^"%d^")
   (health ^"%d^")",
                       namea,get_user_userid(id),authida,teama,namev,get_
   user_userid(tid),authidv,teamv,h4_dam,healthv-h4_dam)
                   }
               }
           }
       }
       else if(tbody == 6 || tbody == 7){
           if(tker){
               if(healthv < tkh6_dam+1){
                   user_kill(tid,1)
                   tdead[tid] += 1
               }else{
                   set_user_health(tid,healthv-tkh6_dam)
                   if(get_cvar_num("mp_logdetail") == 3){
                       log_message("^"%s<%d><%s><%s>^"           attacked
   ^"%s<%d><%s><%s>^"  with  ^"Laser Gun^" (hit ^"legs^") (damage ^"%d^")
   (health ^"%d^")",
                       namea,get_user_userid(id),authida,teama,namev,get_
   user_userid(tid),authidv,teamv,tkh6_dam,healthv-tkh6_dam)
                   }
               }
           }else{
               laser_stats_r1[id][2] += h6_dam
               laser_stats_r2[id][2] += h6_dam
               if(healthv < h6_dam+1){
                   user_kill(tid,1)
                   tdead[tid] += 1
               }else{
                   set_user_health(tid,healthv-h6_dam)
                   if(get_cvar_num("mp_logdetail") == 3){
                       log_message("^"%s<%d><%s><%s>^"           attacked
   ^"%s<%d><%s><%s>^"  with  ^"Laser Gun^" (hit ^"legs^") (damage ^"%d^")
   (health ^"%d^")",
                       namea,get_user_userid(id),authida,teama,namev,get_
   user_userid(tid),authidv,teamv,h6_dam,healthv-h6_dam)
                   }
               }
           }
       }
       emit_sound(tid,CHAN_BODY,     "weapons/xbow_hitbod2.wav",     1.0,
   ATTN_NORM, 0, PITCH_NORM)
       if(tdead[tid] == 1){
           new lasguyfrags = get_user_frags(id)
           if(tker){
               new punish2 = get_cvar_num("amx_laser_tkpunish2")
               new punish3 = get_cvar_num("amx_laser_tkpunish3")
               client_print(id,print_center,"You killed a teammate")
               laser_stats_r1[id][0] -= 1
               laser_stats_r2[id][0] -= 1
               laser_stats_r1[tid][1] += 1
               laser_stats_r2[tid][1] += 1
               lasguyfrags -=1
               set_user_frags(id,lasguyfrags)
               tkcount[id] +=1
               if(tkcount[id] > punish3 -1){
                   switch(punish2){
                       case  1:  client_cmd(id,"echo  You were kicked for
   team killing;disconnect")
                       case 2: {
                           client_cmd(id,"echo  You  were banned for team
   killing")
                           if (equal("4294967295",authida)){
                               new ipa[32]
                               get_user_ip(id,ipa,31,1)
                               server_cmd("addip 180.0 %s;writeip",ipa)
                           }else{
                               server_cmd("banid         180.0         %s
   kick;writeid",authida)
                           }
                       }
                   }
               }
           }else{
               laser_stats_r1[id][0] += 1
               laser_stats_r2[id][0] += 1
               laser_stats_r1[tid][1] += 1
               laser_stats_r2[tid][1] += 1
               lasguyfrags +=1
               set_user_frags(id,lasguyfrags)
           }
           client_print(tid,print_chat,"[AMX]  %s,  you just got fried by
   %s's frickin laser.",namev,namea)
           client_print(id,print_chat,"[AMX]  You  just  killed %s with a
   frickin laser.",namev)
           log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with
   ^"Laser Gun^"",
           namea,get_user_userid(id),authida,teama,namev,get_user_userid(
   tid),authidv,teamv)
           #if use_war3 == 1
           stop_dm(id,tid,tbody,9876)
           #endif
           server_cmd("artificial_dm %d %d",id,tid)
       }
       if(tker){
           new punish1 = get_cvar_num("amx_laser_tkpunish1")
           new healtha = get_user_health(id)
           new players[32],pNum
           get_players(players,pNum,"e",teama)
           for(new i=0;i<pNum;i++)
               client_print(players[i],print_chat,"%s  attacked         a
   teammate",namea)
           switch(punish1){
               case 1: {
                   switch(tbody){
                       case 1: set_user_health(id,healtha - tkh1_dam)
                       case 2: set_user_health(id,healtha - tkh2_dam)
                       case 3: set_user_health(id,healtha - tkh3_dam)
                       case 4: set_user_health(id,healtha - tkh4_dam)
                       case 5: set_user_health(id,healtha - tkh4_dam)
                       case 6: set_user_health(id,healtha - tkh6_dam)
                       case 7: set_user_health(id,healtha - tkh6_dam)
                   }
               }
               case 2: {
                   switch(tbody){
                       case 1: set_user_health(id,healtha - h1_dam)
                       case 2: set_user_health(id,healtha - h2_dam)
                       case 3: set_user_health(id,healtha - h3_dam)
                       case 4: set_user_health(id,healtha - h4_dam)
                       case 5: set_user_health(id,healtha - h4_dam)
                       case 6: set_user_health(id,healtha - h6_dam)
                       case 7: set_user_health(id,healtha - h6_dam)
                   }
               }
               case 3: user_kill(id,0)
           }
           if(!is_user_alive(id)){
               set_hudmessage(255,50,50, -1.0, 0.45, 0, 0.02, 10.0, 1.01,
   1.1, 4)
               show_hudmessage(id,"YOU    WERE    KILLED^nFOR   ATTACKING
   TEAMMATES.^nSEE THAT IT HAPPENS NO MORE!")
           }
       }
   }

   /*
   check_otherentities(id,namea[],tid,tbody){
       new szClassName[32]
       Entvars_Get_String(tid, EV_SZ_classname, szClassName, 31)
       if(equal(szClassName, "hostage_entity")) {
           new Float:damag
           switch(tbody){
               case 0: damag = h4_dam + 0.0
               case 1: damag = h1_dam + 0.0
               case 2: damag = h2_dam + 0.0
               case 3: damag = h3_dam + 0.0
               case 4: damag = h4_dam + 0.0
               case 5: damag = h4_dam + 0.0
               case 6: damag = h6_dam + 0.0
               case 7: damag = h6_dam + 0.0
           }
           new Float:ent_health
           ent_health = Float:Entvars_Get_Float(tid, EV_FL_health)
           Entvars_Set_Float(tid, EV_FL_takedamage, 100.0)
           Entvars_Set_Float(tid, EV_FL_dmg_take, 100.0)
           ent_health -= damag
           Entvars_Set_Float(tid, EV_FL_health, ent_health)
           if(ent_health < 1.0){
               client_print(0,print_center,"%s killed a hostage",namea)
               new um = get_user_money(id)
               set_user_money(id,um - 1000)
   //            Entvars_Set_Int(tid, EV_INT_deadflag, 1)
   #define    DEAD_NO                    0 // alive
   #define    DEAD_DYING                1  //  playing death animation or
   still falling off of a ledge waiting to hit ground
   #define    DEAD_DEAD                2 // dead. lying still.
   #define DEAD_RESPAWNABLE        3
   #define DEAD_DISCARDBODY        4
           }
           return 1
       }
       return 0
   }
   */
   public admin_lasers(id,level,cid){
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       if(get_cvar_num("amx_luds_lasers") == 0){
           set_cvar_string("amx_luds_lasers","1")
           client_print(0,print_chat,"[AMX]  Admin has enabled lasers")
           console_print(id,"[AMX]  You have enabled lasers")
       }else {
           set_cvar_string("amx_luds_lasers","0")
           client_print(0,print_chat,"[AMX]  Admin has disabled lasers")
           console_print(id,"[AMX]  You have disabled lasers")
       }
       new authid[16],name[32]
       get_user_authid(id,authid,15)
       get_user_name(id,name,31)
       log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^"
   lasers",name,get_user_userid(id),authid)
       return PLUGIN_HANDLED
   }
   public admin_lasersbuy(id,level,cid){
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       if(get_cvar_num("amx_laser_buy") == 0){
           set_cvar_string("amx_laser_buy","1")
           client_print(0,print_chat,"[AMX]  Admin  requires  you pay for
   your your laser shots now.")
           console_print(id,"[AMX]  You  have  required  players  pay for
   laser shots")
       }else {
           set_cvar_string("amx_laser_buy","0")
           client_print(0,print_chat,"[AMX]  Admin   has   decreed   that
   lasers are free now")
           console_print(id,"[AMX]  You have made lasers free")
       }
       new authid[16],name[32]
       get_user_authid(id,authid,15)
       get_user_name(id,name,31)
       log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^"
   lasers_buying",name,get_user_userid(id),authid)
       return PLUGIN_HANDLED
   }
   public admin_fstats(id,level,cid){
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       if(!cstrike_running){
           client_print(id,print_chat,"[AMX]  Sorry, laser stats are only
   for Counter-Strike mod at this point.")
           return PLUGIN_HANDLED
       }
       if(force_stats == true){
           force_stats = false
           console_print(id,"[AMX]  You  have  set  server  NOT  to print
   stats to file on the next mapchange")
       }else {
           force_stats = true
           console_print(id,"[AMX]  You have set server to print stats to
   file on the next mapchange")
       }
       new authid[16],name[32]
       get_user_authid(id,authid,15)
       get_user_name(id,name,31)
       log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^"
   force_laser_stats",name,get_user_userid(id),authid)
       return PLUGIN_HANDLED
   }
   public admin_delstats(id,level,cid){
       if (!cmd_access(id,level,cid,1))
           return PLUGIN_HANDLED
       if(!cstrike_running){
           client_print(id,print_chat,"[AMX]  Sorry, laser stats are only
   for Counter-Strike mod at this point.")
           return PLUGIN_HANDLED
       }
       if(file_exists("addons/amx/ejl_laser_stats.ini"))
           delete_file("addons/amx/ejl_laser_stats.ini")
       if(writeonce == 0){
           force_stats = true
           writeonce = 1
           console_print(id,"[AMX]  Writing Laserstats to file...")
           write_laserstats()
       }else{
           console_print(id,"[AMX]  Laserstats  can  only  be  written to
   file once per map.")
       }
       l_t_ranks = 0
       force_stats = false
       new maxplayers = get_maxplayers()+1
       for (new i=1; i<=maxplayers; i++) {
           setc(laser_stats_r2[i][0],4,0)
           setc(laser_statst_c[i][0],4,0)
           setc(laser_stats_r1[i][0],48,0)
           setc(mlaser_stats[i][0],48,0)
           l_rank[i] = 0
       }
       for (new i=0; i<449; i++) {
           setc(laser_stats[i][0],56,0)
           setc(laser_statst[i][0],58,0)
       }
       console_print(id,"[AMX]  You have just deleted all laserstats.")
       force_stats = false
       new authid[16],name[32]
       get_user_authid(id,authid,15)
       get_user_name(id,name,31)
       log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^"
   delete_laser_stats",name,get_user_userid(id),authid)
       return PLUGIN_HANDLED
   }
   public HandleSay(id) {
       new Speech[192]
       read_args(Speech,192)
       remove_quotes(Speech)
       if(   (containi(Speech,   "laser")  !=  -1)  ||  (containi(Speech,
   "lazer") != -1) ){
           if(get_cvar_num("amx_luds_lasers") == 1){
               if(    (get_cvar_num("amx_laserstats_on")    ==    0)   ||
   (!cstrike_running) ){
                   client_print(id,print_chat,"[AMX]  Lasers          are
   ON    For help say /laser")
               }else{
                   client_print(id,print_chat,     "[AMX]  Lasers     are
   ON    For help say /laser    Stats say /laserstats")
               }
           }else{
               client_print(id,print_chat, "[AMX]  Lasers are OFF")
           }
       }
       return PLUGIN_CONTINUE
   }
   public laser_motd(id){
       new la_motd[1300]
       new temp[768]
       temp = "Bind a key to amx_firelasergun    <color info below>^n\
                 Go  to  your  console,  choose a key for laser gun. Lets
   say^n\
                 we  want to use f  -- <I like mouse1 myself - below>. Do
   this:^n^n\
                  bind f amx_firelasergun^n^n\
                 Enter  that,  and  now  whenever you press the f key, it
   fires^n\
                 your  laser.  Lasers  are  real  and  can  hurt and kill
   enemies.^n"
       add(la_motd,1299,temp)
       temp  =  "Caution:  Watch  the  laser temperature posted above the
   center^n\
                 of your screen when you fire. If you overheat the laser,
   it^n\
                will explode and you will die.^n\
               Laser color:  bind f ^"amx_firelasergun !100255050^"^n\
                Preceed a nine digit # with !   Its !RRRGGGBBB <0-255>^n"
       add(la_motd,1299,temp)
       temp = "or just do:  bind f ^"amx_firelasergun red^"^n\
                If you bound mouse1 and want to return to the original^n\
                bind so you can fire normal gun, bind mouse1 +attack^n\
                mouse2 also a good choice for laser, originally +attack2"
       add(la_motd,1299,temp)
       show_motd(id,la_motd,"Laser Gun Help:")
       return PLUGIN_CONTINUE
   }
   public laser_stats_m(id){
       if(get_cvar_num("amx_laserstats_on") == 0){
           client_print(id,print_chat,"[AMX]  Sorry,   laser   stats  are
   diasbled")
           return PLUGIN_HANDLED
       }
       if(!cstrike_running){
           client_print(id,print_chat,"[AMX]  Sorry, laser stats are only
   for Counter-Strike mod at this point.")
           return PLUGIN_HANDLED
       }
       new la_motd[1300]
       new temp[768]
       temp = "say /laserstats  --for top 15 laser fraggers^n\
               say /laserstats2  --for map's total laser stats^n\
               say /laserstatsme  --for your total laser stats^n^n\
               Kills | Deaths | Damage | Overheats | Player^n^n"
       add(la_motd,1299,temp)
       new maxpl = get_maxplayers() +1
       for(new a = 0; a < maxpl; a++) {
           new names[32]
           copy(names,31,mlaser_stats[a][24])
           if(mlaser_stats[a][24]){
               format(temp,767,"%d       %d        %d       %d
    %s^n",mlaser_stats[a][0],mlaser_stats[a][1],mlaser_stats[a][2],mlaser
   _stats[a][3],names)
               add(la_motd,1299,temp)
           }
       }
       show_motd(id,la_motd,"Laser Stats: Map")
       return PLUGIN_CONTINUE
   }
   public laser_stats_mee(id){
       if(get_cvar_num("amx_laserstats_on") == 0){
           client_print(id,print_chat,"[AMX]  Sorry,   laser   stats  are
   diasbled")
           return PLUGIN_HANDLED
       }
       if(!cstrike_running){
           client_print(id,print_chat,"[AMX]  Sorry, laser stats are only
   for Counter-Strike mod at this point.")
           return PLUGIN_HANDLED
       }
       new la_motd[1300]
       new temp[768]
       new names[32],title[64]
       get_user_name(id,names,31)
       temp = "say /laserstats  --for top 15 laser fraggers^n\
               say /laserstats2  --for map's total laser stats^n\
               say /laserstatsme  --for your total laser stats^n^n"
       add(la_motd,1299,temp)
       format(temp,767,"%s,  your  laser  rank  at  map  start  was %d of
   %d^n^n",names,l_rank[id],l_t_ranks)
       add(la_motd,1299,temp)
       temp = "Your total laser stats:^n\
               Kills | Deaths | Damage | Overheats^n"
       add(la_motd,1299,temp)
       format(temp,767,"%d       %d        %d       %d",laser_statst_c[id
   ][0],laser_statst_c[id][1],laser_statst_c[id][2],laser_statst_c[id][3]
   )
       add(la_motd,1299,temp)
       temp = "^n^nYour laser stats for this map:^n\
               Kills | Deaths | Damage | Overheats^n"
       add(la_motd,1299,temp)
       format(temp,767,"%d       %d        %d       %d",laser_stats_r2[id
   ][0],laser_stats_r2[id][1],laser_stats_r2[id][2],laser_stats_r2[id][3]
   )
       add(la_motd,1299,temp)
       temp = "^n^nYour laser stats for the round:^n\
               Kills | Deaths | Damage | Overheats^n"
       add(la_motd,1299,temp)
       format(temp,767,"%d       %d        %d       %d",laser_stats_r1[id
   ][0],laser_stats_r1[id][1],laser_stats_r1[id][2],laser_stats_r1[id][3]
   )
       add(la_motd,1299,temp)
       format(title,63,"%s",names)
       show_motd(id,la_motd,title)
       return PLUGIN_CONTINUE
   }
   public laser_stats_a(id){
       if(get_cvar_num("amx_laserstats_on") == 0) {
           client_print(id,print_chat,"[AMX]  Sorry,   laser   stats  are
   diasbled")
           return PLUGIN_HANDLED
       }
       if(!cstrike_running){
           client_print(id,print_chat,"[AMX]  Sorry, laser stats are only
   for Counter-Strike mod at this point.")
           return PLUGIN_HANDLED
       }
       new la_motd[1300]
       new temp[768]
       temp = "say /laserstats  --for top 15 laser fraggers^n\
               say /laserstats2  --for map's total laser stats^n\
               say /laserstatsme  --for your total laser stats^n^n\
               Kills | Deaths | Damage | Overheats | Player^n^n"
       add(la_motd,1299,temp)
       for(new a = 0; a < 15; a++) {
           new names[32]
           copy(names,31,laser_stats[a][24])
           format(temp,767,"%d       %d        %d       %d            %s^
   n",laser_stats[a][0],laser_stats[a][1],laser_stats[a][2],laser_stats[a
   ][3],names)
           if(laser_stats[a][4])
               add(la_motd,1299,temp)
       }
       show_motd(id,la_motd,"Laser Stats: Top 15")
       return PLUGIN_CONTINUE
   }
   public client_connect(id){
       dod_team[id] = 0
       tdead[id] = 0
       last_laser_time[id] = 0.0
       laser_heat[id] = 0
       if(get_cvar_num("amx_laser_buy") == 0)
           laser_shots[id] = get_cvar_num("amx_laser_ammo")
       else
           laser_shots[id] = 0
       laser_stats_r1[id][0] = 0
       laser_stats_r1[id][1] = 0
       laser_stats_r1[id][2] = 0
       laser_stats_r1[id][3] = 0
       laser_stats_r2[id][0] = 0
       laser_stats_r2[id][1] = 0
       laser_stats_r2[id][2] = 0
       laser_stats_r2[id][3] = 0
       tkcount[id] = 0
       return PLUGIN_CONTINUE
   }
   public client_disconnect(id){
       dod_team[id] = 0
       tdead[id] = 0
       last_laser_time[id] = 0.0
       laser_heat[id] = 0
       laser_shots[id] = get_cvar_num("amx_laser_ammo")
       laser_stats_r1[id][0] = 0
       laser_stats_r1[id][1] = 0
       laser_stats_r1[id][2] = 0
       laser_stats_r1[id][3] = 0
       laser_stats_r2[id][0] = 0
       laser_stats_r2[id][1] = 0
       laser_stats_r2[id][2] = 0
       laser_stats_r2[id][3] = 0
       tkcount[id] = 0
       return PLUGIN_CONTINUE
   }
   public round_end(){
       if(get_cvar_num("amx_luds_lasers") == 0)
           return PLUGIN_CONTINUE
       if(DoOnce == 0){
           DoOnce = 1
           set_task(0.5,"delayed_round_end")
       }
       return PLUGIN_CONTINUE
   }
   public delayed_round_end(){
       new ipid = get_cvar_num("amx_laser_trackbyip")
       new maxplayers = get_maxplayers()+1
       for (new i=1; i<=maxplayers; i++) {
           if(is_user_connected(i) == 1){
               if( (is_user_alive(i) == 0) &&
   (get_cvar_num("amx_laser_buy") == 1) )
                   laser_shots[i] = 0
               if(ipid)
                   get_user_ip(i,laser_stats_r1[i][4],15,1)
               else
                   get_user_authid(i,laser_stats_r1[i][4],19)
               get_user_name(i,laser_stats_r1[i][24],31)
               if(get_cvar_num("amx_laserstats_on") == 1){
                   stats_helper2(laser_stats_r1[i][4],laser_stats_r1[i][2
   4],laser_stats_r1[i][0],laser_stats_r1[i][1],laser_stats_r1[i][2],lase
   r_stats_r1[i][3])
               }
           }
       }
       return PLUGIN_CONTINUE
   }
   public round_start(){
       if(get_cvar_num("amx_luds_lasers") == 0)
           return PLUGIN_CONTINUE
       stats_helper3()
       new authid[20],name[32]
       DoOnce = 0
       new tracked[2]
       new ipid = get_cvar_num("amx_laser_trackbyip")
       new testid[20]
       format(testid,19,laser_stats[0][4])
       if( (ipid) && (testid[0]) && (!equal(testid[3],".",1)) ){
           server_cmd("amx_del_laserstats")
           log_message("[AMX]  Laserstats  deleted  because  of change of
   tracking method from AUTHID to IP")
       }
       else if( (!ipid) && (testid[0]) && (equal(testid[3],".",1)) ){
           server_cmd("amx_del_laserstats")
           log_message("[AMX]  Laserstats  deleted  because  of change of
   tracking method from IP to AUTHID")
       }
       new maxplayers = get_maxplayers()+1
       for (new i=1; i<=maxplayers; i++) {
           tdead[i] = 0
           laser_heat[i] = 0
           if(get_cvar_num("amx_laser_buy") == 0)
               laser_shots[i] = get_cvar_num("amx_laser_ammo")
           last_laser_time[i] = 0.0
           l_warning[i][0] = 0
           l_warning[i][1] = 0
           laser_stats_r1[i][0] = 0
           laser_stats_r1[i][1] = 0
           laser_stats_r1[i][2] = 0
           laser_stats_r1[i][3] = 0
           if(is_user_connected(i) == 1){
               if(get_cvar_num("amx_laserstats_on") == 1){
                   if(ipid)
                       get_user_ip(i,authid,15,1)
                   else
                       get_user_authid(i,authid,19)
                   if(authid[0]){
                       for (new b=0; b<449; b++) {
                           if(equal(authid,laser_statst[b][4],8)){
                               laser_statst[b][56] = -1
                               tracked[0] = 1
                           }
                           else      if(     (!laser_statst[b][4])     &&
   (!tracked[0]) ){
                               tracked[1] = b
                               tracked[0] = 2
                           }
                       }
                       if(tracked[0] == 2){
                           get_user_name(i,name,31)
                           copy(laser_statst[tracked[1]][4],19,authid)
                           copy(laser_statst[tracked[1]][24],31,name)
                           laser_statst[tracked[1]][56] = -1
                       }
                       tracked[0] = 0
                       tracked[1] = 0
                   }
               }
           }
       }
       if(get_cvar_num("amx_laserstats_on") == 1)
           stats_helper4()
       return PLUGIN_CONTINUE
   }
   public new_spawn(id){
       #if use_war3 == 1
       block_message(gmsgDeathMsg)
       #endif
       if(get_cvar_num("amx_luds_lasers") == 0)
           return PLUGIN_CONTINUE
       if(!cstrike_running){
           if(get_cvar_num("amx_laser_buy") == 1)
               laser_shots[id] = 0
           else
               laser_shots[id] = get_cvar_num("amx_laser_ammo")
           tdead[id] = 0
           laser_heat[id] = 0
           last_laser_time[id] = 0.0
           l_warning[id][0] = 0
           l_warning[id][1] = 0
       }
       return PLUGIN_CONTINUE
   }
   public plugin_end(){
       if( (get_cvar_num("amx_laserstats_on") == 0) || (!cstrike_running)
   )
           return PLUGIN_CONTINUE
       delete_file("addons/amx/ejl_laser_stats.ini")
       new wr_stats[100],authid[20],name[32]
       new month[16]
       get_time("%m",month,15)
       ejl_vault("READ","EJL_LASER_MONTH","")
       if(vault_value[0]){
           if( (!equal(vault_value,month)) || (force_stats == true) ){
               write_laserstats()
               if(force_stats == false)
                   return PLUGIN_CONTINUE
           }
       }
       for (new b=0; b<449; b++) {
           if(laser_statst[b][4]){
               if(!(laser_statst[b][0] == 0 && laser_statst[b][1] == 0 &&
   laser_statst[b][2] == 0 && laser_statst[b][3] == 0) ){
                   if(laser_statst[b][57] < 150){
                       if(laser_statst[b][0] < 3)
                           laser_statst[b][57] +=2
                       if(laser_statst[b][2] < 600){
                           laser_statst[b][57] +=1
                       }else{
                           laser_statst[b][57] = 0
                       }
                       if(laser_statst[b][56] < 250){
                           format(authid,19,"%s",laser_statst[b][4])
                           format(name,31,"%s",laser_statst[b][24])
                           format(wr_stats,99,"%s  ^"%s^"  %d %d %d %d %d
   %d",authid,name,laser_statst[b][0],laser_statst[b][1],laser_statst[b][
   2],laser_statst[b][3],laser_statst[b][56],laser_statst[b][57])
                           if(!equal(authid,"BOT"))
                               write_file("addons/amx/ejl_laser_stats.ini
   ",wr_stats,-1)
                       }
                   }
               }
           }
       }
       return PLUGIN_CONTINUE
   }
   stats_helper(authid[],name[],kills,deaths,damage,oh){
       new NumLoops
       if(DoneInit == 0)
           NumLoops = 450
       else
           NumLoops = 16
       for(new a = 0; a < NumLoops; a++) {
           if(authid[0]){
               if(kills >= laser_stats[a][0]){
                   copy(tauthid,19,laser_stats[a][4])
                   copy(tname,31,laser_stats[a][24])
                   tempstats[0] = laser_stats[a][0]
                   tempstats[1] = laser_stats[a][1]
                   tempstats[2] = laser_stats[a][2]
                   tempstats[3] = laser_stats[a][3]
                   copy(laser_stats[a][4],19,authid)
                   copy(laser_stats[a][24],31,name)
                   laser_stats[a][0] = kills
                   laser_stats[a][1] = deaths
                   laser_stats[a][2] = damage
                   laser_stats[a][3] = oh
                   copy(authid,19,tauthid)
                   copy(name,31,tname)
                   kills = tempstats[0]
                   deaths = tempstats[1]
                   damage = tempstats[2]
                   oh = tempstats[3]
               }
           }
       }
   }
   stats_helper2(authid[],name[],kills,deaths,damage,oh){
       new ipid = get_cvar_num("amx_laser_trackbyip")
       new sauthid[20]
       new maxplayers = get_maxplayers()+1
       for (new b=0; b<449; b++) {
           for (new a=1; a<maxplayers; a++){
               if(is_user_connected(a) == 1){
                   if(ipid)
                       get_user_ip(a,sauthid,15,1)
                   else
                       get_user_authid(a,sauthid,19)
                   if(equal(sauthid,laser_statst[b][4],8)){
                       laser_statst_c[a][0] = laser_statst[b][0]
                       laser_statst_c[a][1] = laser_statst[b][1]
                       laser_statst_c[a][2] = laser_statst[b][2]
                       laser_statst_c[a][3] = laser_statst[b][3]
                   }
                   if(equal(sauthid,laser_stats[b][4],8)){
                       l_rank[a] = b +1
                   }
               }
           }
           if(equal(authid,laser_statst[b][4],8)){
               copy(laser_statst[b][24],31,name)
               laser_statst[b][0] += kills
               laser_statst[b][1] += deaths
               laser_statst[b][2] += damage
               laser_statst[b][3] += oh
           }
       }
   }
   stats_helper3(){
       new authid4[20],name4[32]
       l_t_ranks = 0
       new NumLoops
       if(DoneInit == 0)
           NumLoops = 450
       else
           NumLoops = 16
       for (new a=0; a<NumLoops; a++){
           setc(laser_stats[a][4],19,0)
           setc(laser_stats[a][24],31,0)
           laser_stats[a][0] = 0
           laser_stats[a][1] = 0
           laser_stats[a][2] = 0
           laser_stats[a][3] = 0
       }
       for (new b=0; b<449; b++){
           if(laser_statst[b][4]){
               l_t_ranks += 1
               format(authid4,19,"%s",laser_statst[b][4])
               format(name4,31,"%s",laser_statst[b][24])
               stats_helper(authid4,name4,laser_statst[b][0],laser_statst
   [b][1],laser_statst[b][2],laser_statst[b][3])
           }
       }
   }
   stats_helper4(){
       new mname[32],tempname[32]
       new mkills,mdeaths,mdamage,moh
       new maxplayers = get_maxplayers()+1
       for (new a=0; a<maxplayers; a++){
           setc(mlaser_stats[a][24],31,0)
           mlaser_stats[a][0] = 0
           mlaser_stats[a][1] = 0
           mlaser_stats[a][2] = 0
           mlaser_stats[a][3] = 0
       }
       for (new a=1; a<maxplayers; a++) {
           if(is_user_connected(a) == 1){
               copy(mname,31,laser_stats_r1[a][24])
               mkills = laser_stats_r2[a][0]
               mdeaths = laser_stats_r2[a][1]
               mdamage = laser_stats_r2[a][2]
               moh = laser_stats_r2[a][3]
               for (new b=0; b<maxplayers; b++) {
                   if(mkills >= mlaser_stats[b][0]){
                       copy(tempname,31,mlaser_stats[b][24])
                       tempstats[0] = mlaser_stats[b][0]
                       tempstats[1] = mlaser_stats[b][1]
                       tempstats[2] = mlaser_stats[b][2]
                       tempstats[3] = mlaser_stats[b][3]
                       copy(mlaser_stats[b][24],31,mname)

                       mlaser_stats[b][0] = mkills
                       mlaser_stats[b][1] = mdeaths
                       mlaser_stats[b][2] = mdamage
                       mlaser_stats[b][3] = moh
                       copy(mname,31,tempname)
                       mkills = tempstats[0]
                       mdeaths = tempstats[1]
                       mdamage = tempstats[2]
                       moh = tempstats[3]
                   }
               }
           }
       }
   }
   write_laserstats(){
       new showip = get_cvar_num("amx_laser_showip")
       new wr_stats[100],authid[20],name[32]
       new filename[50]
       new len
       new spacer[32],spacer2[10],spacer3[10],spacer4[10],spacer5[10]
       DoneInit = 0
       stats_helper3()
       if(force_stats == false){
           get_time("addons/amx/%Y-%m--laserstats.log",filename,49)
           write_file(filename,filename,-1)
       }else{
           get_time("addons/amx/%m-%d-%Y--%H-%M---laserstats.log",filenam
   e,49)
           write_file(filename,filename,-1)
       }
       write_file(filename," ",-1)
       write_file(filename,"Name                             |Kills     |
   Deaths    |Damage    |Overheats |Identifier",-1)
       write_file(filename," ",-1)
       for (new b=0; b<449; b++) {
           if(laser_stats[b][4]){
               format(authid,19,"%s",laser_stats[b][4])
               format(name,31,"%s",laser_stats[b][24])
               setc(spacer,31,0)
               setc(spacer3,9,0)
               setc(spacer4,9,0)
               setc(spacer5,9,0)
               len = (strlen(name) - 32) * -1
               for(new z = 0; z<len;z++)
                   add(spacer,31," ")
               num_to_str(laser_stats[b][0],spacer2,9)
               num_to_str(laser_stats[b][1],spacer3,9)
               num_to_str(laser_stats[b][2],spacer4,9)
               num_to_str(laser_stats[b][3],spacer5,9)
               len = (strlen(spacer2) - 10) * -1
               setc(spacer2,9,0)
               for(new z = 0; z<len;z++)
                   add(spacer2,9," ")
               len = (strlen(spacer3) - 10) * -1
               setc(spacer3,9,0)
               for(new z = 0; z<len;z++)
                   add(spacer3,9," ")
               len = (strlen(spacer4) - 10) * -1
               setc(spacer4,9,0)
               for(new z = 0; z<len;z++)
                   add(spacer4,9," ")
               len = (strlen(spacer5) - 10) * -1
               setc(spacer5,9,0)
               for(new z = 0; z<len;z++)
                   add(spacer5,9," ")
               if(showip)
                   format(wr_stats,99,"%s%s  %d%s    %d%s    %d%s    %d%s
   %s",name,spacer,laser_stats[b][0],spacer2,laser_stats[b][1],spacer3,la
   ser_stats[b][2],spacer4,laser_stats[b][3],spacer5,authid)
               else
                   format(wr_stats,99,"%s%s  %d%s    %d%s    %d%s    %d%s
   private",name,spacer,laser_stats[b][0],spacer2,laser_stats[b][1],space
   r3,laser_stats[b][2],spacer4,laser_stats[b][3],spacer5)
               write_file(filename,wr_stats,-1)
           }
       }
       DoneInit = 1
   }
   public plugin_log(){
       new args = read_logargc()
       if(args == 2){
           new msg[32]
           read_logargv(1,msg,31)
           if(msg[6] == 'S')
               round_start()
       }
       else if(args == 3){
           new msg[32]
           read_logargv(1,msg,31)
           if(equal(msg,"joined t",8)){
               new clinfo[64],won[32],cutoff,bcount
               new classinfo[32]
               read_logargv(0,clinfo,63)
               read_logargv(2,classinfo,31)
               new tcbackw = strlen(clinfo)
               new cbackw = tcbackw
               for(new i=0;i<tcbackw;i++){
                   cbackw -= 1
                   if(cbackw > 0){
                       if(clinfo[cbackw] == '<'){
                           bcount +=1
                           if(bcount == 3){
                               copy(won,i-cutoff,clinfo[cbackw+1])
                           }
                           else if(bcount == 2)
                               cutoff = i + 2
                       }
                   }
               }
               new iwon = strtonum(won)
               new playerl = find_player("k",iwon)
               if(!playerl) return PLUGIN_CONTINUE
               if(equali(classinfo,"Axis"))
                   dod_team[playerl] = 1
               else
                   dod_team[playerl] = 2
           }
       }
       return PLUGIN_CONTINUE
   }
   public plugin_precache(){
       new mod_name[32]
       get_modname(mod_name,31)
       dod_running = equal(mod_name,"dod") ? true : false
       white = precache_model("sprites/white.spr")
       fire = precache_model("sprites/fexplo.spr")
       if(dod_running)
           smoke = precache_model("sprites/smoke.spr")
       else
           smoke = precache_model("sprites/steam1.spr")
       laser = precache_model("sprites/laserbeam.spr")
       precache_sound("weapons/electro5.wav")
       precache_sound("weapons/xbow_hitbod2.wav")
       return PLUGIN_CONTINUE
   }
   #if use_war3 == 1
   public stop_dm(id,tid,tbody,num){
       if(num == 9876){
           if (tbody == 1){
               message_begin( MSG_ALL, gmsgDeathMsg,{0,0,0},0)
               write_byte(id)
               write_byte(tid)
               write_string(" laser gun")
               message_end()
           }else{
               message_begin( MSG_ALL, gmsgDeathMsg,{0,0,0},0)
               write_byte(id)
               write_byte(tid)
               write_byte(0)
               write_string(" laser gun")
               message_end()
           }
       }else{
           if(redundant_plug == 0){
               new killer_id = read_data(1)
               new victim_id = read_data(2)
               new headshot = read_data(3)
               new weaponname[20]
               if(cstrike_running)
                   read_data(4,weaponname,31)
               else
                   read_data(3,weaponname,31)
               new weapon
               get_user_attacker(victim_id,weapon)

               if     (!(killer_id==victim_id     &&     !headshot     &&
   equal(weaponname,"world"))){
                   message_begin( MSG_ALL, gmsgDeathMsg,{0,0,0},0)
                   write_byte(killer_id)
                   write_byte(victim_id)
                   write_byte(headshot)
                   write_string(weaponname)
                   message_end()
               }
           }
       }
       return PLUGIN_HANDLED
   }
   public regulate_plugins_dm(){
       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,"warcraft3.amx")){
               set_cvar_num("amx_ejl_rpdm",1)
               redundant_plug = 1
           }
       }
       for(new i=0;i<nump;++i){
           get_plugin(i,filename,63,name,63,version,31,author,31,status,3
   1)
           if(get_cvar_num("amx_ejl_rpdm")){
               if(    (equali(filename,"amx_ejl_flamethrower.amx"))    &&
   (strtonum(version[0]) > 4) )
                   redundant_plug = 1
               else   if(   (equali(filename,"cs_flamethrower.amx"))   &&
   (strtonum(version[0]) > 4) )
                   redundant_plug = 1
               else   if(   (equali(filename,"amx_ejl_missiles.amx"))  &&
   (strtonum(version[0]) > 1) )
                   redundant_plug = 1
               else     if(    (equali(filename,"cs_missiles.amx"))    &&
   (strtonum(version[0]) > 1) )
                   redundant_plug = 1
               else   if(   (equali(filename,"amx_ejl_timebomb.amx"))  &&
   (strtonum(version[0]) > 2) )
                   redundant_plug = 1
               else      if(     (equali(filename,"kamikaze.amx"))     &&
   (strtonum(version[0]) > 2) )
                   redundant_plug = 1
               else   if(   (equali(filename,"amx_ejl_jetpack.amx"))   &&
   (strtonum(version[0]) > 1) )
                   redundant_plug = 1
               else    if(    (equali(filename,"luds_jetpack.amx"))    &&
   (strtonum(version[0]) > 1) )
                   redundant_plug = 1
           }
       }
       set_cvar_num("amx_ejl_rpdm",1)
       set_task(1.0,"regulate_plugins_rs")
       return PLUGIN_CONTINUE
   }
   public regulate_plugins_rs(){
       set_cvar_num("amx_ejl_rpdm",0)
       return PLUGIN_CONTINUE
   }

   #endif
   public plugin_init(){
       register_plugin("Laser Guns","2.7.1","EJL")
       register_concmd("amx_lasers","admin_lasers",ADMIN_LEVEL_C,":
   toggles laser guns mode on and off")
       register_concmd("amx_laserbuying","admin_lasersbuy",ADMIN_LEVEL_C,
   ": toggles laser buy requirement mode on and off")
       register_concmd("amx_del_laserstats","admin_delstats",ADMIN_RCON,"
   : deletes all laserstats after writing them to file")
       register_concmd("amx_write_laserstats","admin_fstats",ADMIN_RCON,"
   : toggles forcing laserstats to be written to file on map change")
       register_srvcmd("bot_laser","bot_interface")
       register_cvar("amx_luds_lasers","1",FCVAR_SERVER)
       set_cvar_string("amx_luds_lasers","1")
       register_cvar("amx_laserstats_on","1")
       set_cvar_string("amx_laserstats_on","1")
       register_cvar("amx_laser_buy","0")
       set_cvar_string("amx_laser_buy","0")
       register_cvar("amx_laser_cost","100")
       set_cvar_string("amx_laser_cost","100")
       register_cvar("amx_laser_maxtemp","3440")
       set_cvar_string("amx_laser_maxtemp","3440")
       register_cvar("amx_laser_ammo","50")
       set_cvar_string("amx_laser_ammo","50")
       register_cvar("amx_laser_burndecals","1")
       set_cvar_string("amx_laser_burndecals","1")
       register_cvar("amx_laser_allowinvis","1")
       set_cvar_string("amx_laser_allowinvis","1")
       register_cvar("amx_laser_obeyffcvar","1")
       set_cvar_string("amx_laser_obeyffcvar","1")
       register_cvar("amx_laser_tkpunish1","1")
       set_cvar_string("amx_laser_tkpunish1","1")
       register_cvar("amx_laser_tkpunish2","1")
       set_cvar_string("amx_laser_tkpunish2","1")
       register_cvar("amx_laser_tkpunish3","3")
       set_cvar_string("amx_laser_tkpunish3","3")
       register_cvar("amx_laser_trackbyip","0")
       set_cvar_string("amx_laser_trackbyip","0")
       register_cvar("amx_laser_showip","0")
       set_cvar_string("amx_laser_showip","0")
       register_cvar("amx_laser_botaimdiffuse","16")
       set_cvar_string("amx_laser_botaimdiffuse","16")
       register_clcmd("say /laser","laser_motd")
       register_clcmd("say /lazer","laser_motd")
       register_clcmd("say /laserstats","laser_stats_a")
       register_clcmd("say /laserstats2","laser_stats_m")
       register_clcmd("say /laserstatsme","laser_stats_mee")
       register_clcmd("amx_firelasergun","fire_laser")
       register_clcmd("amx_firelazergun","fire_laser")
       register_clcmd("say","HandleSay")
       register_event("SendAudio","round_end","a","2=%!MRAD_terwin","2=%!
   MRAD_ctwin","2=%!MRAD_rounddraw")
       register_event("TextMsg","round_end","a","2&#Game_C","2&#Game_w")
       register_event("Damage", "laser_sw_con", "b", "2!0", "3=0", "4!0")
       new line, stxtsize
       new data[192]
       new sr[4],sg[4],sb[4]
       if(file_exists("addons/amx/ejl_hud_colors.ini") == 1){
           while((line=read_file("addons/amx/ejl_hud_colors.ini",line,dat
   a,191,stxtsize))!=0){
               parse(data,adscolors[line][3],39,sr,4,sg,4,sb,4)
               adscolors[line][0] = strtonum(sr)
               adscolors[line][1] = strtonum(sg)
               adscolors[line][2] = strtonum(sb)
           }
       }
       new mod_name[32]
       get_modname(mod_name,31)
       cstrike_running = equal(mod_name,"cstrike") ? true : false
       if(cstrike_running){
           new
   sls0[11],sls1[11],sls2[11],sls3[11],sls4[20],sls44[32],sls56[11],sls57
   [11]
           if(file_exists("addons/amx/ejl_laser_stats.ini") == 1){
               while((line=read_file("addons/amx/ejl_laser_stats.ini",lin
   e,data,191,stxtsize))!=0){
                   if(line < 449 && line > -1){
                       parse(data,sls4,19,sls44,31,sls0,10,sls1,10,sls2,1
   0,sls3,10,sls56,10,sls57,10)
                       if(!equal(sls4,"BOT")){
                           new authid[20],name[32]
                           format(laser_statst[line][4],19,"%s",sls4)
                           format(laser_statst[line][24],31,"%s",sls44)

                           laser_statst[line][0] = strtonum(sls0)
                           laser_statst[line][1] = strtonum(sls1)
                           laser_statst[line][2] = strtonum(sls2)
                           laser_statst[line][3] = strtonum(sls3)
                           laser_statst[line][56] = strtonum(sls56) + 1
                           laser_statst[line][57] = strtonum(sls57)
                           format(authid,19,"%s",laser_statst[line][4])
                           format(name,31,"%s",laser_statst[line][24])
                           stats_helper(sls4,sls44,strtonum(sls0),strtonu
   m(sls1),strtonum(sls2),strtonum(sls3))
                       }
                   }
               }
           }
       }
       register_event("ResetHUD", "new_spawn", "b")
       if(get_cvar_num("sv_lan"))
           set_cvar_string("amx_laser_trackbyip","1")
       DoneInit = 1
       new month[16]
       get_time("%m",month,15)
       ejl_vault("WRITE","EJL_LASER_MONTH",month)
       #if use_war3 == 1
       gmsgDeathMsg = get_user_msgid("DeathMsg")
       register_event("DeathMsg", "stop_dm", "a")
       block_message(gmsgDeathMsg)
       set_task(1.0,"regulate_plugins_dm")
       register_cvar("amx_ejl_rpdm","0")
       #endif
       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
   }
