Rizalgar Posted June 22, 2019 Share Posted June 22, 2019 (edited) I'm sure it can be done, since there's a Shout(?) that does something similar, albeit only disarming weapons. I'm just not sure how to go about it. I tried looking at the shouts and the perk, but couldn't find anything pertaining to my question. Edit -- Worst comes to worst, I'll just bypass it by removing the item added, then placing at the characters feet, but I'd like a shorter method if anyone knows one. Edit2 -- Okay, so this is what I have so far. It works fine for the most part, except for if I'm over the inventory limit. Any thoughts on that? Script Scriptname RS_Player_Inventory extends ReferenceAlias {Inventory Handler} Actor Property PlayerRef Auto GlobalVariable Property RS_Player_cInventorySize Auto GlobalVariable Property RS_Player_cBankSize Auto GlobalVariable Property RS_Player_InventorySize Auto GlobalVariable Property RS_Player_BankSize Auto FormList Property RS_FL_Inventory Auto FormList Property RS_FL_Bank Auto FormList Property RS_FL_Stackable Auto Event OnItemAdded(Form Base, Int Count, ObjectReference Ref, ObjectReference Con) Ammo AmmoBase = Base as Ammo Armor ArmorBase = Base as Armor Book BookBase = Base as Book Key KeyBase = Base as Key MiscObject MiscBase = Base as MiscObject Potion PotionBase = Base as Potion Weapon WeaponBase = Base as Weapon If !Con If RS_FL_Stackable.HasForm(AmmoBase) ;Add Item ElseIf RS_FL_Stackable.HasForm(MiscBase) ;Add Item Else If RS_Player_cInventorySize.GetValue() >= 28 Debug.Notification("You are out of inventory space.") Else RS_Player_cInventorySize.SetValue((RS_Player_cInventorySize.GetValue()) + 1) EndIf EndIf Else If RS_FL_Stackable.HasForm(AmmoBase) ;Add Item ElseIf RS_FL_Stackable.HasForm(MiscBase) ;Add Item Else If RS_Player_cInventorySize.GetValue() >= 28 PlayerRef.RemoveItem(ArmorBase, 1, true) PlayerRef.PlaceAtMe(ArmorBase) PlayerRef.RemoveItem(BookBase, 1, true) PlayerRef.PlaceAtMe(BookBase) PlayerRef.RemoveItem(KeyBase, 1, true) PlayerRef.PlaceAtMe(KeyBase) PlayerRef.RemoveItem(MiscBase, 1, true) PlayerRef.PlaceAtMe(MiscBase) PlayerRef.RemoveItem(PotionBase, 1, true) PlayerRef.PlaceAtMe(PotionBase) PlayerRef.RemoveItem(WeaponBase, 1, true) PlayerRef.PlaceAtMe(WeaponBase) Else RS_Player_cInventorySize.SetValue((RS_Player_cInventorySize.GetValue()) + 1) EndIf EndIf EndIf EndEvent Event OnItemRemoved(Form Base, Int Count, ObjectReference Ref, ObjectReference Con) Ammo AmmoBase = Base as Ammo Armor ArmorBase = Base as Armor Book BookBase = Base as Book Key KeyBase = Base as Key MiscObject MiscBase = Base as MiscObject Potion PotionBase = Base as Potion Weapon WeaponBase = Base as Weapon If !Con If RS_FL_Stackable.HasForm(AmmoBase) ;Don't remove ElseIf RS_FL_Stackable.HasForm(MiscBase) ;Don't remove Else RS_Player_cInventorySize.SetValue((RS_Player_cInventorySize.GetValue()) - 1) EndIf EndIf EndEvent Part in question is the RS_Player_cInventorySize.GetSize() >= 28 Edit3 -- Okay, got it figured out why it is doing that and it's because of the OnItemRemoved (derp). Any reason this wouldn't set the variable to prevent this? It baffles me why it won't set the variable. If RS_Player_cInventorySize.GetValue() >= RS_Player_InventorySize.GetValue() RS_Player_cInventorySize.SetValue(29) ---------Resolved---------- For googlers - Scriptname RS_Player_Inventory extends ReferenceAlias {Inventory Handler} Actor Property PlayerRef Auto GlobalVariable Property RS_Player_cInventorySize Auto GlobalVariable Property RS_Player_cBankSize Auto GlobalVariable Property RS_Player_InventorySize Auto GlobalVariable Property RS_Player_BankSize Auto FormList Property RS_FL_Inventory Auto FormList Property RS_FL_Bank Auto FormList Property RS_FL_Stackable Auto Event OnItemAdded(Form Base, Int Count, ObjectReference Ref, ObjectReference Con) Ammo AmmoBase = Base as Ammo Armor ArmorBase = Base as Armor Book BookBase = Base as Book Key KeyBase = Base as Key MiscObject MiscBase = Base as MiscObject Potion PotionBase = Base as Potion Weapon WeaponBase = Base as Weapon If !Con If RS_FL_Stackable.HasForm(AmmoBase) ;Add Item ElseIf RS_FL_Stackable.HasForm(MiscBase) ;Add Item Else If RS_Player_cInventorySize.GetValue() >= 28 PlayerRef.RemoveItem(ArmorBase, 1, true) PlayerRef.PlaceAtMe(ArmorBase) PlayerRef.RemoveItem(BookBase, 1, true) PlayerRef.PlaceAtMe(BookBase) PlayerRef.RemoveItem(KeyBase, 1, true) PlayerRef.PlaceAtMe(KeyBase) PlayerRef.RemoveItem(MiscBase, 1, true) PlayerRef.PlaceAtMe(MiscBase) PlayerRef.RemoveItem(PotionBase, 1, true) PlayerRef.PlaceAtMe(PotionBase) PlayerRef.RemoveItem(WeaponBase, 1, true) PlayerRef.PlaceAtMe(WeaponBase) Debug.Notification("You are out of inventory space.") Else RS_Player_cInventorySize.SetValue((RS_Player_cInventorySize.GetValue()) + 1) EndIf EndIf Else If RS_FL_Stackable.HasForm(AmmoBase) ;Add Item ElseIf RS_FL_Stackable.HasForm(MiscBase) ;Add Item Else If RS_Player_cInventorySize.GetValue() >= RS_Player_InventorySize.GetValue() PlayerRef.RemoveItem(ArmorBase, 1, true) PlayerRef.PlaceAtMe(ArmorBase) PlayerRef.RemoveItem(BookBase, 1, true) PlayerRef.PlaceAtMe(BookBase) PlayerRef.RemoveItem(KeyBase, 1, true) PlayerRef.PlaceAtMe(KeyBase) PlayerRef.RemoveItem(MiscBase, 1, true) PlayerRef.PlaceAtMe(MiscBase) PlayerRef.RemoveItem(PotionBase, 1, true) PlayerRef.PlaceAtMe(PotionBase) PlayerRef.RemoveItem(WeaponBase, 1, true) PlayerRef.PlaceAtMe(WeaponBase) Debug.Notification("You are out of inventory space.") Else RS_Player_cInventorySize.SetValue((RS_Player_cInventorySize.GetValue()) + 1) EndIf EndIf EndIf If RS_Player_cInventorySize.GetValue() >= RS_Player_InventorySize.GetValue() If RS_FL_Stackable.HasForm(AmmoBase) ;Nothing ElseIf RS_FL_Stackable.HasForm(MiscBase) ;Nothing Else RS_Player_cInventorySize.SetValue(29) EndIf EndIf EndEvent Event OnItemRemoved(Form Base, Int Count, ObjectReference Ref, ObjectReference Con) Utility.Wait(1.0) Ammo AmmoBase = Base as Ammo Armor ArmorBase = Base as Armor Book BookBase = Base as Book Key KeyBase = Base as Key MiscObject MiscBase = Base as MiscObject Potion PotionBase = Base as Potion Weapon WeaponBase = Base as Weapon If !Con If RS_FL_Stackable.HasForm(AmmoBase) ;Don't remove ElseIf RS_FL_Stackable.HasForm(MiscBase) ;Don't remove Else RS_Player_cInventorySize.SetValue((RS_Player_cInventorySize.GetValue()) - 1) EndIf EndIf EndEvent Edited June 23, 2019 by Rizalgar Link to comment Share on other sites More sharing options...
Recommended Posts