// New in this version:
// 10/26/02 FIXED: Compliant with adminmod 2.50.50
// 8/22/02  FIXED: stuck player routine works now
// 8/22/02  FIXED: player to player transport more accurate / tweak spawn
// 8/11/02  ADDED: prevention of enemy spawn transporting at round start(CS) 
// 6/22/02  ADDED: admin_scotty_default
// 6/22/02  ADDED: admin_scotty_revoke
// 6/20/02  ADDED: admin_scotty and more player transport options
// 6/20/02  FIXED: Plugin no longer dies after 42 transports (memory leak). 
//
/***************************************************************************
 *  plugin_ejl_beammeup.sma  release version 2.0         Date: 10/26/2002
 *   Author: Eric Lidman     ejlmozart@hotmail.com
 *   Alias: Ludwig van       Upgrade: http://lidmanmusic.com/cs/plugins.html          
 *
 *
 * Ever watch the orignal Star-Trek TV show? This is a fun plugin which
 *  gives limited teleporting powers (you can decide how limited) to
 *  players using the theme of the Star-Trek matter transporter. There
 *  are sounds from the show too, including our favorite first engineer,
 *  the keeper of the transporter, Scotty. This plugin should work with
 *  all Half-Life multiplayer team based mods with upto 4 teams (see
 *  admin_scotty_setbeam to set it up for mods other than Counter-Strike). 
 *
 * Here are the admins scotty control commands:
 *
 *  admin_scotty_on         --- resets to default, only "beam me up" allowed
 *  admin_scotty_off        --- shuts scotty down completely (we dont here)
 *  admin_scotty_unlimited  --- lets "beam me up" be used unlimited times
 *  admin_scotty_crazy      --- fully functional transporter
 *  admin_scotty_insane     --- fully functional transporter
 *                              coordinates can be gathered anytime
 *                              beaming to enemy spawn (CS) is permitted
 *                              even at round start 
 *  admin_scotty_default    --- sets the current scotty mode as default by 
 *                              writing it to the vault file and loading 
 *                              it at map start when plugins are initialized.
 *                              Admin ACCESS_RCON is required to set default. 
 *  admin_scotty_reset      --- if always stuck busy with noone beaming
 *                              Admin ACCESS_RCON is required for this too.
 *                              (sort of obsolete at this point anyway what
 *                              with all the automtic resets built in now)
 *  admin_scotty_override   --- forces players to use maps preset coordinates
 *                              even if they had their own coordinates locked
 *  admin_scotty_reload <leave blank or put "custom">
 *                    --- reloads a maps default beam me up coordiantes.
 *			        If used this way, "admin_scotty_reload custom"
 *                        then the coordinates saved by the setbeam 
 *		              command will be reloaded over the default
 *			        ones. To get the default ones back just issue
 *			        "admin_scotty_reload".  
 *  admin_scotty_setbeam <team_number> or <team_number z_modifier> or
 *			        <team_number x y z z_modifier>   
 *			    --- this command sets new coordinates for "Beam me
 *			        up scotty". For that mapload, they override the 
 *			        transporter_xyz.txt unless the reload command
 *			        is used. It can be issued 3 ways. Example:
 *				    admin_scotty_setbeam 1
 *				    admin_scotty_setbeam 1 100
 *				    admin_scotty_setbeam 1 -323 98 123 100
 *			        The first way sets coordinates for team 1 with
 *			        the admins own coordinates. Team 1 in CS is
 *			        the Terrorists, in TFC thats Blue. The second
 *			        way sets team 1 coordinates with the admins
 *			        own coordinates with 100 added to the height.
 *			        The third way sets team 1 coordinates with the
 *			        x,y, and z numbers with 100 added to the z. The 
 *			        z modifier value is unnecessary. You may notice
 *			        that the default coordinates provided in the
 *   			        transporter_xyz.txt are almost all 100 height
 *			        higher than the ground. This was to help prevent
 *			        a person from transporting into another. It
 *			        seemed to be a problem. Anyway, this command is
 *			        useful for setting team beam up points on maps
 *			        which are not listed in the transporter_xyz.txt.
 * 			        In fact, it is essential for those using mods 
 *			        other than Counter-Strike as I have provided no
 *			        default "beam me up scotty" coordinates for other
 *			        mods like TFC, DoD, etc. You have to set your own. 
 *			        They are automatically saved to the
 * 			        transporter_custom.txt and then automatically 
 *			        reloaded everytime thereafter that map is played.
 *			        If multiple coordinates for a team/map are
 *			        entered, only the last ones are used.
 *
 *  admin_scotty <player> <various_parameters>
 *                    --- admin can use scotty to teleport another player
 *                        in different ways -- to either team's spawn point,
 *                        to another player, to numerical xyz coordinates, 
 *                        or even to the admin's or any players saved 
 *                        coordinates from, yes "scotty lock onto my
 *                        coordinates". I mean, why not, they are stored in
 *                        memory, we are just retieving them and using the
 *                        saved lock coordinates for other players.
 *                        Usage:
 *                          admin_scotty <player> to <team> base
 *                          admin_scotty <player> to <player2>
 *                          admin_scotty <player> to <player2> <lock 1,2 or 3>
 *                          admin_scotty <player> <x> <y> <z>
 *                        Actual examples of usage:                          
 *                          admin_scotty ludwig to ct base
 *                          admin_scotty ludwig to vodka
 *                          admin_scotty ludwig to vodka 3
 *                          admin_scotty ludwig 100 100 100
 *
 *  admin_scotty_revoke <player> <optional time in minutes to revoke>
 *                    --- admin can revoke a player's scotty privilages while
 *                        leaving other player's scotty privilages untouched.
 *                        If there is no time given, the default of 15 minutes
 *                        will be the time scotty privilages are revoked for.
 *                        Maximum time is 60 minutes. If the command is used 
 *                        again on the same player, his privilages are granted
 *                        back to him.
 *                        Usage:
 *                          admin_scotty_revoke <player>
 *                          admin_scotty_revoke <player> <minutes>
 *                        Actual examples of usage:                          
 *                          admin_scotty_revoke ludwig
 *                          admin_scotty_revoke ludwig 20
 *
 *
 * For Players:
 *
 *      Say: vote_scotty    -- sets up a vote to enable admin_scotty_crazy
 *                             (only works if fun_mode is enabled)
 *
 *  Here is the command to use the transporter in its minimum mode. It
 *  transports you back to your own spawn point:
 *
 *      say: beam me up scotty
 *
 *  With admin_scotty_crazy mode you can save up to any 3 locations on a map
 *  with while alive with the commands below: 
 * 
 *      say: scotty lock onto my coordinates        --- save set 1
 *      say: scotty lock 2 onto my coordinates      --- save set 2
 *      say: scotty lock 3 onto my coordinates      --- save set 3
 *
 *  To go transport to those saved coordinates (if it is near round start
 *  and the coordinates are close to enemy spawn, transport will be denied):
 *
 *      say: scotty energize                        --- go to set 1
 *      say: scotty energize 2 now                  --- go to set 2
 *      say: scotty energize 3 now                  --- go to set 3
 *
 *  To beam to the last place one of your teamates beammed to (follow him):
 *
 *      say: scotty beam me to my teamates
 *  
 *  To beam to a particular teammate, use his name where it says <player>.
 *  You may also beam to that players saved coordinates from that player's
 *  "scotty lock onto my coordinates" command. Very cool.   
 *
 *      say: scotty beam me to <player>
 *      say: scotty beam me to <player> <1, 2, or 3 coordinates>
 *
 *      Actual usage with coordinates:   say: scotty beam me to Ludwig 3
 * 
 * To gather coordinates while dead admin_scotty_insane has to be enabled
 *  and will only last as long as the admin who enabled it stays connected
 *  for the reason that things could get out of hand with players
 *  transporting off the map and no admin there to take care of them.
 *  There is a built in protection against players who got stuck 
 *  transporting off the map or into a wall, but it only works if the
 *  player cant move at all. This player will be sent back to base and
 *  be buried. Also, under admin_scotty_insane, you are permitted to beam
 *  to enemy spawn at round start (CS).
 *
 * Also, under admin_scotty_insane, you can "say: where am i scotty" and
 *  the numeric x,y,z coordinates will be given to you. To go to any
 *  numeric x,y,z coordinates, "say: scotty -948 99 704" or whatever set of
 *  3 numbers you want. This was the old way, but I left it in and made
 *  accessible in insane mode only. One more insane mode feature is to
 *  transport to enemy base by "say: scotty beam me up". (instead of the
 *  home base command "say: beam me up scotty" -- a subtle difference.)
 * 
 *      say: where am i scotty
 *      say: scotty beam me up   
 *
 * Under all scotty modes only one transporting can occur at any given time.
 *  But if you huddle together with somenone who is transporting, you go
 *  with them to wherever they go.
 *
 * For the mod TFC, if you are carrying a KEY or a FLAG, scotty is not
 *  supposed to let you transport. I tested this on a few maps and it
 *  seems to work properly. Let me know if there are problems. In order
 *  for this particular feature to work, you need to be using the
 *  metamod plugin, LogD. Get it here:  http://logd.sourceforge.net/
 *  Once you get LogD, make sure logging is on and I think logdetail may
 *  need to be set to 3 in your server.cfg. Not sure on that one.
 *
 * Installation:
 *
 * The transporter_xyz.txt goes in your mod (cstrke) directory.  All
 *  the sound (.wav) files go into your ..\sounds\misc   directory.
 *  To be more fun, all the clients should have the sounds in their
 *  ..sounds\misc too. You can auto download them to people using the 
 *  .res files provided in this package. These files go into the ..\maps
 *  directory unless you already have .res files there of the same name. 
 *  In that case you will want to change the names to maps which dont yet
 *  have .res files. Preferably these will be maps you play often so that
 *  the sounds will propagate faster to more of your clients. The
 *  remainder of the files should be traeted as you would for any other
 *  plugin. General instructions on installing plugins are in the
 *  adminmod manual under scripting.
 * 
 * Other intallation notes:
 *  
 *  Sound.inc:    If you plan to make changes to the plugin source such 
 *  as setting the default scotty mode to off, as some may wish to do,
 *  you must make sure that the sound.inc file is in this folder:
 *  ..\scripting\include -- otherwise you will get errors when you try
 *  to compile it. sound.inc is include in this plugin package. 
 *
 *  Switches:     Immedialety below the readme section in the .sma
 *  file are some switches which allow mod specific features as well
 *  as some values that can be adjusted to your liking. You can set
 *  the default mode of the trasporter here using "true" and "false".
 *  In order for a switch change to work, you need to recompile the
 *  plugin.
 * 
 *  Adminmod.cfg:    There are a few things that you need to change in
 *  your adminmod.cfg file. Find these cvars listed below and change
 *  their values to what you see here:
 *
 *     allow_client_exec 1
 *     sv_allowdownload 1
 *     file_access_read 1
 *     file_access_write 1
 *     admin_fx 1
 *
 * Last notes: If you remember the show, you know that the transporter
 *  was not a 100% reliable piece of equipment. That effect has been 
 *  inadvertantly reproduced in this plugin. It just worked out that
 *  way. The tranporter in my plugin relies on those rather flakey 
 *  timers that we scripters are given to work with. Dont look at it
 *  as a bug, but as an enhancement which makes it more realistic.
 * 
 * Acknowledgements: I just want to thank all the coders whose code I
 *  more or less stole to put this thing together. There are so many 
 *  little snippets I cant even begin to count them all. Names like,
 *  Sank, Dio, Milkman, and Cavey come immediately to mind. Also, I am 
 *  greatful to the guys on the adminmod scripting forums for helping
 *  me with the testing, like leo008 and STUMPER for their suggestions
 *  to make it more TFC and other mod friendly.
 *
 * You may want to make known to players what the basic scotty commands
 *  are. I do it right in my motd or on my server connect screen. 
 *
 *********************************************************************/
