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

[TF2] Dropped weapons


Post New Thread Reply   
 
Thread Tools Display Modes
404UserNotFound
BANNED
Join Date: Dec 2011
Old 07-20-2015 , 21:23   Re: [TF2] Dropped weapons
Reply With Quote #11

Is there any way to restrict which clients can use the action key to pick up the dropped weapon, i.e. just the client who triggered the drop? I have an idea that requires this to be possible.

*fingers crossed*
404UserNotFound is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-20-2015 , 21:34   Re: [TF2] Dropped weapons
Reply With Quote #12

Quote:
Originally Posted by abrandnewday View Post
Is there any way to restrict which clients can use the action key to pick up the dropped weapon, i.e. just the client who triggered the drop? I have an idea that requires this to be possible.

*fingers crossed*
Write an extension to detour the Pickup function, or use SM 1.8+'s OnClientCommandKeyValues forward to hook the +tf_action_slot_item command and block if there's a dropped weapon near them.
psychonic is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 07-20-2015 , 21:41   Re: [TF2] Dropped weapons
Reply With Quote #13

Quote:
Originally Posted by psychonic View Post
Write an extension to detour the Pickup function, or use SM 1.8+'s OnClientCommandKeyValues forward to hook the +tf_action_slot_item command and block if there's a dropped weapon near them.
I've uh...I've never written an extension. I've also never written a Metamod plugin. Too advanced for my blood.
404UserNotFound is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-21-2015 , 00:11   Re: [TF2] Dropped weapons
Reply With Quote #14

Quote:
Originally Posted by psychonic View Post
Write an extension to detour the Pickup function, or use SM 1.8+'s OnClientCommandKeyValues forward to hook the +tf_action_slot_item command and block if there's a dropped weapon near them.
Wouldn't it be better to detour CTFPlayer::CanPickupDroppedWeapon? Or is that only checked on the client side?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 07-21-2015 , 05:43   Re: [TF2] Dropped weapons
Reply With Quote #15

Quote:
Originally Posted by Powerlord View Post
Wouldn't it be better to detour CTFPlayer::CanPickupDroppedWeapon? Or is that only checked on the client side?
Wasn't enough when we tried. It does class checking in CTFPlayer::PickupWeaponFromOther
__________________

Last edited by Pelipoika; 07-21-2015 at 06:11.
Pelipoika is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 07-21-2015 , 13:25   Re: [TF2] Dropped weapons
Reply With Quote #16

Quote:
Originally Posted by Pelipoika View Post
Wasn't enough when we tried. It does class checking in CTFPlayer::PickupWeaponFromOther
Even if you remove class check from CTFPlayer::PickupWeaponFromOther then picking up weapon from different class than client's own will result in server's crash sadly...
__________________
...

Last edited by Oshizu; 07-21-2015 at 13:28.
Oshizu is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 08-14-2015 , 12:04   Re: [TF2] Dropped weapons
Reply With Quote #17

Awww fucking hell.

I just want to point out that this does NOT work with MvM. I'm assuming the reason for that is because the in-game functions psychonic calls does a check for the game mode and probably stops execution if it detects MvM (which is probably how Valve nerfed it for MvM). The weapons do not spawn at all in MvM.

I can confirm it works on koth_suijin... but yeah for MvM this is totally useless. Thanks for the effort and release though!

I might have to use my shit weapon drop plugin and then use TF2Items to give a proper weapon right as a dropped weapon is picked up... hacky as hell and removes ubercharge percentage but FWIW it should sort of work.

Last edited by Potato Uno; 08-14-2015 at 12:14.
Potato Uno is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 08-15-2015 , 16:00   Re: [TF2] Dropped weapons
Reply With Quote #18

Quote:
Originally Posted by Potato Uno View Post
Awww fucking hell.

I just want to point out that this does NOT work with MvM. I'm assuming the reason for that is because the in-game functions psychonic calls does a check for the game mode and probably stops execution if it detects MvM (which is probably how Valve nerfed it for MvM). The weapons do not spawn at all in MvM.

I can confirm it works on koth_suijin... but yeah for MvM this is totally useless. Thanks for the effort and release though!

I might have to use my shit weapon drop plugin and then use TF2Items to give a proper weapon right as a dropped weapon is picked up... hacky as hell and removes ubercharge percentage but FWIW it should sort of work.
You could try

PHP Code:
GameRules_SetProp("m_bPlayingMannVsMachine"0);
//Spawn weapon
GameRules_SetProp("m_bPlayingMannVsMachine"1); 
But that might just break alot of things
__________________
Pelipoika is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 08-15-2015 , 17:34   Re: [TF2] Dropped weapons
Reply With Quote #19

PHP Code:
int CreateDroppedWeapon(int fromWeaponint client, const float origin[3], const float angles[3])
{

    
// Offset of the CEconItemView class inlined on the weapon.
    // Manually using FindSendPropInfo as 1) it's a sendtable, not a value,
    // and 2) we just want a pointer to it, not the value at that address.
    
int itemOffset FindSendPropInfo("CTFWeaponBase""m_Item");
    if (
itemOffset == -1)
        
ThrowError("Failed to find m_Item on CTFWeaponBase");
    
    
// Can't get model directly. Instead get index and look it up in string table.
    
char model[PLATFORM_MAX_PATH];
    
int modelidx GetEntProp(fromWeaponProp_Send"m_iWorldModelIndex");
    
ModelIndexToString(modelidxmodelsizeof(model));

    
GameRules_SetProp("m_bPlayingMannVsMachine"0); 
    
    
int droppedWeapon SDKCall(hCreateDroppedWeaponclientoriginanglesmodelGetEntityAddress(fromWeapon) + Address:itemOffset);
    if (
droppedWeapon != INVALID_ENT_REFERENCE)
        
SDKCall(hInitDroppedWeapondroppedWeaponclientfromWeaponfalsefalse);
        
    
// Enable it again:
    
GameRules_SetProp("m_bPlayingMannVsMachine"1); 
    
    
SetEntProp(droppedWeaponProp_Send"m_bInitialized"1);        // not sure if this is needed
    
    
return droppedWeapon;

Got it to work, thanks for the help! You guys are awesome.
Potato Uno is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 08-15-2015 , 18:33   Re: [TF2] Dropped weapons
Reply With Quote #20

Quote:
Originally Posted by Potato Uno View Post
PHP Code:
SetEntProp(droppedWeaponProp_Send"m_bInitialized"1);        // not sure if this is needed 
It shouldn't be
__________________
Pelipoika 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 12:42.


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