Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TF2] shavit-misc's NoWeaponDrops is broken #1159

Closed
jedso opened this issue Jul 24, 2022 · 0 comments · Fixed by #1160
Closed

[TF2] shavit-misc's NoWeaponDrops is broken #1159

jedso opened this issue Jul 24, 2022 · 0 comments · Fixed by #1160

Comments

@jedso
Copy link
Contributor

jedso commented Jul 24, 2022

You can't purposefully drop items in TF2 like you can in CS:S/GO (no drop command). However, when you die (e.g. kill), your current weapon is dropped for other team members to use along with an ammo pack. The big difference in TF2 though, is that this dropped weapon becomes a new tf_dropped_weapon entity and therefore never satisfies the FindEntityByClassname(ent, "weapon_*") check in shavit-misc's Timer_Cron when gCV_NoWeaponDrops.BoolValue is true.

if (gCV_NoWeaponDrops.BoolValue)
{
int ent = -1;
while ((ent = FindEntityByClassname(ent, "weapon_*")) != -1)
{
if (GetEntPropEnt(ent, Prop_Send, "m_hOwnerEntity") == -1)
{
AcceptEntityInput(ent, "Kill");
}
}
}

SDKHook_WeaponDrop also doesn't behave as you would expect in TF2. When you die, the WeaponDrop callback contains the entity index of the last equipped weapon but NOT the entity index of the newly created tf_dropped_weapon. Unless the player changes their loadout, the weapon entity index remains the same before and after respawning, so the only thing OnWeaponDrop does is kill whatever weapon entity was equipped at time of death.

public void OnWeaponDrop(int client, int entity)
{
if(gCV_NoWeaponDrops.BoolValue && IsValidEntity(entity))
{
AcceptEntityInput(entity, "Kill");
}
}

So basically neither Timer_Cron or the WeaponDrop callback kill dropped weapons in TF2. Luckily though TF2 has a built-in ConVar for this functionality, tf_dropped_weapon_lifetime, so there’s no need to use a timer or hook WeaponDrop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant