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

[TF2] Weapon Limiter


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Robot Gloryhole
Junior Member
Join Date: Jul 2012
Location: Brisbane, QLD
Plugin ID:
3126
Plugin Version:
0.6.0
Plugin Category:
Gameplay
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
    9 
    Plugin Description:
    Controls the number and type of weapons equipable by players by setting limits.
    Old 07-31-2012 , 08:28   [TF2] Weapon Limiter
    Reply With Quote #1

    This is my first attempt at a TF2 / SourceMod plugin, made at the request of my clan's server administrator as a way to limit the number of Gunslingers equipable per team. Please let me know any functionality that you think could improve it and I will try to oblige.

    List of features:
    • Set limits by weapon or weapon class
    • Set different limits for red/blue and/or a server-wide limit
    • Configurable by configuration file or by commands
    • Ability to whitelist players by their steam ID - whitelisted players can always equip the weapons specified in their whitelist entry(s)
    Requires:
    • tf2items
    CVAR:
    • weaplimit_version
    Admin Commands:
    • weaplimit_help
      • display a list of available commands
    • weaplimit_enabled <1|0>
      • enable/disable the plugin
    • weaplimit_chatenabled <1|0>
      • enable/disable chat output to the player
    • weaplimit_hudenabled <1|0>
      • enable/disable HUD output to the player
    • weaplimit_addlimit <total limit> <red limit> <blue limit> <player class> <item slot> <item index|item class>
      • add an entry to the limit table
    • weaplimit_printlimits
      • print all entries in the limit table to the console
    • weaplimit_removelimit <limit key>
      • remove the specified limit from the limit table
    • weaplimit_clearlimits
      • remove all limits from the limit table
    • weaplimit_addwhitelist <userid> <item slot> <item index|item class>
      • add an entry to the whitelist table
    • weaplimit_printwhitelist
      • print all entries in the whitelist table to the console
    • weaplimit_removewhitelist <whitelist key>
      • remove the specified whitelist entry from the whitelist table
    • weaplimit_clearwhitelist
      • remove all whitelist entries from the whitelist table
    • weaplimit_loadconfig <config file>
      • clear the existing settings and load the settings defined in the specified configuration file
    Command Usage Examples:
    • weaplimit_enabled 1
      • enable the plugin
    • weaplimit_addlimit -1 -1 2 scout unknown tf_weapon_scattergun
      • add a limit for blue team scouts of 2 weapons belonging to the "tf_weapon_scattergun" weapon class
    • weaplimit_addlimit 4 -1 -1 unknown unknown 142
      • add a limit for all players of 4 "Gunslinger" weapons, regardless of player class
    • weaplimit_addlimit -1 3 3 unknown secondary tf_weapon_shotgun
      • add a limit for each team of 3 weapons belonging to the "tf_weapon_shotgun" weapon class
    • weaplimit_removelimit 1
      • remove the limit entry with a key of '1' from the limit table
    • weaplimit_addwhitelist STEAM_0:0:12345678 unknown -1
      • add the player with the specified steam id to the whitelist for all weapons
    • weaplimit_addwhitelist STEAM_0:0:12345678 primary -1
      • add the player with the specified steam id to the whitelist for all primary slot weapons
    • weaplimit_removewhitelist 2
      • remove the whitelist entry with a key of '2' from the whitelist table
    Configuration File Usage:
    • See attached weapon_limits.cfg file.
    Change History:
    Quote:
    0.5.0 - Initial public version, including *some* comments
    0.5.1 - Added printing of limits/whitelist on plugin launch, changed a bunch of "new" to "decl"
    0.5.2 - Added HUD message informing the client when they equip a limited weapon
    0.5.3 - Added commands to mute chat and/or HUD messages, Added weaplimit_help command
    0.6.0 - Added commands to load the configuration and clear limits/whitelist entries
    Attached Files
    File Type: smx weapon_limits.smx (18.0 KB, 1284 views)
    File Type: sp Get Plugin or Get Source (weapon_limiter.sp - 924 views - 66.7 KB)
    File Type: cfg weapon_limits.cfg (4.7 KB, 1763 views)

    Last edited by Robot Gloryhole; 08-14-2012 at 08:44. Reason: New version
    Robot Gloryhole is offline
    Horsedick
    AlliedModders Donor
    Join Date: Sep 2011
    Old 07-31-2012 , 11:45   Re: [TF2] Weapon Limiter
    Reply With Quote #2

    hmm this looks promising, I wonder if adding a cvar for limiting or making for 0 use of only airblasting by pyro when in "god mode" area's of a map? Case in point, restricting that use to prevent getting blown out into an open area of the map while afk.
    Horsedick is offline
    DJTHED
    New Member
    Join Date: Jul 2012
    Old 07-31-2012 , 16:38   Re: [TF2] Weapon Limiter
    Reply With Quote #3

    The plugin isn't compiling for me, do you mind attaching the actual plugin?
    DJTHED is offline
    Horsedick
    AlliedModders Donor
    Join Date: Sep 2011
    Old 07-31-2012 , 17:04   Re: [TF2] Weapon Limiter
    Reply With Quote #4

    Quote:
    Originally Posted by DJTHED View Post
    The plugin isn't compiling for me, do you mind attaching the actual plugin?
    year appears it requires tf2items

    I compiled it - here ya go
    Attached Files
    File Type: smx weapon_limiter.smx (15.5 KB, 531 views)
    File Type: sp Get Plugin or Get Source (weapon_limiter.sp - 508 views - 56.4 KB)
    Horsedick is offline
    Robot Gloryhole
    Junior Member
    Join Date: Jul 2012
    Location: Brisbane, QLD
    Old 07-31-2012 , 19:00   Re: [TF2] Weapon Limiter
    Reply With Quote #5

    That's really weird - I definitely included tf2items in the dependency field when I submitted the plugin. I will update my original post to explicitly mention the tf2items requirement.
    Robot Gloryhole is offline
    Robot Gloryhole
    Junior Member
    Join Date: Jul 2012
    Location: Brisbane, QLD
    Old 07-31-2012 , 19:07   Re: [TF2] Weapon Limiter
    Reply With Quote #6

    Quote:
    Originally Posted by Horsedick View Post
    hmm this looks promising, I wonder if adding a cvar for limiting or making for 0 use of only airblasting by pyro when in "god mode" area's of a map? Case in point, restricting that use to prevent getting blown out into an open area of the map while afk.
    I'm not sure that fits with what the rest of the plugin is trying to achieve. I can see why what you suggest might be wanted by a server admin, but I think that would belong in the same plugin that has the godmode implementation.

    Also, just thought of a great movie title: "Horsedick & Robot Gloryhole: Together At Last" ... coming to a theatre near you in 2014.
    Robot Gloryhole is offline
    Horsedick
    AlliedModders Donor
    Join Date: Sep 2011
    Old 07-31-2012 , 20:17   Re: [TF2] Weapon Limiter
    Reply With Quote #7

    Quote:
    Originally Posted by Robot Gloryhole View Post
    That's really weird - I definitely included tf2items in the dependency field when I submitted the plugin. I will update my original post to explicitly mention the tf2items requirement.
    I'd update the original post to include the plugin too ..ya never know some many not read down a few spots.
    Horsedick is offline
    Robot Gloryhole
    Junior Member
    Join Date: Jul 2012
    Location: Brisbane, QLD
    Old 07-31-2012 , 20:33   Re: [TF2] Weapon Limiter
    Reply With Quote #8

    Quote:
    Originally Posted by Horsedick View Post
    I'd update the original post to include the plugin too ..ya never know some many not read down a few spots.
    Done
    Robot Gloryhole is offline
    DJTHED
    New Member
    Join Date: Jul 2012
    Old 08-01-2012 , 17:33   Re: [TF2] Weapon Limiter
    Reply With Quote #9

    I've got a chance to try it out, but there is one problem. When a player reaches the limit, it does remove the item just fine, but it doesn't replace the weapon with something else. Right now I'm limiting the amount of gunslinger engineers, and when the limit is reached, you end up not having a wrench at all until you manually change it to something else in your loadout.

    Is it possible to add a feature like this?
    DJTHED is offline
    Robot Gloryhole
    Junior Member
    Join Date: Jul 2012
    Location: Brisbane, QLD
    Old 08-01-2012 , 21:06   Re: [TF2] Weapon Limiter
    Reply With Quote #10

    My initial plan was to have the plugin automatically assign a new weapon to the player when one was removed - the weapon would have been either the stock weapon for that player class/slot or a weapon specified in the limit entry.

    I ran into two issues with this approach though:
    • I wanted to be able to 'limit' any weapon in the game, including stock weapons
    • It turns out adding functionality to set a player's weapon was more complicated than expected (if anyone could show me how to do this simply, I'll try to add the 'replacing' functionality in)
    At this point, I had a discussion with the server admin and senior clan members and they had no problems whatsoever with my proposed functionality of removing limited weapons. One thing I would like to do would be to make the notification to the player that their weapon was removed due to a limit more explanatory and more visible (ie in the middle of the screen). That, along with any other suggestions/bugfixes will probably make it into 0.5.1 .
    Robot Gloryhole is offline
    Reply


    Thread Tools
    Display Modes

    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 07:23.


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