Skip to content

Commit

Permalink
Merge pull request #17 from punteroo/development
Browse files Browse the repository at this point in the history
Add check for disguise weapons firing OnGiveNamedItem
  • Loading branch information
punteroo authored Nov 13, 2021
2 parents 62b2102 + 06b2470 commit 672a86f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Binary file modified plugins/tf2item_weapons.smx
Binary file not shown.
10 changes: 9 additions & 1 deletion scripting/tf2item_weapons.sp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_VERSION "3.1.2"
#define PLUGIN_VERSION "3.1.3"

public Plugin myinfo =
{
Expand Down Expand Up @@ -625,6 +625,14 @@ public Action TF2Items_OnGiveNamedItem(int client, char[] classname, int iItemDe
// Ignore cosmetic items.
if (StrContains(classname, "tf_wearable", false) != -1) return Plugin_Continue;

TFClassType class = TF2_GetPlayerClass(client);

// Ignore disguise weapons (we do NOT have an entity index here, so we can't check directly for m_bDisguiseWeapon)
if (class == TFClass_Spy) {
// They're a Spy. Check if this weapon being given corresponds to their class.
if (TF2Econ_GetItemLoadoutSlot(iItemDefinitionIndex, class) == -1) return Plugin_Continue;
}

// Turn the item ID into the strange variant just to be sure.
bool changed = StockToStrange(iItemDefinitionIndex);

Expand Down
6 changes: 6 additions & 0 deletions scripting/tf2items/tf2item_base.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
/*
* Change-Log
*
* 3.1.3 - 13/11/21
* tf2item_weapons
* - Fixed #16
* - Players with set overrides on any class could mask item indexes to be given weapons they must not equip by disguising.
* - Disguise Weapons would fire TF2Items_OnGiveNamedItem
*
* 3.1.2 - 04/11/21
* General
* - Fixed ArrayLists not being properly initialized through map changes.
Expand Down

0 comments on commit 672a86f

Please sign in to comment.