
   /*********************************************************************
   **
   * amx_te_model.sma     version 2.3      December 29/2002-Jan 4 2002
   *  By:  Eric Lidman    Alias: Ludwig van      ejlmozart@hotmail.com
   *  Upgrade: http://lidmanmusic.com/cs/plugins.html
   *
   *  The stupidest plugin I ever wrote: Spray temporary models from your
   *   person. Basically lets you play with TE_MODEL from the HL_SDK and
   *   change a few parameters passed to it in-game. All parameters are
   *   optional, the default is one "tree" model for 20 seconds (=255)
   *   Have fun! Oh, yah, this is just the beginning, if you are computer
   *   savy, modify this plugin and add to it whatever you like.
   *
   *   UPDATED!!! Now the spray goes on the direction of your aim.
   *   A big thanks to SpaceDude for coming up with code for that.
   *
   *
   * Command:
   *
   *   amx_te_model [<model type> <number to spray 1-500>
   *                       <speed range -4000 to +4000> <duration 1-255>]
   *
   * Actual Usage:
   *
   *   amx_te_model
   *   amx_te_model headcrab
   *   amx_te_model big_mom 50
   *   amx_te_model tree 10 -500
   *   amx_te_model gasbag 100 3000 255
   *
   * Models to choose from:
   *   random  tree  big_mom  houndeye  leech  fungus  headcrab  zombie
   *   bigrat  bullsquid  gasbag  hgibs  friendly  islave  icky  nihilant
   h
   *
   *   chicken  ----  cstrike  only,  all other mods default this name to
   tree
   *   girl  ---  optional,  needs  model put on server or it defaults to
   tree
   *
   *  Issues:  There  is  no  stop  command, but it will limit you to 500
   models.
   *   Who  needs  one  anyway,  just  be reasonable. If you have alot of
   models
   *   sprayed onto the map there is potential for client video lag. Tell
   em
   *   to  upgrade!  Even  so, the models only last 20 seconds, so no big
   deal.
   *   Assuming  everone's pak file is the same, there should be no issue
   with
   *   the server crashing on startup because it couldnt find a model. I
   *   mention this however because I already ran into it. My test server
   and
   *   my  real  server do not use the same pak file much to my surprise.
   But,
   *   this version works on both my servers and draws on the more common
   *   models so as to avoid this crash possiblilty.
   *
   **********************************************************************
   ***/
   #include <amxmod>
   new girl
   new tree
   new big_mom
   new houndeye
   new leech
   new fungus
   new headcrab
   new zombie
   new bigrat
   new bullsquid
   new gasbag
   new hgibs
   new friendly
   new islave
   new icky
   new nihilanth
   new chicken
   public mod_spawn(id){
       if (!(get_user_flags(id)&ADMIN_LEVEL_H)){
           client_print(id,print_console,"[AMX]  You  have  no  access to
   that command")
           return PLUGIN_HANDLED
       }
       if (read_argc() < 2){
           client_cmd(id,"echo  [AMX]  Ok, well make one random model for
   you  now,  but  usage  is:  amx_te_model  <model>  <quantity>  <speed>
   <duration>")
           client_cmd(id,"echo [AMX] Models: <cstrike only> chicken")
           client_cmd(id,"echo  [AMX]  Models:  <if  server owner allows>
   girl")
           client_cmd(id,"echo        [AMX]        Default        Models:
   random  tree  big_mom  houndeye  leech  fungus  headcrab  zombie")
           client_cmd(id,"echo        [AMX]        Default        Models:
   bigrat  bullsquid  gasbag  hgibs  friendly  islave  icky  nihilanth")
       }
       new arg1[32] // make what
       new arg2[8] // make how many
       new arg3[8] // velocity
       new arg4[8] // duration of existence
       new iarg2
       new iarg3
       new iarg4
       read_argv(1,arg1,32)
       read_argv(2,arg2,8)
       read_argv(3,arg3,8)
       read_argv(4,arg4,8)
       iarg2 = strtonum(arg2)
       iarg3 = strtonum(arg3)
       iarg4 = strtonum(arg4)
       if( (iarg2 < 1) || (iarg2 > 500) ) {
           iarg2 = 1
       }
       if( (iarg3 < -4000) || (iarg3 > 4000) || (iarg3 == 0) ) {
           iarg3 = 1000
       }
       if( (iarg4 < 1) || (iarg4 > 255) ) {
           iarg4 = 255
       }
       new csid[35]
       csid[0] = id
       csid[1] = iarg3
       csid[2] = iarg4
       copy(csid[3],32,arg1)
       set_task(0.2,"make_mod",1316,csid,35,"a",iarg2-1)
       return PLUGIN_HANDLED
   }
   public sqrt(num) {
       new div = num
       new result = 1
       while (div > result) { // end when div == result, or just below
           div = (div + result) / 2 // take mean value as new divisor
           result = num / div
       }
       return div
   }
   public make_mod(id[]){
       new vec[3]
       new aimvec[3]
       new velocityvec[3]
       new length
       new speed = id[1]
       get_user_origin(id[0],vec)
       get_user_origin(id[0],aimvec,2)
       velocityvec[0]=aimvec[0]-vec[0]
       velocityvec[1]=aimvec[1]-vec[1]
       velocityvec[2]=aimvec[2]-vec[2]
       length=sqrt(velocityvec[0]*velocityvec[0]+velocityvec[1]*velocityv
   ec[1]+velocityvec[2]*velocityvec[2])
       velocityvec[0]=velocityvec[0]*speed/length
       velocityvec[1]=velocityvec[1]*speed/length
       velocityvec[2]=velocityvec[2]*speed/length
       new imodel
       if(equal(id[3],"random")){
           imodel = random(6)
           if(imodel == 0)
               imodel = big_mom
           else if(imodel == 1)
               imodel = tree
           else if(imodel == 2)
               imodel = bullsquid
           else if(imodel == 3)
               imodel = headcrab
           else if(imodel == 4)
               imodel = zombie
           else if(imodel == 5)
               imodel = hgibs
       }
       else if(equal(id[3],"girl")){
           imodel = girl
       }
       else if(equal(id[3],"tree")){
           imodel = tree
       }
       else if(equal(id[3],"big_mom")){
           imodel = big_mom
       }
       else if(equal(id[3],"houndeye")){
           imodel = houndeye
       }
       else if(equal(id[3],"leech")){
           imodel = leech
       }
       else if(equal(id[3],"fungus")){
           imodel = fungus
       }
       else if(equal(id[3],"headcrab")){
           imodel = headcrab
       }
       else if(equal(id[3],"zombie")){
           imodel = zombie
       }
       else if(equal(id[3],"bigrat")){
           imodel = bigrat
       }
       else if(equal(id[3],"bullsquid")){
           imodel = bullsquid
       }
       else if(equal(id[3],"gasbag")){
           imodel = gasbag
       }
       else if(equal(id[3],"hgibs")){
           imodel = hgibs
       }
       else if(equal(id[3],"friendly")){
           imodel = friendly
       }
       else if(equal(id[3],"islave")){
           imodel = islave
       }
       else if(equal(id[3],"icky")){
           imodel = icky
       }
       else if(equal(id[3],"nihilanth")){
           imodel = nihilanth
       }
       else if(equal(id[3],"chicken")){
           imodel = chicken
       }
       if(imodel == 0)
           imodel = tree
       // TE_MODEL from HL-SDK common/const.h
       message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
       write_byte(106)
       write_coord(vec[0])
       write_coord(vec[1])
       write_coord(vec[2]+20)
       write_coord(velocityvec[0])
       write_coord(velocityvec[1])
       write_coord(velocityvec[2]+100)
       write_angle (0)
       write_short (imodel)
       write_byte (2)
       write_byte (id[2])
       message_end()
   }
   public plugin_precache(){
       //  the "girl_hostage.mdl" is not in the pak file, but I use in in
   my version
       //  because I like things of beauty, the whole reason I wrote this
   silly thing.
       //  I  have attached it to this post, all you have to do is put it
   into your
       // ..%modname%/models folder
       tree = precache_model("models/tree.mdl")
       big_mom = precache_model("models/big_mom.mdl")
       houndeye = precache_model("models/houndeye.mdl")
       bullsquid = precache_model("models/bullsquid.mdl")
       leech = precache_model("models/leech.mdl")
       fungus = precache_model("models/fungus.mdl")
       headcrab = precache_model("models/headcrab.mdl")
       zombie = precache_model("models/zombie.mdl")
       bigrat = precache_model("models/bigrat.mdl")
       gasbag = precache_model("models/gasbag.mdl")
       hgibs = precache_model("models/hgibs.mdl")
       friendly = precache_model("models/friendly.mdl")
       islave = precache_model("models/islave.mdl")
       icky = precache_model("models/icky.mdl")
       nihilanth = precache_model("models/nihilanth.mdl")
       if(file_exists("models/girl_hostage.mdl")==1)
           girl = precache_model("models/girl_hostage.mdl")
       new modname[32]
       get_modname(modname,32)
       if(equal(modname,"cstrike")){
           chicken = precache_model("models/chick.mdl")
       }
       return PLUGIN_CONTINUE
   }
   public plugin_init(){
       register_plugin("Admin TE_MODEL","0.8","EJL")
       register_clcmd("amx_te_model","mod_spawn",ADMIN_LEVEL_H,"amx_te_mo
   del  <model> <quantity 1-500> <speed -4000 to 4000> <duration 1-255> :
   spray temporary models from yourself" )
       return PLUGIN_CONTINUE
   }
