Raised This Month: $32 Target: $400
 8% 

[TF2] Remote Control/Build/Limit buildings plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author
naris
AlliedModders Donor
Join Date: Dec 2006
Plugin ID:
985
Plugin Version:
5.0
Plugin Category:
Fun Stuff
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
    9 
    Plugin Description:
    Remote Control and/or Build bulldings. Also includes build limit plugin functionality.
    Old 07-07-2009 , 13:27   [TF2] Remote Control/Build/Limit buildings plugin
    Reply With Quote #1

    This plugin is based on twistedeuphoria's plugin (http://forums.alliedmods.net/showthread.php?t=95757) to Remote Control Sentries.

    It added the ability to not only remote control sentries, but also to build/spawn them. It also incorporates DJ Tsunami's Build Restrictions/Limit plugin (http://forums.alliedmods.net/showthread.php?p=642578)

    This plugin also has an extensive native interface that allows it to be called from other plugins to build buildings or perform other actions.

    The following convars are available to customize the plugin:

    sm_remote_enable(1/0, default 1)
    Enable or disable remote control.

    sm_remote_steal (1/0, default 1)
    Set true to allow stealing other people's buildings.

    sm_remote_build (1/0, default 0)
    Set true to spawn desired building if it doesn't exist.

    sm_remote_build_level (0-3, default 1)
    Max level building that can built.

    sm_remote_build_mini (0-1, default 1)
    Set true to allow mini sentries to be built.

    sm_remote_instant (1/0, default 0)
    Set true to build buildings instantly (from the remote menu)

    sm_remote_always_builds (1/0, default 0)
    Set true allow remote to always build new objects (within limits).

    sm_remote_factor (default 0.50)
    Factor multiplied by (4 - sentry level) then multiplied by speed.

    sm_remote_speed (default 300.0)
    Speed at which remote objects move.

    sm_remote_jump (default 2000.0)
    Speed at which remote objects jump.

    sm_remote_fall (default 500.0)
    Speed at which remote objects fall.

    The following convars are available to limit building:

    sm_buildlimit_enabled (1/0, default 1)
    Enable/disable restricting buildings in TF2.

    sm_buildlimit_immunity (1/0, default 0)
    Enable/disable admin immunity for restricting buildings in TF2.

    sm_buildlimit_red_dispensers
    sm_buildlimit_red_teleporters
    sm_buildlimit_red_sentries
    Limits for Red buildings in TF2. (number of buildings a player can build. Default 1)

    sm_buildlimit_blu_dispensers
    sm_buildlimit_blu_teleporters
    sm_buildlimit_blu_sentries
    Limits for Blu buildings in TF2. (number of buildings a player can build. Default 1)


    The following commands are available:

    sm_remote_on : Start remote controlling your buildings(sentry gun) (depreciated)
    sm_remote_off : Stop remote controlling your buildings. (depreciated)

    sm_remote : Start/stop remote controlling your buildings.

    sm_remote_sentry : Start/stop remote controlling your sentry gun.
    sm_remote_enter : Start/stop remote controlling your teleport entrance.
    sm_remote_exit : Start/stop remote controlling your teleport exit.
    sm_remote_disp : Start/stop remote controlling your dispenser.

    sm_build : Build an object.
    sm_build_sentry : Build a sentry gun.
    sm_build_enter : Build a teleport entrance.
    sm_build_exit : Build a teleport exit.
    sm_build_disp : Build a dispenser.

    This is the native interface, callable form other plugins:

    PHP Code:
    // These define the permissions
    #define HAS_REMOTE                     (1 << 0)
    #define REMOTE_CAN_ZOMBIE            (1 << 1)
    #define REMOTE_CAN_STEAL            (1 << 2)
    #define REMOTE_CAN_BUILD_INSTANTLY    (1 << 3)
    #define REMOTE_CAN_BUILD_FLOATING     (1 << 4)
    #define REMOTE_CAN_BUILD_MINI       (1 << 5)
    #define REMOTE_CAN_BUILD_LEVEL_1    (1 << 6)
    #define REMOTE_CAN_BUILD_LEVEL_2    (1 << 7)
    #define REMOTE_CAN_BUILD_LEVEL_3    (1 << 8)
    #define REMOTE_CAN_BUILD_AMPLIFIER  (1 << 9)
    #define REMOTE_CAN_BUILD_REPAIR     (1 << 10)

    #define REMOTE_CAN_BUILD            (REMOTE_CAN_BUILD_MINI|REMOTE_CAN_BUILD_LEVEL_1|REMOTE_CAN_BUILD_LEVEL_2|REMOTE_CAN_BUILD_LEVEL_3)
    #define REMOTE_CAN_BUILD_UPGRADED   (CAN_BUILD_LEVEL_2|CAN_BUILD_LEVEL_3)
    #define CAN_BUILD_ACTIVATED         REMOTE_CAN_BUILD_INSTANTLY

    /**
     * Assume control of the remote plugin
     *
     * @param plugin_only     Set to 1 to assume complete control of remotesentries.
     * @return                none
     */
    native ControlRemote(bool:plugin_only=true);

    /**
     * Give a remote control to the player
     *
     * @param index         Client index
     * @param permissions   Permissions to use, set 0 to disable (default=-1 to use ConVars)
     * @param speed         Speed that Remote Controlled object move.
     * @param fall_speed    Speed used when Remote Controlled objects fall.
     * @param jump_speed    Speed used when Remote Controlled objects jump.
     * @return                none
     */
    native SetRemoteControl(clientpermissions=-1Float:speed=-1.0Float:fall_speed=-1.0Float:jump_speed=-1.0);

    /**
     * Remote Control an object
     *
     * @param index     Client index
     * @param type:     Type of object to control
     * @return            none
     */
    native RemoteControlObject(clientTFExtObjectType:type=TFExtObject_Unknown);

    /**
     * Stop Remote Controlling an object (if any)
     *
     * @param index     Client index
     * @return            none
     */
    native StopControllingObject(client);

    /**
     * Gets called when controlling a building
     *
     * @param client:   The index of the client that used the remote control.
     * @param builder:  The index of the builder of the building that got controlled
     * @param ent:      The index of the building that got grabbed
     */
    forward Action:OnControlObject(client,builder,ent);

    /**
     * Gets called when building a building
     *
     * @param client:   The index of the client that want to build a building.
     * @param ent:      The index of the building that got grabbed
     */
    forward Action:OnBuildObject(client,TFExtObjectType:type);

    /**
     * Description: Native Interface to build
     */

    /**
     * Build a Sentry
     *
     * @param iBuilder             Client index of builder
     * @param fOrigin           Position fotr new Sentry
     * @param fAngle            Angles for new Sentry
     * @param iLevel            Level for new Sentry
     * @param bDisabled         Disabled flag
     * @param bMini             Mini Sentry flag (causes the flashing light to be attached, and make them un-repairable or upgradable)
     * @param bShielded         Shielded flag (causes the sentry to have a shield)
     * @param iHealth           Health of the Sentry
     * @param iMaxHealth        Max Health of Sentry
     * @param iShells           Number of shells Sentry spawns with
     * @param iRockets          Number of rockets Sentry spawns with
     * @param flPercentage      Value to use for flPercentageConstructed
     * @return                    entity index of new Sentry
     */
    native BuildSentry(iBuilder, const Float:fOrigin[3], const Float:fAngle[3], iLevel=1,
                       
    bool:bDisabled=falsebool:bMini=falsebool:bShielded=false,
                       
    iHealth=-1iMaxHealth=-1iShells=-1iRockets=-1,
                       
    Float:flPercentage=1.0);

    /**
     * Build a Dispenser
     *
     * @param iBuilder             Client index of builder
     * @param fOrigin           Position fotr new Dispenser
     * @param fAngle            Angles for new Dispenser
     * @param iLevel            Level for new Dispenser
     * @param iDisabled         Disabled flag
     * @param iHealth           Health of the Dispenser
     * @param iMaxHealth        Max Health of Dispenser
     * @param iMetal            Amount of metal Dispenser spawns with
     * @param flPercentage      Value to use for flPercentageConstructed
     * @param type              Type of dispenser to build (which model to use - Dispenser, Amplifier or Repair Node)
     * @return                    entity index of new Dispenser
     */

    native BuildDispenser(iBuilder, const Float:fOrigin[3], const Float:fAngle[3], iLevel=1,
                          
    bool:iDisabled=falseiHealth=-1iMaxHealth=-1iMetal=-1,
                          
    Float:flPercentage=1.0TFExtObjectType:type=TFExtObject_Dispenser);

    /**
     * Build a Teleporter Entry
     *
     * @param iBuilder             Client index of builder
     * @param fOrigin           Position fotr new Teleporter Entry
     * @param fAngle            Angles for new Teleporter Entry
     * @param iLevel            Level for new Teleporter Entry
     * @param iDisabled         Disabled flag
     * @param iHealth           Health of the Teleporter Entry
     * @param iMaxHealth        Max Health of Teleporter Entry
     * @param flPercentage      Value to use for flPercentageConstructed
     * @return                    entity index of new Teleporter Entry
     */
    native BuildTeleporterEntry(iBuilder, const Float:fOrigin[3], const Float:fAngle[3],
                                
    iLevel=1bool:iDisabled=falseiHealth=-1iMaxHealth=-1,
                                
    Float:flPercentage=1.0);

    /**
     * Build a Teleporter Exit
     *
     * @param iBuilder             Client index of builder
     * @param fOrigin           Position fotr new Teleporter Exit
     * @param fAngle            Angles for new Teleporter Exit
     * @param iLevel            Level for new Teleporter Exit
     * @param iDisabled         Disabled flag
     * @param iHealth           Health of the Teleporter Exit
     * @param iMaxHealth        Max Health of Teleporter Exit
     * @param flPercentage      Value to use for flPercentageConstructed
     * @return                    entity index of new Teleporter Exit
     */
    native BuildTeleporterExit(iBuilder, const Float:fOrigin[3], const Float:fAngle[3],
                               
    iLevel=1bool:iDisabled=falseiHealth=-1iMaxHealth=-1,
                               
    Float:flPercentage=1.0);

    /**
     * Build an object where the client is standing
     *
     * @param client             Client index of builder
     * @param type              Type of object to build
     * @param iLevel            Level for new Building
     * @param bMini             Mini Sentry flag (causes the flashing light to be attached, and make them un-repairable or upgradable)
     * @param bShielded         Shielded flag (causes the sentry to have a shield)
     * @param bDisabled         Disable the building temporarily after building.
     * @param check             Check the build limit before bulding.
     * @param iHealth           Health of the Teleporter Exit
     * @param iMaxHealth        Max Health of Teleporter Exit
     * @param remote            Remote control the building after building it.
     * @param drop              Drop the building after building (to ensure it's on the ground) - requires ztf2grab plugin to work.
     * @param pos               Returns the position the object was built at.
     * @return                    entity index of new Object
     */
    native BuildObject(clientTFExtObjectType:typeiLevel=1bool:bMini=false,
                       
    bool:bShielded=falsebool:bDisabled=trueiHealth=-1,
                       
    iMaxHealth=-1Float:flPercentage=1.0bool:remote=false,
                       
    bool:drop=truebool:check=trueFloat:pos[3]={0.0});

    /**
     * Counts buildings of all classes owned by client
     *
     * @param client             Client index of builder
     * @param counts            Array to hold the counts of all buildings by type.
     * @return                    count of all buildings.
     */
    native CountBuildings(clientcounts[TFExtObjectType]={0});

    /**
     * Counts objects of the given class owned by client
     *
     * @param client             Client index of builder
     * @param class             Classname of entities to count.
     * @param mode              m_iObjectMode of entities to count (-1=any)
     * @return                    count of all buildings.
     */
    native CountObjects(client, const String:class[], mode=-1);

    /**
     * Adds buildings owned by client to a menu.
     *  (The SelectionInfo of each menu item will be set to the stringized value of an EntRef for the building)
     *
     * @param menu              Menu to add buildings to
     * @param client             Client index of builder
     * @param all               Include unfinished buildings in the menu
     * @param counts            Array to hold the building counts by type.
     * @param target            Entity ID of last object added to the menu
     * @return                    count of buildings added
     */
    native AddBuildingsToMenu(Handle:menuclientbool:all=false,
                              
    counts[TFExtObjectType]={0}, &target=0);

    /**
     * Destroys buildings
     *
     * @param client             Client index of builder, -1 for all builders.
     * @param all                Set to false to only destroy buildings that have been spawned by this plugin
     * @return                    count of buildings destroyed
     */
    native DestroyBuildings(client=-1bool:all=true);

    /**
     * Presents a menu of buildings for client to pick one to destroy.
     *
     * @param client             Client index of builder
     * @return                    true if there were buildings to destroy
     */
    native bool:DestroyBuildingMenu(client);

    /**
     * Destroys the specified building.
     *
     * @param object             Entity (building object) to destroy.
     * @return                    none
     */
    native DestroyBuilding(object);

    /**
     * Description: Native Interface to buildlimit
     */

    /**
     * Assume control of the buildlimit plugin
     *
     * @param plugin_only     Set to 1 to assume complete control of the Firemines plugin.
     * @return                none
     */
    native ControlBuild(bool:plugin_only=true);

    /**
     * Sets the number of buildings the payer can build.
     *
     * @param index             Client index
     * @param sentry            Set to number of sentries the player can build. (-1 is unlimited)
     * @param dispenser         Set to number of dispensers the player can build. (-1 is unlimited)
     * @param teleport_entry    Set to number of teleport_entrys the player can build. (-1 is unlimited)
     * @param teleport_exit     Set to number of teleport_exits player can build. (-1 is unlimited)
     * @return                    none
     */
    native GiveBuild(client,sentry=1,dispenser=1,teleport_entry=1,teleport_exit=1);

    /**
     * Reset the build restriction back to 1 of each type of building.
     *
     * @param index     Client index
     * @return            none
     */
    native ResetBuild(client);

    /**
     * Check if the client is allowed to build the building.
     *
     * @param index     Client index
     * @param type      Type of object to check
     * @param mode:     Mode of object to check (-1=don't check mode)
     * @param count     Reference that returns the number of existing buildings
     * @return            true if the building can be built.
     */
    native bool:CheckBuild(client,TFObjectType:type,mode=-1,&count=0);

    /**
     * Gets called when the build command is issued to build a building
     *
     * @param client:   The index of the client that is building
     * @param type:     The type of building being built
     * @param mode:     The mode of building being built (0=Teleporter Entrance, 1=Exit, -1=N/A)
     * @param count:    The number of that type of building already built by client
     * @return          Plugin_Handled will block building.
     */
    forward Action:OnBuildCommand(client,TFObjectType:type,mode,count); 
    Change log
    Code:
    2/23/2012 - v5.1
    
    • Fixed "level 4" sentries to have 256 hp instead of > 4000.
    • Fixed tf2_objects.inc
    • Replaced TF2_Is<condition>() with TF2_IsPlayer<condition>()
    • Fixed possible issue with remote admin immunity checking.
    • Updated for various TF2 updates.
    • Various bug fixes.
    11/9/2010 - v5.0
    • Integrated with amp_node plugin to build Amplifiers and Repair Nodes.
    • Set sm_remote_build_level to 0 to prevent building normal sentries while still allowing mini sentries to be built (if sm_remote_build_mini is true)
    • Various bug fixes.
    7/13/2010 - v4.2
    • Fixed invalid handle error.
    7/13/2010 - v4.1
    • Fixed not allowing more then 1 of each building when using the remote or sm_build commands while using the plugin standalone.
    7/11/2010 - v4.0
    • Fixed models used for level 2 and 3 dispensers
    • Added support for Mini Sentries
    5/23/2010 - v3.2
    • Fixed issues with teleporters
    • Added limited support for Amplifiers
    5/8/2010 - v3.1
    • Fixed not being able to remote control an existing building
    • Fixed not being able to remote control a targeted building
    • Added check parameter to BuildObject() native
    5/8/2010 - v3.0
    • Fixes for TF2 119 update
    • Fix Build Limits for Teleporters
    • Set m_iObjectMode for Teleporters
    • Don't allow dead ringers spys to control objects
    • Check entity limits
    • Track EntRefs instead of Entity Indices
    • Changed Forwards to Global Forwards
    10/15/2009 - v2.0
    • Don't allow cloaked spys to build buildings and un-disguise spys when they build things
    • Fixed Property "m_hBuilder" not found error
    • Added StopContollingObject() primitive to remote
    • Changed default for sm_remote_object to false Hook player_death in remote and stop controlling unless the zombie flag is set
    • Build objects in noclip instead of teleporting builder on top.
    • Added BuildObject() native to remote
    • Changed Build Natives to sanitize iLevel.
    • Fixed Remote Control teleporting people off the map and in other strange places when the object get killed.
    • Changed remote to remove all built objects on round end or when a player switches teams.
    • Changed DestroyAllBuildings() to use FindEntityByClassname() instead of looping through entities.
    • Removed REMOTE_ALWAYS_BUILDS flag
    • Changed CountBuildings() and AddBuildingsToMenu(), to use FindEntityByClassname()
    • Added counts[] array parameter to AddBuildingsToMenu()
    • Reduced counts[] array parameter size from 5 to 4
    • Changed RemoteControl() to check for targets before checking type.
    • Changed RemoteControl() to add build options to the Remote Control menu (if applicable).
    • Moved Build Options in Remote Menu to be 1st.
    • Fixed CountBuildings() native to return the sum.
    • Changed remote to noclip sentries built to remote control if the remote control fails (due to lack of energy, etc.)
    • Changed remote to not change the CollisionGroup back to 0 in Activate() if the builder is too close.
    • Changed remote to noclip sentries in RemoteOff() if the builder is too close.
    • Replaced constant 50.0 with m_vecBuildMaxs[0] when checking distances between players and objects.
    • Fixed errors in remote by changing RemoteOff() to only check and set collision groups for objects that still exist
    • Changed DestroyBuuilding() to DestroyBuildingMenu()
    • Added DestroyBuilding() function to destroy a specific building object. Changed code that destroy's buildings to blow them up (subtract 1000 health) instead of just removing them.
    • Changed BuildObject() to use GetClientEyeAngles() instead of GetClientAbsAngles() for the object's angles.
    • Increased initial disabled time for newly built sentries to 10 seconds per level (1,2,3)
    • Fixed being able to build 1 more structure than you are supposed to.
    • Changed remote to use the ztf2grab plugin to cause newly build objects to fall to the ground.
    • Added CAN_BUILD_FLOATING to remote permissions bits
    • Added drop flag to BuildObject()
    • Added CountObjects() native to remote.inc
    • Added sm_build_objects_txt convar to remote to allow engineer to spawn buildings if it is false (to indicate objects.txt has not been modified)
    • Changed CheckBuild() to call CountObjects()
    • #define MAXENTITIES 2048 instead of using constant.
    • Use the fairly new index parameter for player_builtobject and object_destroyed.
    • Fixed DestroyBuildingsMenu() in remote
    • Use EdictClass instead of NetClass to determine object/building type
    • Cleaned up entity/edict checking
    7/15/2009 - v1.2
    • Added sm_remote_zombie to stop controlling buildings when the controller dies
    • Don't allow cloaked or disgused spys or bonked scouts remote control buildings
    • Included tf2_player.inc to allow compilation using SM's web compiler
    • Fixed convars (such as sm_remote_instant) not working
    7/10/2009 - v1.1
    • Fixed CountBuildings() native..
    • Fixed sm_remote/sm_build commands not obtaining correct building type.
    • Replaced sm_buildlimit_red_teleport_entrances & sm_buildlimit_red_teleport_exits with sm_buildlimit_red_teleporters
    • Replaced sm_buildlimit_blu_teleport_entrances & sm_buildlimit_blu_teleport_exits with sm_buildlimit_blu_teleporters
    Attached Files
    File Type: sp Get Plugin or Get Source (remote.sp - 4896 views - 95.3 KB)
    File Type: inc remote.inc (12.7 KB, 1828 views)
    File Type: sp Get Plugin or Get Source (ztf2grab.sp - 3883 views - 64.3 KB)
    File Type: inc ztf2grab.inc (5.1 KB, 1916 views)
    File Type: inc tf2_objects.inc (3.1 KB, 2042 views)
    File Type: inc entlimit.inc (1.5 KB, 1976 views)
    File Type: inc tf2_player.inc (15.5 KB, 1808 views)
    File Type: inc tf2_build.inc (17.6 KB, 1825 views)
    File Type: smx remote.smx (31.6 KB, 2137 views)

    Last edited by naris; 02-23-2012 at 21:03. Reason: Update
    naris is offline
     



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 05:33.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode