Jump to content

Does anyone know what scripting event can be used to prevent a player from using an item?


AsteroidLeaf

Recommended Posts

For the sake of simplicity in explaining, say I have 4 potions (or aid items) and i want the player to be able to only use 3 at a time until a timer is up. if the player tries to use the 4th item before the timer is up, I want to stop the player from being able to consume the 4th item and then be told they have to wait. What scripting event can i use to prevent the player from being able to use an item they otherwise would be able to use?

I already have a way to keep track of how many items used, and a timer that starts upon using the first item. I also already have a boolean setup to say true or false if the timer is active. I'd like to use this logic to say if the timer is still running and the player already used 3 items, then they can NOT use any more until the timer is up.

I used 

Event OnItemEquipped(Form akBaseObject, ObjectReference akReference)

Already to check for consumed item with a certain keyword, then increment an integer variable for how many items were consumed and start a timer.

What event can i look for to prevent the usage of anymore? Should i just use the same event but have a condition for if its 3 or more playerRef.unequip(*item) or something? I don't know if this would work because the items are consumables and just disappear when you use it.

I tried to use 

Function UnequipItem(Form akBaseObject, bool abPreventEquip = false, bool abSilent = false)
    Game.GetPlayer().UnequipItem(akBaseObject, True, False)
EndFunction

With the bool set to true to "prevent" usage, but it didn't seem to work. It still let me use the 4th item.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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