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

Solved [TF2] Remove all weapons from player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
caxanga334
Member
Join Date: Nov 2013
Location: Brazil
Old 05-12-2019 , 21:09   [TF2] Remove all weapons from player
Reply With Quote #1

I'm trying to remove all weapons from players but weapons with wearable are not being removed (for example: The Chargin' Targe, Darwin's Danger Shield).

This is the code I'm using.

Spoiler


Solution
PHP Code:
int iPrimaryiSecondary;
iPrimary TF2_GetPlayerLoadoutSlot(iClientTF2LoadoutSlot_Primarytrue);
if(
iPrimary != -1)
{
    
TF2_RemovePlayerWearable(iClientiPrimary);
}
iSecondary TF2_GetPlayerLoadoutSlot(iClientTF2LoadoutSlot_Secondarytrue);
if(
iSecondary != -1)
{
    
TF2_RemovePlayerWearable(iClientiSecondary);


Last edited by caxanga334; 05-14-2019 at 14:07. Reason: solved
caxanga334 is offline
adma
Senior Member
Join Date: Oct 2015
Old 05-12-2019 , 22:02   Re: [TF2] Remove all weapons from player
Reply With Quote #2

Ignore, misunderstood the question

PHP Code:
static int iWeaponWearables[] = {
  
133// Gunboats
  
444// Mantreads
  
405// Ali Baba's Wee Booties
  
608// Bootlegger
  
231// Darwin's Danger Shield
  
642  // Cozy Camper
};

int iEnt = -1;
while ((
iEnt FindEntityByClassname(iEnt"tf_wearable")) != -1) {
  
// Get item index
  
iIndex GetEntProp(iEntProp_Send"m_iItemDefinitionIndex");

  
// Check if the item index matches a weapon wearable
  
for (int i 0sizeof(iWeaponWearables); ++i) {
    if (
iIndex == iWeaponWearables[i])
      
bIsWeaponWearable true;
  }

  
// If wearable is not a weapon
  
if (!bIsWeaponWearable) {
    
// If owner is not the client, then skip
    
if (GetEntPropEnt(iEntProp_Send"m_hOwnerEntity") != iClient
      continue;

    
// Call RemoveWearable
    
SDKCall(hSDKCalliClientiEnt);
  }

__________________

Last edited by adma; 05-14-2019 at 08:57.
adma is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 05-12-2019 , 22:16   Re: [TF2] Remove all weapons from player
Reply With Quote #3

You'll need to You can also use CTFPlayer::GetEntityForLoadoutSlot() to access loadout slots (which are different from weapon slots).

I've been meaning to push a PR to Powerlord's upstream source for support of the latest version of the game, but my fork of his TF2 Wearable Tools API supports accessing wearables in weapon slots and removing them.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 05-12-2019 at 22:16.
nosoop 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 20:26.


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