phoneyLogic Posted February 19, 2013 Share Posted February 19, 2013 Hi folks, I want to run a script on an object once when its bought by the player from vendors ... and ran into a very strange problem: Begin OnAdd ... only runs when the player sells the item Begin OnDrop ... only runs when the player sells the item Begin OnSell ... only runs when the player sells the item All the blocks are running as long as I sell the item, but I need them as I buy it. But then, nothing happens. Am I'm doing sth wrong? Link to comment Share on other sites More sharing options...
luthienanarion Posted February 19, 2013 Share Posted February 19, 2013 If a vendor is the only source of obtaining the item, you can just use player.getitemcount blargobject to determine when one is obtained. Link to comment Share on other sites More sharing options...
phoneyLogic Posted February 19, 2013 Author Share Posted February 19, 2013 (edited) I want to use it for this mod:http://newvegas.nexu....com/mods/34999 The script I'm using currently is as follows: Begin MenuMode 1053 if ( Player.GetItemCount RACEMenuToken == 0 ) Player.AddItem RACEMenuToken 1 1 endif End The player can buy radios to place them into the world. But therefore another item is needed, the RACEMenuToken. The player may want to get rid of the Token. Anyway, the problem is, Idon't want to add the Token every time the player trades (all or none)Items - but only in case he buys a radio.So I attached the scripts to the radio base object in the code boxes below. But as said, they only work if I sell a radio. I may work around using the MenuMode above and write tons of code just tocheck "are we going in barter menü? How many radios do we have? Doesthis kind of change as we leave the Barter menu?" but this clearly wouldnot be my favourite solution. I was wondering, we have this cool "Begin On..." blocks, cant I just use them? I tried: Begin OnAdd; Player if MenuMode 1053 == 1 if ( Player.GetItemCount RACEMenuToken == 0 ) Player.AddItem RACEMenuToken 1 1 endif endif End Begin OnDrop; Player if MenuMode 1053 == 1 if ( Player.GetItemCount RACEMenuToken == 0 ) Player.AddItem RACEMenuToken 1 1 endif endif End Begin OnSell if ( Player.GetItemCount RACEMenuToken == 0 ) Player.AddItem RACEMenuToken 1 1 endif End They work just amazing, as long as I sell the Item. But none of them works if I buy it. :-/ Is this a bug or something? I just can't imagine why someone would intentionally disable all this blocks as soon as the player buys sth. It makes no sense to me. And that's why I figure, I might do sth wrong. Edited February 19, 2013 by tortured Tomato Link to comment Share on other sites More sharing options...
Belthan Posted February 20, 2013 Share Posted February 20, 2013 Maybe pointing out the obvious, but the semicolon after begin OnAdd starts a comment. The script will run when the object is added to any actor, not just the player, so it runs when you sell the object to a vendor. But it still seems like it should run when you buy the object from a vendor. The only thing I can see that would make this fail is if you somehow already have a token in your inventory. Link to comment Share on other sites More sharing options...
phoneyLogic Posted February 20, 2013 Author Share Posted February 20, 2013 (edited) The semicolon I added was to test it without referece.I even tried to pass the specific vendor as ref and removing all other conditions, like so Begin OnSell CliffBriscoeREF showmessage RACEKeyRadioOnMessage End Begin OnDrop CliffBriscoeREF Player.AddItem RACEMenuToken 1 1 End and it didn't work. In the barter menu these blocks only seems to run if the player is the reference. Edited February 20, 2013 by tortured Tomato Link to comment Share on other sites More sharing options...
Belthan Posted February 20, 2013 Share Posted February 20, 2013 The following works as expected for me. Specifically, when I sell the object that uses this script, the script doesn't run. When I buy it back from the vendor the message is displayed and the extra item is added to my inventory. begin OnAdd Player if MenuMode 1053 == 1 showmessage Debug player.additem ArmorCombat 1 endif end Which is functionally equivalent to your script, so I know it doesn't really help. The only other thing I can think of is this: a few months ago I had a bizarre problem where a function wasn't working as documented, many posts and pulled out hair with no luck. Gave up on the feature I was trying to implement. For unrelated reasons I had to reinstall F3 a few weeks later, lo and behold the same mod miraculously started working. Link to comment Share on other sites More sharing options...
phoneyLogic Posted February 20, 2013 Author Share Posted February 20, 2013 (edited) This would be exactly what I'm looking for.But somehow, OnAdd Player doesn't work for me as soon as I'm bartering.Wait, might it be because I'm running the script on a misc item? testing... EditYep, this seems to be the problem."OnAdd Player" works on an Apparel item but not on a Misc item.So either Misc items are bugged or the problem still is on my end. Edited February 20, 2013 by tortured Tomato Link to comment Share on other sites More sharing options...
Belthan Posted February 20, 2013 Share Posted February 20, 2013 Hm. Works on misc items for me. I attached the following script to BurnedBook01, and it runs when I buy it (but not when I sell it). begin OnAdd player if MenuMode 1053 == 1 showmessage Debug player.additem BurnedBook02 1 endif end Link to comment Share on other sites More sharing options...
phoneyLogic Posted February 20, 2013 Author Share Posted February 20, 2013 (edited) Weird, I changed the barter and loaded an older save and "OnAdd Player" works now. Think you were right, might have been a cache or even save game related problem.Anyways, I'm so glad it finally works now. ^^ Thank you for you help, I might just have given up. kudos givenluthienanarion, you already have :teehee: Edited February 20, 2013 by tortured Tomato Link to comment Share on other sites More sharing options...
Recommended Posts