wholegrain Posted January 8, 2017 Posted January 8, 2017 Scriptname _aaa_FiftyFifty Extends ObjectReference MiscObject Property Gold001 Auto Int Property GoldAmount = 50 Auto Event OnActivate(ObjectReference akActionRef) GoToState("Busy") If(akActionRef==(Game.Getplayer())) If(akActionRef.GetItemCount(Gold001)>=(GoldAmount)) If(Utility.RandomInt(0,1)) akActionRef.AddItem(Gold001, GoldAmount) Else akActionRef.RemoveItem(Gold001, GoldAmount) EndIf Else Debug.MessageBox("Not enough gold") Endif Endif GoToState("") EndEvent State Busy Event OnActivate(ObjectReference akActionRef) ; EndEvent EndState Why isn't this script working. This script was meant to give or remove 50 gold from the player inventory whenever he clicked on an object, but it keeps saying "Not enough gold" and not doing anything even though I have 1901 gold inside my inventory. What's wrong?
davisev5225 Posted January 9, 2017 Posted January 9, 2017 If(akActionRef.GetItemCount(Gold001)>=(GoldAmount)) What is that supposed to be checking? Right now, you're comparing the ObjectID for the object you activate to the amount of gold you want to give the player (in this case, 50 gold). That won't work.
wholegrain Posted January 9, 2017 Author Posted January 9, 2017 checking if the player has more than 50 gold. If(PlayerRef.GetItemCount(50) >= (GoldAmount) would this work? Scriptname _aaa_FiftyFifty Extends ObjectReference MiscObject Property Gold001 Auto Int Property GoldAmount = 50 Auto Event OnActivate(ObjectReference akActionRef) GoToState("Busy") If(akActionRef==(Game.Getplayer())) If(PlayerRef.GetItemCount(50) >= (GoldAmount) If(Utility.RandomInt(0,1)) akActionRef.AddItem(Gold001, GoldAmount) Else akActionRef.RemoveItem(Gold001, GoldAmount) EndIf Else Debug.MessageBox("Not enough gold") Endif Endif GoToState("") EndEvent State Busy Event OnActivate(ObjectReference akActionRef) ; EndEvent EndState
LazyBoot Posted January 9, 2017 Posted January 9, 2017 If(akActionRef.GetItemCount(Gold001)>=(GoldAmount)) I'm fairly sure you don't need to have "GoldAmount" in ( and ) there. Edit: try your original code but with If(akActionRef.GetItemCount(Gold001)>=GoldAmount)If that doesn't work, try printing akActionRef.GetItemCount(Gold001) to screen somewhere. In the "Not enough gold" box maybe.
wholegrain Posted January 9, 2017 Author Posted January 9, 2017 wait that doesn't even compile. I will try this: Scriptname gamble_script extends ObjectReference MiscObject Property Gold001 Auto Int Property GoldAmount = 50 Auto Event OnActivate(ObjectReference akActionRef) GoToState("Busy") If(akActionRef==(Game.Getplayer())) If(akActionRef.GetItemCount(Gold001)>=GoldAmount) If(Utility.RandomInt(0,1)) akActionRef.AddItem(Gold001, GoldAmount) Else akActionRef.RemoveItem(Gold001, GoldAmount) EndIf Else Debug.MessageBox("Not enough gold") Endif Endif GoToState("") EndEvent State Busy Event OnActivate(ObjectReference akActionRef) ; EndEvent EndState;
LazyBoot Posted January 9, 2017 Posted January 9, 2017 I edited in another suggestion as well while you replied it seems.
wholegrain Posted January 9, 2017 Author Posted January 9, 2017 nope doesn't work... is Gold001 the right id for gold?
kozzz Posted January 9, 2017 Posted January 9, 2017 Maybe you forgot to fill Gold001 property and GetItemCount(None) called?
wholegrain Posted January 9, 2017 Author Posted January 9, 2017 yeah, I get 0 in return. What's the real id for gold inside player inventory?
Andy14 Posted January 9, 2017 Posted January 9, 2017 checking if the player has more than 50 gold. If(PlayerRef.GetItemCount(50) >= (GoldAmount) would this work? Scriptname _aaa_FiftyFifty Extends ObjectReference MiscObject Property Gold001 Auto Int Property GoldAmount = 50 Auto Event OnActivate(ObjectReference akActionRef) GoToState("Busy") If(akActionRef==(Game.Getplayer())) If(PlayerRef.GetItemCount(50) >= (GoldAmount) If(Utility.RandomInt(0,1)) akActionRef.AddItem(Gold001, GoldAmount) Else akActionRef.RemoveItem(Gold001, GoldAmount) EndIf Else Debug.MessageBox("Not enough gold") Endif Endif GoToState("") EndEvent State Busy Event OnActivate(ObjectReference akActionRef) ; EndEvent EndState I do not think so If the variable is always 50: Why global and above all as Auto If there is no quest with the properties, it is quite nonsensical. If there is a quest for it, just declaration but no values - otherwise also nonsensical. If GoldAmount is ALWAYS 50, then it is easier to compare than PlayerRef.GetItemCount(50) >= 50. Why variable, if at all times the same value?
wholegrain Posted January 9, 2017 Author Posted January 9, 2017 What do you mean by fill? Wait, do I need to do something else to attach Gold001 to the gold inside the player inventory. I thought you could just access it via a script.
Andy14 Posted January 9, 2017 Posted January 9, 2017 What do you mean by fill? Wait, do I need to do something else to attach Gold001 to the gold inside the player inventory. I thought you could just access it via a script. He means - your script in CK (as a quest, magic effect - whatever). Properties - Auto fill - or - manually. He means precisely the "MiscObject Property Gold001 Auto" Where does that come from?
wholegrain Posted January 9, 2017 Author Posted January 9, 2017 I just attached a script to an activator item.
LazyBoot Posted January 9, 2017 Posted January 9, 2017 I just attached a script to an activator item.You need to go into properties on the script in the creation kit and set Gold001 to whatever gold is.
wholegrain Posted January 9, 2017 Author Posted January 9, 2017 Gold001 is supposed to be the gold inside the player's inventory. How do I link Gold001 to the gold inside the player's inventory?
LazyBoot Posted January 9, 2017 Posted January 9, 2017 Gold001 is supposed to be the gold inside the player's inventory? How do I link Gold001 to the gold inside the player's inventory?Give me a moment and I'll grab some screenshots to show you.
Andy14 Posted January 9, 2017 Posted January 9, 2017 Gold001 is supposed to be the gold inside the player's inventory? How do I link Gold001 to the gold inside the player's inventory? If(akActionRef.GetItemCount(Gold001)>=GoldAmount) Your own script. ?!
wholegrain Posted January 9, 2017 Author Posted January 9, 2017 I am seeing Gold001 MiscObject Gold001 (0000000F) Do I need to change 0000000F to something else? Gold001 is supposed to be the gold inside the player's inventory? How do I link Gold001 to the gold inside the player's inventory? If(akActionRef.GetItemCount(Gold001)>=GoldAmount) Your own script. ?! I just asked someone to write a script that would give me or remove 50 gold from my inventory when clicking an item.
LazyBoot Posted January 9, 2017 Posted January 9, 2017 I am seeing Gold001 MiscObject Gold001 (0000000F) Do I need to change 0000000F to something else? Gold001 is supposed to be the gold inside the player's inventory? How do I link Gold001 to the gold inside the player's inventory? If(akActionRef.GetItemCount(Gold001)>=GoldAmount) Your own script. ?! I just asked someone to write a script that would give me or remove 50 gold from my inventory when clicking an item. It should look something like this
Andy14 Posted January 9, 2017 Posted January 9, 2017 I am seeing Gold001 MiscObject Gold001 (0000000F) Do I need to change 0000000F to something else? Gold001 is supposed to be the gold inside the player's inventory? How do I link Gold001 to the gold inside the player's inventory? If(akActionRef.GetItemCount(Gold001)>=GoldAmount) Your own script. ?! I just asked someone to write a script that would give me or remove 50 gold from my inventory when clicking an item. MiscObject Property Gold001 Auto Gold001 is just a name, a variable. The value of this variable must be in the Quest / Magiceffekt / etc. With properties. It can be gold 0000000f or other things - your decision
wholegrain Posted January 9, 2017 Author Posted January 9, 2017 Isn't this how it's supposed to be? I am seeing Gold001 MiscObject Gold001 (0000000F) Do I need to change 0000000F to something else? Gold001 is supposed to be the gold inside the player's inventory? How do I link Gold001 to the gold inside the player's inventory? If(akActionRef.GetItemCount(Gold001)>=GoldAmount) Your own script. ?! I just asked someone to write a script that would give me or remove 50 gold from my inventory when clicking an item. Capture2.PNGIt should look something like this Yeah, that's what I got basically. The question is if scripts can be attached to an activator. Do I need to make a Quest script for it to work or something?
Andy14 Posted January 9, 2017 Posted January 9, 2017 Ok - in this case, the name and value are the same. So Gold001 is not just a variable - sorry.
wholegrain Posted January 9, 2017 Author Posted January 9, 2017 So, do I just need to change the variable name to make it work? lol? http://www.skyrimsearch.com/categories/items/1/Gold001/ It's referencing to gold and it's checking if the player has 50 gold, so logically it should be fine, no? Could the bug be due to the fact I have a lot of scripts running at the same time? Does anyone know what's wrong?
wholegrain Posted January 9, 2017 Author Posted January 9, 2017 Ok, I fixed it. Used: Game.GetPlayer().GetGoldAmount() and now it works. Thanks guys. Also, if you can create nif for backgammon board, checker board and playing card deck. Please, let me know.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.