
   /* AMX Mod Script
   *
   * Free otis Plugin
   *
   * 2003 - Lazy
   *
   * Players can get a free otis in any map,
   * just set the maximum they are allowed to have to prevent spam.
   *
   * Origin code credited to SpaceDude
   *
   * Command List:
   *
   * Admin Commands:
   *
   * Say "spawn otis", Say "reset otis"
   *
   * Client Commands:
   *
   * Say "free otis"
   */
   #include <amxmod>
   #include <amxmisc>
   #include <misc>
   new otis[33]
   new flare6
   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 reset_nums()
   {
       for (new i; i < get_maxplayers(); i++)
       {
           otis[i] = 0
       }
   }
   public plugin_precache()
   {
       /* Precache ALL of otis's files - OR ELSE! */

       precache_model("models/otis.mdl")
       precache_model("models/otisf.mdl")

       precache_sound("otis/ot_attack.wav")
       precache_sound("barney/ba_pain1.wav")
       precache_sound("barney/ba_pain2.wav")
       precache_sound("barney/ba_pain3.wav")
       precache_sound("barney/ba_die1.wav")
       precache_sound("barney/ba_die2.wav")
       precache_sound("barney/ba_die3.wav")
       flare6 = precache_model("sprites/flare6.spr")
       return PLUGIN_CONTINUE
   }
   public plugin_init()
   {
       register_plugin("OtisGuard", "1.0", "Lazy")

       register_cvar("max_guards", "1", FCVAR_SERVER)

       register_clcmd("say", "HandleSay", 0, "Catch say")

       reset_nums()

       return PLUGIN_CONTINUE
   }
   public HandleSay(id)
   {
       new chat[256]
       new name[32]
       new numotis

       read_args(chat, 256)

       get_user_name(id, name, 32)

       numotis = get_cvar_num("max_guards")

       if (containi(chat, "free otis") == 1)
       {
           if (numotis == 0)
           {
               client_print(id,  print_chat,  "[AMX]: Feature disabled on
   this server")
           }
           else
           {
               if (otis[id] == numotis)
               {
                   client_print(id,  print_chat,  "[AMX]:  You've used up
   your free Otis for this map")
               }
               else
               {
                   otis[id]++

                   new originplayer[3], originlook[3]

                   get_user_origin(id, originplayer)
                   get_user_origin(id, originlook, 2)

                   new distance[2]

                   distance[0] = originlook[0]-originplayer[0]
                   distance[1] = originlook[1]-originplayer[1]

                   new entityorigin[3]
                   new unitsinfront = 55

                   entityorigin[0]=originplayer[0]+(unitsinfront*distance
   [0])/sqrt(distance[0]*distance[0]+distance[1]*distance[1])
                   entityorigin[1]=originplayer[1]+(unitsinfront*distance
   [1])/sqrt(distance[0]*distance[0]+distance[1]*distance[1])
                   entityorigin[2]=originplayer[2]

                   client_print(0, print_chat, "[AMX]: %s recieves a free
   Otis!", name)
                   client_cmd(0, "spk ambience/alien_humongo")

                   create_monster("monster_otis",      "models/otis.mdl",
   entityorigin,  1,  0, 0, 0, 100, kRenderFxNone, kRenderNormal, 255, 0,
   0, 255, 800.0, SOLID_BBOX, MOVETYPE_WALK, 1)

                   message_begin(MSG_BROADCAST, SVC_TEMPENTITY)

                   write_byte(100)

                   write_coord(entityorigin[0])
                   write_coord(entityorigin[1])
                   write_coord(entityorigin[2])

                   write_short(flare6)
                   write_short(0)

                   message_end()
               }
           }
       }
       else if (containi(chat, "spawn otis") == 1)
       {
           if (!access(id, ADMIN_LEVEL_D))
                 {
                     client_print(id,  print_chat,  "[AMX]:  That  is  an
   admin-only command")

                     return PLUGIN_HANDLED
                 }

           new originplayer[3], originlook[3]

           get_user_origin(id, originplayer)
           get_user_origin(id, originlook, 2)

           new distance[2]

           distance[0] = originlook[0]-originplayer[0]
           distance[1] = originlook[1]-originplayer[1]

           new entityorigin[3]
           new unitsinfront = 55

           entityorigin[0]=originplayer[0]+(unitsinfront*distance[0])/sqr
   t(distance[0]*distance[0]+distance[1]*distance[1])
           entityorigin[1]=originplayer[1]+(unitsinfront*distance[1])/sqr
   t(distance[0]*distance[0]+distance[1]*distance[1])
           entityorigin[2]=originplayer[2]

           client_print(0,  print_chat, "[AMX]: %s spawns a free Otis for
   everyone!", name)
           client_cmd(0, "spk ambience/alien_humongo")

           create_monster("monster_otis",              "models/otis.mdl",
   entityorigin,  1,  0, 0, 0, 100, kRenderFxNone, kRenderNormal, 255, 0,
   0, 255, 800.0, SOLID_BBOX, MOVETYPE_WALK, 1)

           message_begin(MSG_BROADCAST, SVC_TEMPENTITY)

           write_byte(100)

           write_coord(entityorigin[0])
           write_coord(entityorigin[1])
           write_coord(entityorigin[2])

           write_short(flare6)
           write_short(0)

           message_end()
       }
       else if (containi(chat, "reset otis") == 1)
       {
           if (!access(id, ADMIN_LEVEL_D))
                 {
                     client_print(id,  print_chat,  "[AMX]:  That  is  an
   admin-only command")

                     return PLUGIN_HANDLED
                 }

           reset_nums()

           client_print(0,   print_chat,  "[AMX]:  %s  Resets  your  Otis
   counts! Spawn another!", name)
       }

       return PLUGIN_CONTINUE
   }
