FullmetalRyuken Posted September 10, 2012 Share Posted September 10, 2012 Hello all, I'm looking for some help as far as putting a script together. My goal is when a player equips a particular necklace it will run a script that will automatically equip an armor set in the player inventory. I have skimmed through the forums and other sites and haven't found much of anything. Any help or a point in the right direction would be much appreciated!!! Link to comment Share on other sites More sharing options...
jshepler Posted September 10, 2012 Share Posted September 10, 2012 I think these might get you in the right direction...http://www.creationkit.com/OnObjectEquipped_-_Actor http://www.creationkit.com/AddItem_-_ObjectReference http://www.creationkit.com/EquipItem_-_Actor Link to comment Share on other sites More sharing options...
FullmetalRyuken Posted September 11, 2012 Author Share Posted September 11, 2012 Thanks for the help! I am new to this whole script thing, but this is what i came up with... Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) Game.GetPlayer().EquipItem(ebonymail)endEvent i attached the script to the necklace i wanted to use in ck, then compiled and came back with zero errors. Tried in game but nothing happens. Is there something i missed? Link to comment Share on other sites More sharing options...
JanusForbeare Posted September 11, 2012 Share Posted September 11, 2012 (edited) Since you're attaching the script to the necklace, you'll want OnEquipped, not OnObjectEquipped. Here's what I would recommend: Actor Property Player Auto Armor Property EbonyMail Auto Event OnEquipped(akactor) if (akactor == Player) Player.additem(EbonyMail, 1) Player.EquipItem(EbonyMail) Endif EndEvent Event OnUnequipped(akactor) if (akactor == Player) Player.UnequipItem(EbonyMail) Player.removeitem(EbonyMail, 1) Endif EndEvent EDIT: Forgot "endif" statements in my original post. I've corrected this mistake. Edited September 11, 2012 by JanusForbeare Link to comment Share on other sites More sharing options...
FullmetalRyuken Posted September 11, 2012 Author Share Posted September 11, 2012 Since you're attaching the script to the necklace, you'll want OnEquipped, not OnObjectEquipped. Here's what I would recommend: Actor Property Player Auto Armor Property EbonyMail Auto Event OnEquipped(akactor) if (akactor == Player) Player.additem(EbonyMail, 1) Player.EquipItem(EbonyMail) Endif EndEvent Event OnUnequipped(akactor) if (akactor == Player) Player.UnequipItem(EbonyMail) Player.removeitem(EbonyMail, 1) Endif EndEvent EDIT: Forgot "endif" statements in my original post. I've corrected this mistake. Still doesn't do anything in game. When I equip the necklace nothing happens. Must be something im doing when i create the script in ck, for some reason It compiles okay without any errors. Thanks for all your help Janus, going to try a couple more things before I give up on this idea. Link to comment Share on other sites More sharing options...
jshepler Posted September 11, 2012 Share Posted September 11, 2012 If you're loading a savegame where you already have the necklace from before you attached the script to it, I believe the necklace won't have the script. Because it didn't exist at the time it was spawned, it wasn't saved with the script attached, it won't be there when loaded. Try spawning a new necklace and equipping it. Link to comment Share on other sites More sharing options...
FullmetalRyuken Posted September 15, 2012 Author Share Posted September 15, 2012 instead of typing in ''EbonyMail" should i use the items id # ? This is the script im currently using and I added beggars robes instead as a test. Link to comment Share on other sites More sharing options...
jshepler Posted September 15, 2012 Share Posted September 15, 2012 No, you had it right before. Those methods take a Form, which Armor extends so that should be ok. I was referring to the necklace that script is attached to. When you attached the script to the necklace in the CK and loaded a savegame, I don't believe that script is automatically added to any existing necklaces. Scripts attached to Form objects are only attached to instances of those Form objects when at the time the instance was created. So I was suggesting that you spawn a new instance of the necklace and equipping that instead of the existing necklace you already had. Assuming my understanding of how this works is correct. Link to comment Share on other sites More sharing options...
FullmetalRyuken Posted September 15, 2012 Author Share Posted September 15, 2012 No, you had it right before. Those methods take a Form, which Armor extends so that should be ok. I was referring to the necklace that script is attached to. When you attached the script to the necklace in the CK and loaded a savegame, I don't believe that script is automatically added to any existing necklaces. Scripts attached to Form objects are only attached to instances of those Form objects when at the time the instance was created. So I was suggesting that you spawn a new instance of the necklace and equipping that instead of the existing necklace you already had. Assuming my understanding of how this works is correct. I went back to the original script(using EbonyMail) and just attached it to the common gold necklace. loaded a new save and added one through console commands, but the necklace still doesn't equip or add any armor. Could it be the way I'm attaching the script through ck? I just attach the script, compile to make sure that it succeeds, then I save and load skyrim. Thanks again for your help jshelper. Link to comment Share on other sites More sharing options...
FullmetalRyuken Posted September 16, 2012 Author Share Posted September 16, 2012 I finally succeeded at creating the script that I needed!! (After a lot of this) :wallbash: Thanks for all the help much appreciated. ;D Link to comment Share on other sites More sharing options...
Recommended Posts