theoneandonlyboiler Posted August 12, 2012 Share Posted August 12, 2012 Hi I made a Rivet City apartment and now i'm trying to make it buyable at the market place. I've managed to get one of the merchants to sell it as an item. But the script that adds the actual key and deed and removes the apartment item from the player inventory just won't work. and with my very limited understanding of how scripts work i can't find the error. here is the script:**********************************************scn RivetCityHouseScript Begin OnAdd player Player.AddItem HouseDeedRivetCity 1Player.AddItem RivetCityHouseKey 1Player.RemoveItem RivetCityApartment 1 End********************************************** The script is attached to the item that is sold by the merchant. So it should run if the player buys the apartment, add the key and deed to the player, remove the item and shut down. The GECK doesn't give me any errors when saving the script. So, what is wrong with it? Link to comment Share on other sites More sharing options...
Ladez Posted August 12, 2012 Share Posted August 12, 2012 The script looks valid, are you sure you haven't made an oversight somewhere else? Link to comment Share on other sites More sharing options...
theoneandonlyboiler Posted August 13, 2012 Author Share Posted August 13, 2012 I checked and rechecked everything. The item is there, the key is there, the deed is there, the names match with the script commands. I can add the key and deed with the console in game and it works fine and i can buy the item. The script is attached to the item that is sold by the merchant so it should rund as soon as i buy it. So everything is as it should be as far as i understand it. It's just the script that won't run. Link to comment Share on other sites More sharing options...
theoneandonlyboiler Posted August 13, 2012 Author Share Posted August 13, 2012 Ok, now it is getting really confusing: If i drop the apartment from my inventory after buying it and then pick it up again, the script runs! So buying it does'nt count as adding it to my inventory but throwing it on the floor and picking it up again does? What the f***!? So at least it works somehow. But i would prefer it to run on buying the apartment. Any ideas how to accomplish this? Link to comment Share on other sites More sharing options...
Ladez Posted August 13, 2012 Share Posted August 13, 2012 So somehow the OnAdd doesn't run when the item is bought. It's odd, I accomplished to do it just a few days ago in a mod of my own so it should be possible. Anyways, you could alternatively make a quest script with a gamemode block instead, which continuously checks if you have the item in your inventory. ScriptName RivetCityHouseScript BEGIN GameMode If Player.GetItemCount RivetCityApartment > 0 Player.AddItem HouseDeedRivetCity 1 Player.AddItem RivetCityHouseKey 1 Player.RemoveItem RivetCityApartment 1 1 StopQuest RivetCityHouseQuest EndIf END Attach this script to a Start Game Enabled quest called RivetCityHouseQuest. It will keep running until you have the item in your inventory, at which point it will add the key and deed, remove the item and stop the quest from running as there's no further use for it. Hope it helps. Link to comment Share on other sites More sharing options...
theoneandonlyboiler Posted August 13, 2012 Author Share Posted August 13, 2012 (edited) Thanks Ladez. I'll try this :) EDIT Yep, that did it! :) But isn't it a problem when there is a script constantly running that doesn't need to? Say you never buy that apartment, then the script will run forever... Edited August 13, 2012 by theoneandonlyboiler Link to comment Share on other sites More sharing options...
prensa Posted August 13, 2012 Share Posted August 13, 2012 theoneandonlyboiler - Hello! I'm no expert on scripting, still learning myself. :) I tested OnAdd too & it seemed to work but you could also try OnSell instead: scn RivetCityHouseScript Begin OnSell Player.AddItem HouseDeedRivetCity 1Player.AddItem RivetCityHouseKey 1Player.RemoveItem RivetCityApartment 1 1 end You attach that script to the item being sold. The addition of the space & 1 on the end of the RemoveItem line means no message will be displayed of the item being removed, that can be handy if you don't want to spoil the illusion by having an item removed that's not really meant to have been there. Hope this helps! Prensa Link to comment Share on other sites More sharing options...
Ladez Posted August 13, 2012 Share Posted August 13, 2012 @theoneandonlyboiler Well, generally you don't want to keep scripts running unless there's a reason for it. This script, however, barely uses any system resources, it's a simple check and a few lines of code and it does serve a purpose albeit small. @prensa Damn, I totally forgot that blocktype existed. *facepalm* :rolleyes: Link to comment Share on other sites More sharing options...
JkKILER Posted August 13, 2012 Share Posted August 13, 2012 (edited) Well that blocktype could work, or you could use the doonce command: -----------------------------------------scn RivetCityHouseScript Short DoOnce Begin Onadd player If DoOnce == 0 Player.AddItem HouseDeedRivetCity 1Player.AddItem RivetCityHouseKey 1Player.RemoveItem RivetCityApartment 1 1 set DoOnce to 1 end----------------------------------------- Edited August 13, 2012 by JkKILER Link to comment Share on other sites More sharing options...
Ladez Posted August 14, 2012 Share Posted August 14, 2012 @JkKILER DoOnce is not really so much a command as it is a technique, which is employed when you want something to run only one time. The OnAdd block already does that by default, it runs one time when the scripted item is added to an inventory, that's it. Your script is not really any different from the original one. :) Link to comment Share on other sites More sharing options...
Recommended Posts