Highlord90 Posted June 19, 2016 Share Posted June 19, 2016 I'm currently working on a mod where I would like the player to optionally buy a key to a small cabin for a simple player home. The issue I have is 0 papyrus experience. I'd like to take away 1000 gold from the player but ONLY if the player has that amount of money avaliable. If he doesn't the NPC will say 'Sorry you cant afford it' and if he does the NPC says thanks, you get a key and the 1000 gold is removed. I've got the dialogue set up and working up until the Will you buy it Yes/No dialogue, I just need to have the money detected and removed if there's enough. Thanks in advance to anyone who can help. (FYI I am using the Dialogue View in CK) Link to comment Share on other sites More sharing options...
Fantafaust Posted June 19, 2016 Share Posted June 19, 2016 (edited) Something like: ------------if (Game.GetPlayer().GetItemCount(Gold) >= 1000) ;do the thing, say the positive responseElse ;don't do the thing, say the negative responseendIf------------- You will have to define gold in the properties Edited June 19, 2016 by Fantafaust Link to comment Share on other sites More sharing options...
Highlord90 Posted June 19, 2016 Author Share Posted June 19, 2016 (edited) I don;t understand, man alive why can't I wrap my head around coding...Maybe I should just give up on modding Edited June 19, 2016 by Highlord90 Link to comment Share on other sites More sharing options...
KunoMochi Posted June 19, 2016 Share Posted June 19, 2016 (edited) @Highlord90:You will have to add that script shown by Fantafaust above into the "Yes" dialogue Papyrus fragment. Of course, you also have to add in the line to add the key and remove the gold from the player. Also, you might be able to do "Game.GetPlayer().GetGoldAmount()" instead of "Game.GetPlayer().GetItemCount(Gold)" [unless the former method doesn't work]. In the IF statement, you'll probably have to use this: Game.GetPlayer().RemoveItem(Form akItemToRemove, int aiCount = 1, bool abSilent = false, ObjectReference akOtherContainer = None)So the whole thing would be something like: ; check if player gold amount is greater than or equal to 1000 if (Game.GetPlayer().GetGoldAmount() >= 1000) ; lines to remove gold from player then adds key to player Game.GetPlayer().RemoveItem(pItemGold, 1000) Game.GetPlayer().AddItem(pItemKey, 1) endIf You'll have to add the properties in to the script fragment on the right. I suggest compiling/saving the fragment with a blank space first (i.e., a space) so you can add in the properties before adding in and compiling the code to bypass the errors. Edited June 19, 2016 by KunoMochi Link to comment Share on other sites More sharing options...
Fantafaust Posted June 19, 2016 Share Posted June 19, 2016 I'll be online later tonight after work(right now 2:40, will be home at 5) working on my mod, as I tend to multitask, so if you still aren't understanding let me know and I'll try to help you. Link to comment Share on other sites More sharing options...
KunoMochi Posted June 19, 2016 Share Posted June 19, 2016 I just noticed that the dialogue conditions has a "GetItemCount", where you can set the item to "Gold001" and weigh against "1000". That way, you can run a specific line with the script lines to remove the gold and add the key, while another to tell the player that they do not have enough gold. That may work out better. :) Link to comment Share on other sites More sharing options...
Fantafaust Posted June 19, 2016 Share Posted June 19, 2016 That's a much better solution, yes. :) try that one highlord Link to comment Share on other sites More sharing options...
Highlord90 Posted June 19, 2016 Author Share Posted June 19, 2016 I'll save this page, I spent 2 days on this and got so frustrated that uninstalling Skyrim was better for my health at the moment. Thanks for the info, it will be used eventually :) Link to comment Share on other sites More sharing options...
MaximilianPs Posted September 25, 2016 Share Posted September 25, 2016 Sorry for necromancing it, but I'm interested too.. What I'm trying to do is that, I've a table filled with food and stuff, the player would be able to get the object but I would like to subtract the object value, so I need to check if player have enough money before the selected object is effectively picked up. Actually I've 2 problems:how to get object value?how to run the script before the game put the object in the player inventory ? ; check if player gold amount is greater than or equal to selected object if (Game.GetPlayer().GetGoldAmount() >= SelectedObject.value) ; lines to remove gold from player then adds key to player Game.GetPlayer().RemoveItem(pItemGold, SelectedObject.value) ; add object to the player inventory Game.GetPlayer().AddItem(SelectedObject, 1) else Debug.Message("You haven't enough money to pay it"); endIf Also I would give to the player the option to steal it, but this is another story.... (another problem for another time :happy: ) Link to comment Share on other sites More sharing options...
FrankFamily Posted September 25, 2016 Share Posted September 25, 2016 id make those items unique activators (shared script) so You can react better to activation and give or not the item if the player has the gold or is sneaking, something like this: Scriptname BuyItem Extends ObjectReference Miscobject property myitem auto; fill with the associated misc item the activator represents. Miscobject property gold auto Event onactivate(ObjectReference akActionRef) If akactivator == game.getplayer() If akactivator.IsSneaking() akactivator.Additem(myitem) DisableNoWait() Delete() Else Int Cost = myitem.getgoldvalue() If akactivator.getgoldamount() >= Cost akactivator.RemoveItem(gold, Cost) akactivator.Additem(myitem) DisableNoWait() Delete() Else debug.notification("You don't have enough gold") Endif Endif Endif Endevent EDIT: added deleting of the activator and corrected the activate event, is objectreference parameter not actor, wrote it on the phone... Link to comment Share on other sites More sharing options...
Recommended Posts