Raised This Month: $51 Target: $400
 12% 

[TF2] How to disable player picks up weapons?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
w1200441
Senior Member
Join Date: Dec 2011
Old 07-03-2015 , 15:06   [TF2] How to disable player picks up weapons?
Reply With Quote #1

As the title, if player picks up my modified weapons when I die, the effects will keep on the weapons and they can use it.
So does there any concoles to block this setting?
w1200441 is offline
Akuba
Senior Member
Join Date: Oct 2013
Old 07-03-2015 , 15:26   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #2

Quote:
Originally Posted by SHADoW NiNE TR3S View Post
So there's a convar to prevent the weapon drops altogether:

tf_dropped_weapon_lifetime 0, as per StarBlaster64 from Github
Akuba is offline
w1200441
Senior Member
Join Date: Dec 2011
Old 07-04-2015 , 12:07   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #3

Thanks for the concole.

And how to hook the weapons I dropped?
w1200441 is offline
SM9
Veteran Member
Join Date: Sep 2013
Location: United Kingdom
Old 07-04-2015 , 18:27   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #4

PHP Code:
public void OnPluginStart()
{
    for (
int iClient 1iClient <= MaxClientsiClient++) {
        if (
IsClientConnected(iClient) && IsClientInGame(iClient)) {
            
OnClientPutInServer(iClient);
        }
    }
}

public 
void OnClientPutInServer(int iClient

    
SDKHook(iClientSDKHook_WeaponCanUseOnWeaponCanUse); 


public 
Action OnWeaponCanUse(int iClientint iWeapon)  
{
    return 
Plugin_Handled;

SM9 is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 07-04-2015 , 21:39   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #5

what exactly is OnWeaponCanUse

does that fire when a weapon appears that someone can equip? when someone tries to equip it? or...
__________________
Chdata is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 07-04-2015 , 22:18   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #6

Quote:
Originally Posted by Chdata View Post
what exactly is OnWeaponCanUse

does that fire when a weapon appears that someone can equip? when someone tries to equip it? or...
OnWeaponCanUse is an arbitrary name picked by him. Your question should be about SDKHook_WeaponCanUse, which Google seems to think fires whenever a person tries to pick up a weapon.
__________________
ddhoward is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 07-05-2015 , 06:06   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #7

Quote:
Originally Posted by w1200441 View Post
As the title, if player picks up my modified weapons when I die, the effects will keep on the weapons and they can use it.
So does there any concoles to block this setting?
Funny enough, this is the reason why Valve nerfed this feature in MvM.

Any mods that mess with item attributes are going to be more messy with this feature.

As an alternative solution, you can kill the weapon entity when it is dropped.
Potato Uno is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 07-05-2015 , 06:20   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #8

kill the weapon entity as in use the cvar to set their lifetime to 0 rather than making an extraneous plugin to repeat that mechanic
__________________
Chdata is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 07-05-2015 , 06:51   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #9

Okay I tested it. It fires whenever you are equipped with a weapon, so during/before/after?? post_inventoryapplication

and every time you pick up and switch for a new weapon

I don't know how one would differentiate that firing when first equip with your stuff or switching to a new weapon, though.

edit: I used a haphazard way of doing it (wait till round starts).

Returning Plugin_Handled when trying to pick up a primary weapon makes you drop your primary weapon, but not take the new one, leaving you with no weapon in the primary slot. And then you can't pick up any primary weapons because you need to have one to drop in the first place.
__________________

Last edited by Chdata; 07-05-2015 at 06:54.
Chdata is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 07-05-2015 , 09:56   Re: [TF2] How to disable player picks up weapons?
Reply With Quote #10

Quote:
Originally Posted by Chdata View Post
Okay I tested it. It fires whenever you are equipped with a weapon, so during/before/after?? post_inventoryapplication

and every time you pick up and switch for a new weapon

I don't know how one would differentiate that firing when first equip with your stuff or switching to a new weapon, though.

edit: I used a haphazard way of doing it (wait till round starts).

Returning Plugin_Handled when trying to pick up a primary weapon makes you drop your primary weapon, but not take the new one, leaving you with no weapon in the primary slot. And then you can't pick up any primary weapons because you need to have one to drop in the first place.
Did you try settransmit on them, so only people you want to use them can see?
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Reply



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 01:30.


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