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 a modified version of TF2_RemoveWeaponSlot
PHP Code:
stock void HAS_RemoveWeaponSlot(int client, int slot)
{
int weaponIndex;
while ((weaponIndex = GetPlayerWeaponSlot(client, slot)) != -1)
{
// bug #6206
// papering over a valve bug where a weapon's extra wearables aren't properly removed from the weapon's owner
int extraWearable = GetEntPropEnt(weaponIndex, Prop_Send, "m_hExtraWearable");
if (extraWearable != -1)
{
SDKCall(hRemoveWearable, client, extraWearable);
AcceptEntityInput(extraWearable, "Kill");
}
int iEnt = -1; while ((iEnt = FindEntityByClassname(iEnt, "tf_wearable")) != -1) { // Get item index iIndex = GetEntProp(iEnt, Prop_Send, "m_iItemDefinitionIndex");
// Check if the item index matches a weapon wearable for (int i = 0; i < sizeof(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(iEnt, Prop_Send, "m_hOwnerEntity") != iClient) continue;
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.