Jump to content

Limited containers capacity weight


baronesbc

Recommended Posts

 

Alright, so I made a manager quest for Limited Container Capacity, made the player ref, and added this script:

Scriptname LCC_ManagerScript extends ReferenceAlias

Float Property Max = 500.00 Auto

;Event OnInit()
;	Debug.Notification("LCC running")
;EndEvent

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
;	Debug.Notification("Item removed from player")
	If ( akDestContainer )
;		Debug.Notification("akDestContainer is valid")
		Int NumItems = akDestContainer.GetNumItems()
;		Debug.Notification("NumItems: "+NumItems)
		Int i = 0
		Float TotalWeight = 0
		While ( i < NumItems )
			If ( akDestContainer.GetNthForm(i) )
					TotalWeight = TotalWeight + ( akDestContainer.GetNthForm(i).GetWeight() * akDestContainer.GetItemCount(akDestContainer.GetNthForm(i)) )
					i += 1
			EndIf
		EndWhile
		Debug.Notification("Container Weight: "+TotalWeight)
		If ( TotalWeight > Max )
			akDestContainer.RemoveItem( akBaseItem, aiItemCount, true, Game.GetPlayer() )
			Debug.Notification("This item won't fit in this container")
;		Else
;			Debug.Notification("The item fits")
		EndIf
	EndIf
EndEvent

It originally didn't work because I was dumb and had it extending ObjectReference. But after I changed that, I noticed everything was working fine except that the item wasn't being returned to the player. It wasn't being removed, either. It was just staying there even though it knew it didn't fit. So I changed it to akBaseItem and it worked perfectly. I even clicked 3 in rapid succession that wouldn't fit and even though all three made it in before the script got through the first, it managed to return all three in turn. So, that's promising.

 

But I'm worried that returning the base item is going to strip any player enchanted/upgraded items of their enhancements. Thoughts?

 

Actually, I realized I had an upgraded piece of armor. So I filled the container and then put in the armor, and it was returned in its upgraded state. However, I don't have anything I've enchanted, so I can't test that easily. Here's the file if one of you would be awesome enough to test it if you can easily.

 

EDIT: In the file, I forgot to compile the script. The only thing I'd changed is commenting out the unnecessary notifications.

 

EDIT2: I reread this and realized it was practically unintelligible because I made so many typing mistakes. They're fixed now. I should really proof-read my posts...

 

Thanks! I tried to use this mod, but when i trade whit my follower appears a bug: the items that i transfer to backpack of my follower are replicated...

moreover i want to know if possible to apply it at this mod:

Dragonkiller Cart Reloaded

http://skyrim.nexusmods.com/mods/25493/?tab=2&navtag=%2Fajax%2Fmodfiles%2F%3Fid%3D25493&pUp=1

Edited by baronesbc
Link to comment
Share on other sites

  • 5 years later...

Hi all, I was wondering if was possible to create a mod that add a limit capacity weight for boxes barrels or other containers, I never could stand the unrealistic idea to add items inside the containers to infinity... Unfortunately I could not find a mod like this anywhere, (if this already exists please post me) so if this idea would be developed by some modder I'd love to ... Thank you and sorry my bad English by google translate :)Â

Theoretically, why would you even need to monitor every container in the world? World containers reset, so people really only are going to store their stuff in containers in the player home. Just put weight caps on that instead only.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...