Jump to content

Need some help with a script...


Recommended Posts

I'm working on a mod that contains some enchanted containers. One of them is a Coin Purse. This purse will have a limit of 10,000 gold.

 

It actually involves two containers, first is the item the player sees and carries which contains this script (which I stole from someone else's mod):

 

Scriptname aaCH18_Script_FLSTCheck_Ore extends ObjectReference

ObjectReference Property aaCh18OreSack Auto

MiscObject Property OreObj Auto

 

Event OnEquipped(Actor akActor)

Game.DisablePlayerControls(false, false, false, false, false, true, false)

utility.wait(0.1)

Game.EnablePlayerControls(false, false, false, false, false, true, false)

utility.wait(0.5)

aaCh18OreSack.Activate(Game.GetPlayer())

EndEvent

 

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

If akNewContainer == aaCh18OreSack

aaCh18OreSack.RemoveItem(OreObj)

Game.GetPlayer().AddItem(OreObj,1,True)

Debug.Notification("The Coin Purs can't contain itself.")

EndIf

EndEvent

 

The actual container which is essentially a vendor trunk is in a hidden location with the following script attached:

 

Scriptname aaCH18_PurseCount extends ObjectReference

 

FormList Property aaCh18FLST Auto

Actor Property PlayerREF Auto

INT Property MaxCount Auto

 

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

If akSourceContainer==PlayerREF

If !aaCh18FLST.HasForm(akBaseItem)

RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)

Debug.Trace("Invalid Item")

EndIf

EndIf

 

int ActualCount = akItemReference.GetItemCount(akBaseItem)

debug.trace("TOO MANY")

If ActualCount > MaxCount

akItemReference.removeitem(akbaseitem, actualcount - maxcount)

akSourceContainer.additem(akbaseitem, actualcount - maxcount)

endif

EndEvent

 

The scripts work in that I can't drop anything but gold into the purse, however, I can put as much gold as I like in it.

 

Suggestions? Insults?

Link to comment
Share on other sites

Papyrus is fickle.

 

If that is your actual code (and not a retype), then I'd suggest making sure that your variable names are correct in case.

 

For example:

akBaseItem may not be treated the same as akbaseitem

 

Also, is the intent for the player to have the coin purse visually equipped? Must they unequip it before equipping to access? If that is not the intent, then it would be best to unequip the interactive piece after it is equipped by the player. It will save them a step or two later.

 

You mentioned that you are using a vendor trunk. If you have not, ensure that the container is not set to respawn. Hopefully it is tucked away in an inaccessible empty cell where that won't be an issue but it is better to be safe than sorry.

 

Your activate line in the OnEquipped event is in the wrong location. That event should be similar to this:

 

 

Event OnEquipped(Actor akActor)
	If akActor == PlayerRef
		Game.DisablePlayerControls(False, False, False, False, False, True)	; Exit menu
		Utility.Wait(0.01)
		TheContainer.Activate(PlayerRef)					; activate container interface
		Utility.Wait(0.01) 
		Game.EnablePlayerControls(False, False, False, False, False, True)	; Reenable menu		
		If (SelfItem != WornItem)
			PlayerRef.UnequipItem(SelfItem, False, True)
		EndIf	
	EndIf
EndEvent

The unequip line is because the mod I'm working on has options for a visual model and an invisible model. The invisible model gets unequipped to save steps for the player later.

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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