Skip to content

Commit

Permalink
Dont add items while worn
Browse files Browse the repository at this point in the history
  • Loading branch information
dysphie committed Jan 25, 2022
1 parent c6bc590 commit c8d1683
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripting/nmrih-backpack2.sp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Plugin myinfo = {
name = "[NMRiH] Backpack2",
author = "Dysphie & Ryan",
description = "Portable inventory boxes",
version = "2.0.8",
version = "2.0.9",
url = "github.com/dysphie/nmrih-backpack2"
};

Expand Down Expand Up @@ -243,7 +243,7 @@ enum struct Backpack

bool Attach(int wearer, bool suppressSound = false)
{
if (this.wearerRef != INVALID_ENT_REFERENCE) {
if (IsValidEntity(this.wearerRef)) {
return false;
}

Expand Down Expand Up @@ -1350,6 +1350,9 @@ bool OnAmmoBoxCollide(int collidedWith, int ammoBox)
Backpack bp;
backpacks.GetArray(backpackID, bp);

if (IsValidEntity(bp.wearerRef))
return true;

Item reg;
if (!GetItemByEntity(ammoBox, reg)) {
return false;
Expand Down Expand Up @@ -1395,6 +1398,9 @@ bool OnWeaponCollide(int collidedWith, int weapon)

Backpack backpack;
backpacks.GetArray(backpackID, backpack);

if (IsValidEntity(backpack.wearerRef))
return true;

if (backpack.AddWeapon(ammoAmt, reg, _, targetname))
{
Expand Down

0 comments on commit c8d1683

Please sign in to comment.