Jump to content

Objects not being enabled by script


Predence00

Recommended Posts

In a house mod I made, I have a script attached to a sign that when you choose to pay 5000 gold you get the deed and it should enable the various workbenches used to build the house.

But for some people they are stating that this sign will take the 5000 gold and give the deed but will not enable the workbench or it will not do anything but take 5000 gold. Any reason for this?

 

Script:

ObjectReference Property ObjectEnabled auto

Message Property SteadingMenuMessage auto

LeveledItem Property DeedGuideLeveledList auto
MiscObject Property Gold auto

Event OnActivate(ObjectReference akActionRef)
SteadingBuyMenu()
EndEvent

Function SteadingBuyMenu(int MsgButton = 0)
MsgButton = SteadingMenuMessage.Show()
If MsgButton == 0
Game.FadeOutGame(false, true, 2.0, 2.0)
ObjectEnabled.enable()
Game.GetPlayer().AddItem(DeedGuideLeveledList, 1, false)
Game.GetPlayer().RemoveItem(Gold, 5000,false)
ElseIf MsgButton == 1

EndIf
EndFunction

 

I have tested this multiple times with multiple different mods but can't recreate the issue.

Link to comment
Share on other sites

Nothing seems wrong to me, you may want to check that activator is the player and check if its enabled before removing the gold in the case enable fails for whatever reason. I'd write it like this:

Scriptname lalal Extends ObjectReference

ObjectReference Property ObjectEnabled auto
Message Property SteadingMenuMessage auto
LeveledItem Property DeedGuideLeveledList auto
MiscObject Property Gold auto

Event OnActivate(ObjectReference akActionRef)
If akActionRef == game.GetPlayer()
  int MsgButton = 0
  MsgButton = SteadingMenuMessage.Show()
  If !MsgButton
   Game.FadeOutGame(false, true, 2.0, 2.0)
   ObjectEnabled.enable()
   If !ObjectEnabled.IsDisabled()
    akActionRef.AddItem(DeedGuideLeveledList, 1, false)
    akActionRef.RemoveItem(Gold, 5000,false)
   Else
    ;something went wrong, maybe a notification here?
   Endif
  Endif
Endif
EndEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

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