Jump to content

Access a container from a switch (script)


tagigan

Recommended Posts

I have the "Create a bank" script from the wiki and I would like to activate it from a switch in another location within the same cell. The container is a Parent to the switch.

When the switch is activated the Message Box pops up and can deposit gold to the container. But, I still can't access the container (button 9)

Thanks for any advice offered.

 

===================================================================

Script attached to container.

 

Scn AEMBankContainer

 

Short Button

Short DoOnce

Short ChestGoldCount

Short PlayerGoldCount

Short PlayerLevel

 

Begin onActivate

Messagebox "How much gold do you want to put in the deposit box? (Currently %g gold)", ChestGoldCount, "Done", "100 gold", "250 gold", "500 gold", "1000 gold", "2500 gold", "5000 gold", "10000 gold", "50000 gold", "Access Chest"

End

 

Begin Gamemode

 

Set PlayerLevel to (Player.Getlevel)

Set button to getbuttonpressed

If button > -1

If charactergen.debug == 1

Message "Button = %.0f", button

Endif

 

Set PlayerGoldCount to Player.Getitemcount Gold001

 

If (Button == 0)

Return

Elseif (Button == 1)

If PlayerGoldCount < 100

Messagebox "You don’t have enough gold"

Elseif player.Getitemcount Gold001 >= 100

Additem Gold001 100

Set ChestGoldCount to (ChestGoldCount + 100)

Player.RemoveItem Gold001 100

Endif

Elseif (Button == 2)

If PlayerGoldCount < 250

Messagebox "You don’t have enough gold"

Elseif player.Getitemcount Gold001 >= 250

Additem Gold001 250

Set ChestGoldCount to (ChestGoldCount + 250)

Player.RemoveItem Gold001 250

Endif

Elseif (Button == 3)

If PlayerGoldCount < 500

Messagebox "You don’t have enough gold"

Elseif player.Getitemcount Gold001 >= 500

Additem Gold001 500

Set ChestGoldCount to (ChestGoldCount + 500)

Player.RemoveItem Gold001 500

Endif

Elseif (Button == 4)

If PlayerGoldCount < 1000

Messagebox "You don’t have enough gold"

Elseif player.Getitemcount Gold001 >= 1000

Additem Gold001 1000

Set ChestGoldCount to (ChestGoldCount + 1000)

Player.RemoveItem Gold001 1000

Endif

Elseif (Button == 5)

If PlayerGoldCount < 2500

Messagebox "You don’t have enough gold"

Elseif player.Getitemcount Gold001 >= 2500

Additem Gold001 2500

Set ChestGoldCount to (ChestGoldCount + 2500)

Player.RemoveItem Gold001 2500

Endif

Elseif (Button == 6)

If PlayerGoldCount < 5000

Messagebox "You don’t have enough gold"

Elseif player.Getitemcount Gold001 >= 5000

Additem Gold001 5000

Set ChestGoldCount to (ChestGoldCount + 5000)

Player.RemoveItem Gold001 5000

Endif

Elseif (Button == 7)

If PlayerGoldCount < 10000

Messagebox "You don’t have enough gold"

Elseif player.Getitemcount Gold001 >= 10000

Additem Gold001 10000

Set ChestGoldCount to (ChestGoldCount + 10000)

Player.RemoveItem Gold001 10000

Endif

Elseif (Button == 8)

If PlayerGoldCount < 50000

Messagebox "You don’t have enough gold"

Elseif player.Getitemcount Gold001 >= 50000

Additem Gold001 50000

Set ChestGoldCount to (ChestGoldCount + 50000)

Player.RemoveItem Gold001 50000

Endif

Elseif (Button == 9)

Activate

Endif

Set ChestGoldCount to (Getitemcount Gold001)

Endif

 

If GetDayOfWeek != 0 && DoOnce == 1

Set DoOnce to 0

Elseif GetDayOfWeek == 0 && DoOnce == 0

RemoveItem Gold001 ChestGoldCount

Set ChestGoldCount to (ChestGoldCount * (1.00 + PlayerLevel / 1000))

AddItem Gold001 ChestGoldCount

Message "You have received interest!"

Set DoOnce to 1

Endif

 

End

=========================================================

Script attached to switch.

 

Scn AEMBankATMbutton

; activates parent

 

short init

short busy

ref target

ref mySelf

 

Begin OnActivate

 

if init == 0

Set target to GetParentRef

Set mySelf to GetSelf

Set init to 1

endif

 

if IsActionRef mySelf == 0 && busy == 0

Set busy to 1

target.Activate mySelf 1

PlayGroup forward 0

endif

 

End

 

Begin GameMode

 

if IsAnimPlaying == 0 && busy == 1

Set busy to 0

endif

 

End

Link to comment
Share on other sites

  • Recently Browsing   0 members

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