Jump to content

Slight problem with my Script


Recommended Posts

This Is What I have put

Scriptname __0SMF_ColdFridge3 extends ObjectReference Const
Int Property Insert Auto Const
FormList Property WarmDrinks Auto Const
FormList Property ColdDrinks Auto Const
Message Property FridgeMessage Auto Const
Container Property PristineFridge Auto Const
Event OnActivate(ObjectReference akActionRef)
int selectedOption = FridgeMessage.Show()
If (selectedOption == 1) ; Cancel
return
EndIf
If (Game.GetPlayer().GetItemCount(WarmDrinks) < Insert) ;
Debug.Notification("You need a Warm Drink")
return
EndIf
Game.GetPlayer().RemoveItem(WarmDrinks, Insert)
If (selectedOption == 0) ;
Game.GetPlayer().AddItem(ColdDrinks)
Debug.Notification("Have A cold One")
EndIf
EndEvent

The Game.GetPlayer()AddItem is the one that needs to go in a container
Link to comment
Share on other sites

You want the warm drink(player has it first) to go in a container, or you want the cold drink(doesn't exist until player gives warm drink) to go in the container?

 

In any case your code is nested improperly and will always remove a warm drink from the player no matter what option they pick.

According to what you said you want the cold drink to go in the container, but you still used Game.GetPlayer() ?

You should be using PristineFridge.AddItem(ColdDrinks) if that's the right container

Link to comment
Share on other sites

Whilst game.getplayer call is expensive, in a holotape/message menu which suspends realtime world execution its not a major problem.

 

If avoiding more properties on nasty script fragments, the best practice is to call the function ONCE per function by assigning it:

 

Actor PlayerREF = Game.GetPlayer()

...

PlayerREF.RemoveItem(WarmDrinkBaseForm, int aiCount = 1, bool abSilent = false, akOtherContainer = Fridge)

...

Fridge.RemoveItem(ColdDrinkBaseForm, int aiCount = 1, bool abSilent = false, akOtherContainer = PlayerREF)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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