AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [TF2] How to disable player picks up weapons? (https://forums.alliedmods.net/showthread.php?t=265707)

w1200441 07-03-2015 15:06

[TF2] How to disable player picks up weapons?
 
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?

Akuba 07-03-2015 15:26

Re: [TF2] How to disable player picks up weapons?
 
Quote:

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

tf_dropped_weapon_lifetime 0, as per StarBlaster64 from Github


w1200441 07-04-2015 12:07

Re: [TF2] How to disable player picks up weapons?
 
Thanks for the concole.

And how to hook the weapons I dropped?

SM9 07-04-2015 18:27

Re: [TF2] How to disable player picks up weapons?
 
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;



Chdata 07-04-2015 21:39

Re: [TF2] How to disable player picks up weapons?
 
what exactly is OnWeaponCanUse

does that fire when a weapon appears that someone can equip? when someone tries to equip it? or...

ddhoward 07-04-2015 22:18

Re: [TF2] How to disable player picks up weapons?
 
Quote:

Originally Posted by Chdata (Post 2315701)
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.

Potato Uno 07-05-2015 06:06

Re: [TF2] How to disable player picks up weapons?
 
Quote:

Originally Posted by w1200441 (Post 2315123)
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.

Chdata 07-05-2015 06:20

Re: [TF2] How to disable player picks up weapons?
 
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 07-05-2015 06:51

Re: [TF2] How to disable player picks up weapons?
 
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.

friagram 07-05-2015 09:56

Re: [TF2] How to disable player picks up weapons?
 
Quote:

Originally Posted by Chdata (Post 2315798)
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?


All times are GMT -4. The time now is 12:56.

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