Skip to content

Commit

Permalink
Added sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuza committed May 9, 2023
1 parent f83d553 commit 0a9d8f1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Release Notes

## [2.0.3]

### Fixes

- Check if the weapon exists during `TF2_OnConditionAdded` and `TF2_OnConditionRemoved`

## [2.0.2]

### Changes
Expand Down
15 changes: 12 additions & 3 deletions scripting/attribute_viewmodel_override.sp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public Plugin myinfo =
name = "[TF2] Attribute: Viewmodel Override",
author = "Zabaniya001",
description = "[TF2] Attributes to modify arms, arms animations, firstperson and thirdparson weapon model.",
version = "2.0.2",
version = "2.0.3",
url = "https://github.com/Zabaniya001/TF2CA-weaponmodel_override"
};

Expand Down Expand Up @@ -273,8 +273,11 @@ public void TF2_OnConditionAdded(int client, TFCond cond)

int weapon = TF2_GetActiveWeapon(client);

SetEntityRenderMode(weapon, RENDER_NORMAL);
SetEntityRenderColor(weapon, 255, 255, 255, 255);
if(weapon > MaxClients && IsValidEntity(weapon))
{
SetEntityRenderMode(weapon, RENDER_NORMAL);
SetEntityRenderColor(weapon, 255, 255, 255, 255);
}

g_ClientWeaponModels[client].Delete(client);

Expand All @@ -285,9 +288,15 @@ public void TF2_OnConditionRemoved(int client, TFCond cond)
{
if(cond != TFCond_Taunting)
return;

if(!IsClientInGame(client))
return;

int weapon = TF2_GetActiveWeapon(client);

if(weapon <= 0 || !IsValidEntity(weapon))
return;

OnDrawWeapon(client, weapon);

return;
Expand Down

0 comments on commit 0a9d8f1

Please sign in to comment.