Raised This Month: $ Target: $400

[TF2] DropWeapon

Post New Thread Reply   
Thread Tools Display Modes
Senior Member
Join Date: May 2020
Plugin ID:
Plugin Version:
Plugin Category:
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
    Plugin Description:
    Drop weapons like in CSGO
    Old 02-24-2023 , 15:15   [TF2] DropWeapon
    Reply With Quote #1

    TF2 DropWeapon

    The purpose of this plugin is to re-enable dropping weapons from players into the worls and picking them back up / re-equipping single inventory slots.
    This allows for weapon handling similar to other Source games like CS.

    I feel like it's important to mention that the goal of this plugin is not to give you arbitrary weapons (falsify inventory) to arbitrary classes,
    but to merely give weapons already owned by a player back to them in a controlled manner, like you would expect from other valve games.

    Weapon class restrictions are also untouched! You wont be able to equip scouts with rocket launchers using this plugin.

    For players, the idea is simple

    Use your drop item key (Default `bind L dropitem`) to drop your active weapon (CTF flag as priority). To pick an item back up
    use your action item key (default H) or, for a more reliable pickup, use a +use bind. Unless disabled, you can also just walk over the weapon to pick it up,
    given you do not have another weapon in the same slot.

    If you just want this as a library for other plugins, you can set `sm_tf2dropweapon_enabled 0` to set the plugin in library mode and disable all interactive/player functionallity.

    For plugin devs

    Using this plugin you can drop weapons, pick up any tf_dropped_weapon to a player, regenerate loadout slots from the current player inventory, equip stock items
    for players on a whim, even by the weapon's classname; or react to weapons being dropped and picked up. See the include file for more information.

    This plugin also partially restores SDKHook_WeaponDrop (i think) and SDKHook_DropWeapon native (bypassHooks needs to be false).

    ConVars & Commands
    • sm_tf2dropweapon_supresscleanup 0 By default the game checks the game mode and deletes already existing weapons before spawning more. Set to 1 to disable that check.
    • sm_tf2dropweapon_usetopickup 1 The default key for picking up weapons seems to have issues. Set to 1 to allow +use to pick up weapons.
    • sm_tf2dropweapon_pickupany 1 There are some restriction for picking up weapons. Set to 1 to ignore these. Note: Setting to one uses a reimplementation that might be more prone to gamedata updates, so try 0 if you're running into issues.
    • sm_tf2dropweapon_touchpickup 1 Set to 1 to pick up weapons, that fit into a slot that is currently empty.
    • sm_tf2dropweapon_enabled 1 Enables sm_dropweapon/sm_pickupweapon, dropitem hook and proximity pickup. Set to 0 if you just got this plugin as library.

    The commands were used for testing, but feel free to enable them for your players:
    • sm_dropweapon Drop your weapon
    • sm_pickupweapon Look at a weapon first
    • sm_giveweapon ADMFLAG_CHEATS - Usage: (<weapon>|<class> <slot> ['stock']). Gives a player a weapon. Either use a weapon class name, or player class name and slot. For class and slot, gives from the loadout. If stock is specified uses a stock weapon.
    • sm_dwgive ADMFLAG_CHEATS - Same as sm_giveweapon. Just a shorter alias that should not clash with other give weapon plugins.

    Natives/Forwards overview

    PHP Code:
    // React to when a weapons is dropped
    forward Action TF2DW_OnClientDropWeapon(int clientint weapon)
    // Listen to when a weapon was dropped
    forward void TF2DW_OnClientDropWeaponPost(int clientint droppedWeapon)
    // React to when a weapon is picked up
    forward Action TF2DW_OnClientPickupWeapon(int clientint droppedWeapon)
    // Listen to when a weapon was picked up
    forward void TF2DW_OnClientPickupWeapon(int clientint weapon)
    // Force a player to drop a weapon in the given loadout slot
    native int TF2DW_DropWeaponLoadoutSlot(int clientint loadoutSlot)
    // Equip a player with a weapon based on weapon classname and active player class (stock)
    native int TF2DW_GiveWeaponByClassname(int client, const char[] classname)
    // Equip a player with a weapon based on weapon slot and active player class (uses loadout unless stockItem is true)
    native int TF2DW_GiveWeaponForLoadoutSlot(int clientint loadoutSlotbool stockItem=false)
    // Spawn a stock dropped weapon in the world based on weapon class name and specified player class
    native int TF2DW_CreateDroppedWeaponByClassname(const char[] classnameTFClassType class, const float position[3])
    // Spawn a dropped weapon in the world based on player loadout, player class and weapon slot
    native int TF2DW_CreateDroppedWeaponFromLoadout(int clientTFClassType class, int slot, const float position[3])
    // Get the stock item definition index for a given player class and loadout slot
    native int TF2DW_GetStockWeaponItemDef(TFClassType class, int slot)
    // Get a weapons default max ammo and clip size based on player class data and item attributes
    native bool TF2DW_GetWeaponDefaultMaxClipAndAmmo(int itemDefTFClassType playerClass=TFClass_UnknownintmaxClip=0intmaxAmmo=0

    Plugins & LibrariesListing GitHubDosMike Tools ▶ ToDo

    Last edited by reBane; 02-24-2023 at 17:13.
    reBane is offline

    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 21:36.

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