Skip to content

Commit

Permalink
Fix some wearables not removed properly
Browse files Browse the repository at this point in the history
  • Loading branch information
FortyTwoFortyTwo committed May 22, 2023
1 parent 1e28ae7 commit b52fbad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion scripting/randomizer.sp
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ public void OnGameFrame()

if (IsValidEntity(iEntity))
{
RemoveEntity(iEntity);
TF2_RemoveItem(GetEntPropEnt(iEntity, Prop_Send, "m_hOwnerEntity"), iEntity, true);
break;
}
}
Expand Down
16 changes: 10 additions & 6 deletions scripting/randomizer/stocks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ stock float TF2_GetMultiMaxAmmo(float flInitial, int iAmmoType, int iEntity)
}
}

stock void TF2_RemoveItem(int iClient, int iWeapon)
stock void TF2_RemoveItem(int iClient, int iWeapon, bool bForce = false)
{
if (TF2_IsWearable(iWeapon))
{
Expand All @@ -479,18 +479,22 @@ stock void TF2_RemoveItem(int iClient, int iWeapon)

//Below similar to TF2_RemoveWeaponSlot, but only removes 1 weapon instead of all weapons in 1 slot

RemovePlayerItem(iClient, iWeapon);

if (!bForce)
{
//Add to list to remove later instead of removing all weapons at once
g_aEntityToRemove.Push(EntIndexToEntRef(iWeapon));
return;
}

int iExtraWearable = GetEntPropEnt(iWeapon, Prop_Send, "m_hExtraWearable");
if (iExtraWearable != -1)
TF2_RemoveWearable(iClient, iExtraWearable);

iExtraWearable = GetEntPropEnt(iWeapon, Prop_Send, "m_hExtraWearableViewModel");
if (iExtraWearable != -1)
TF2_RemoveWearable(iClient, iExtraWearable);

RemovePlayerItem(iClient, iWeapon);

//Add to list to remove later instead of removing all weapons at once
g_aEntityToRemove.Push(EntIndexToEntRef(iWeapon));
}

stock void TF2_AddConditionFake(int iClient, TFCond nCond)
Expand Down

0 comments on commit b52fbad

Please sign in to comment.