krestor Posted February 25, 2024 Posted February 25, 2024 I have been trying to make a script where when a player places 1000 gold into a strongbox it opens a door and locks the strongbox. This is what i have so far that won't compile.
Gristle Posted February 25, 2024 Posted February 25, 2024 I'm no expert here, but I do see some problems: Container is not defined. Perhaps this should be LastStrong? Gold001 is defined as a property, but you are using Gold instead. Gold001 is not an ObjectReference, it is a Miscellaneous Object (I forget the abbreviation). 1
krestor Posted February 25, 2024 Author Posted February 25, 2024 So tried your advice and this is what i got. I may have misunderstood something idk.
MadMansGun Posted February 25, 2024 Posted February 25, 2024 add "MiscObject Property Gold001 auto" delete "int gold001" also you don't need the ( in front of container or the ) after 1000 for this script
krestor Posted February 25, 2024 Author Posted February 25, 2024 @MadMansGun That fixed most of it but i got this. Can you please explain this?
MadMansGun Posted February 25, 2024 Posted February 25, 2024 (edited) your top "if container.getitemcount" line should be "if laststrong.getitemcount" Edited February 25, 2024 by MadMansGun
krestor Posted February 25, 2024 Author Posted February 25, 2024 @MadMansGun I tried that and i got this. and if i remove the ) after 1000 i get even more errors
MadMansGun Posted February 25, 2024 Posted February 25, 2024 if LastStrong.GetItemCount(Gold001) == 1000
MadMansGun Posted February 25, 2024 Posted February 25, 2024 ...maybe try replaceing if LastStrong.GetItemCount(Gold001) == 1000 with Int chestgold = GetItemCount(gold001) if chestgold == 1000
krestor Posted February 25, 2024 Author Posted February 25, 2024 @MadMansGun I got this. I have no idea what the issues is
krestor Posted February 25, 2024 Author Posted February 25, 2024 @MadMansGun Me too. Thanks for trying.
MadMansGun Posted February 25, 2024 Posted February 25, 2024 12 minutes ago, krestor said: . long shot but maybe Form GetGold = Game.GetFormFromFile(0x0000000F, "Skyrim.ESM") Int StoreGold = LastStrong.GetItemCount(GetGold) if StoreGold >= 1000
krestor Posted February 25, 2024 Author Posted February 25, 2024 @MadMansGun Where do i put this in the script?
MadMansGun Posted February 25, 2024 Posted February 25, 2024 replace "if LastStrong.GetItemCount(Gold001) == 1000" with those 3 lines
krestor Posted February 25, 2024 Author Posted February 25, 2024 @MadMansGun When i put in Event OnClose(ObjectReference akActionRef) if LastStrong.GetItemCount(Gold001) == 1000) LastDoor.Activate() LastStrong.Lock() endIf EndEvent ObjectReference Property LastDoor Auto Container Property LastStrong Auto MiscObject Property Gold001 Auto The only error i get is. I wonder if i formatted it wrong. I have tried ) and)) and then i tried ()) after the 1000 and nothing works
Tlam99 Posted February 25, 2024 Posted February 25, 2024 (edited) Form cast problem I guess 2 hours ago, krestor said: LastStrong.GetItemCount(Gold001) == 1000) LastDoor.Activate() The function returns an int It's not defined under properties and no formcast Int iLastStrong = LastStrong.GetItemCount(Gold001 as form) If iLastStrong == 1000 or direct check If ( LastStrong.GetItemCount(Gold001 as Form ) == 1000 PS: recommend not use check for the exact Nr., better > or so. Otherwise it can happen, the condition will never met. E.g. put or withdraw 2 coins ? Edited February 25, 2024 by Tlam99
AndrewLRG Posted February 25, 2024 Posted February 25, 2024 GetItemCount() must be called on ObjectReference, not on Container. It should look like this: Event OnClose(ObjectReference akActionRef) if LastStrong.GetItemCount(Gold001) == 1000 LastDoor.Activate(LastDoor) LastStrong.Lock() endIf EndEvent ObjectReference Property LastDoor Auto ObjectReference Property LastStrong Auto MiscObject Property Gold001 Auto You will need to set LastStrong Property to the strongbox you placed in the world. Also, I'm not sure that Door can be activated to open. If it does not work you can try replacing LastDoor.Activate(LastDoor) with LastDoor.PlayGamebryoAnimation("Open", 5.0) This will force the door to play "Open" animation.
MadMansGun Posted February 25, 2024 Posted February 25, 2024 (edited) ah yes, the stupid easy to miss bullshit that fucks me up the ass at every turn. but since this is a object script wouldn't "self.GetItemCount(Gold001) == 1000" also work? Edited February 25, 2024 by MadMansGun
AndrewLRG Posted February 25, 2024 Posted February 25, 2024 1 hour ago, MadMansGun said: ah yes, the stupid easy to miss bullshit that fucks me up the ass at every turn. but since this is a object script wouldn't "self.GetItemCount(Gold001) == 1000" also work? Yep, it should.
ghastley Posted February 26, 2024 Posted February 26, 2024 Another point to consider is that Lock() will by default set the lowest level of lock, and the highest is “requires a key”. If you want the container not to be openable by the player, then consider using BlockActivation instead, as this stops the container from being used at all. The down side is that there is no failure message to indicate that you can not open it. It just has no activation prompt.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now