Jump to content

Enabling/Disabling items depending on GetItemCount on the player?


samv96UK

Recommended Posts

Hey all!

To sum up my problem, I'm working on a part of my mod where I want the player's wealth to be illustrated through his/her vault. I am attempting to make it so that the vault contains lots of things in if the player has a lot of gold in their inventory, and not many things in if they do not have much gold.

So basically, I have five static objects (which are different sized mounds of gold), that are all set to initially disabled and I want to somehow make them enabled if the player has more than a certain amount of coins.

For example, if the player has 100 gold, the first pile would be enabled, then when they got 1000 Gold in their inventory the second pile would be enabled, but if they lost 900 gold then the second pile would be disabled again.

I'm not entirely sure how this would be done though. It tried:

 

Scriptname SanctuaryTreasuryGold extends ObjectReference  

if (Game.GetPlayer().GetItemCount(Gold001) <= 100)
  SmallGoldPile.Enable()
endIf
Endevent

MiscObject Property Gold001  Auto  
ObjectReference SmallGoldPile Auto

 

but it doesn't work. I get the error message:

 

c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\SanctuaryTreasuryGold.psc(3,0): missing EOF at 'if'
No output generated for SanctuaryTreasuryGold, compilation failed.

 

Can anyone enlighten me on what I'm doing wrong, or if it's actually possible? Thanks!

Link to comment
Share on other sites

Your script has an EndEvent, but you don't have any events in there! That's why it won't compile.

 

Here's what I would do for this:

Use a trigger. Set it somewhere that the player has to walk through to get to the vault, but where the vault's contents are still out of sight.

Use GetGoldAmount() instead of GetItemCount() -- it's a bit more obvious what you're doing and why that way. :wink:

You just need a series of if/else condition blocks:

 

Event OnTriggerEnter(ObjectReference akActionRef)
    Actor Player = Game.GetPlayer()
    Int Gold = Player.GetGoldAmount()
    If akActionRef == Player ; only do anything if the player is entering the trigger
        If Gold >= 100
            SmallGoldPile.Enable() ; Make it appear if the player is rich
        Else
            SmallGoldPile.Disable() ; Make it go away if the player gets poor
        EndIf
        If Gold >= 1000
            MediumGoldPile.Enable() ; Make it appear if the player is rich
        Else
            MediumGoldPile.Disable() ; Make it go away if the player gets poor
        EndIf
        ; etc.
    EndIf
EndEvent
Edited by kromey
Link to comment
Share on other sites

  • Recently Browsing   0 members

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