IronDusk33 Posted November 4, 2013 Share Posted November 4, 2013 (edited) Hello, I'm trying to make a script for an armor item, where when the item is added to the player's inventory, its automatically equipped, and can't be unequipped. I attached this script to the armor. This is what I came up with:----------------------------------------------------------------------------------------------------Scriptname IronHookEquipScript extends ObjectReference Actor Property PlayerREF Auto Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) If akNewContainer == PlayerREF Game.GetPlayer() .EquipItem (IronHook, true, true) EndIf EndEvent-----------------------------------------------------------------------------------------------However, being absolutely clueless with scripting, when I attempted to save, this error popped up:-----------------------------------------------------------------------------------------------Starting 1 compile threads for 1 files...Compiling "IronHookEquipScript"...C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\IronHookEquipScript.psc(7,31): variable IronHook is undefinedNo output generated for IronHookEquipScript, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on IronHookEquipScript--------------------------------------------------------------------------------------------------I have no idea of what is going on, or if I have anything right. Please Help! Edited November 4, 2013 by IronDusk33 Link to comment Share on other sites More sharing options...
csirgli Posted November 5, 2013 Share Posted November 5, 2013 Hi, I'm not really familliar with papyrus (just started to look it at yestarday), but an ide which can be useful. The below message is saying the IronHook is unknown.- When a console command player.additem used, the item number (FormID) has to be used. Like 000DB5D2 which is the crafting material "leather". Do you know the item number for "Iron Hook" ? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 5, 2013 Share Posted November 5, 2013 You need to declare a property variable for your armor piece. The modified script is as follows Scriptname IronHookEquipScript extends ObjectReference Actor Property PlayerREF Auto Armor Property IronHook Auto Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) If akNewContainer == PlayerREF PlayerREF.EquipItem(IronHook, true, true) EndIf EndEvent Be sure to fill your properties after you compile your script else it won't do anything. However, since this script is on the object itself... There is one trick you can do which will remove the need for that property. Scriptname IronHookEquipScript extends ObjectReference Actor Property PlayerREF Auto Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) If akNewContainer == PlayerREF PlayerREF.EquipItem(Self, true, true) EndIf EndEvent You can use Self to refer to the object running the script. Provided that object is a CK object or placed reference. Aliases on quests can't use Self directly, they need to get their reference. But I'm getting ahead of what you need to know. Link to comment Share on other sites More sharing options...
IronDusk33 Posted November 5, 2013 Author Share Posted November 5, 2013 Thanks! I did some tweaking and was able to get the item to auto-equip. I had to make a property for the Iron Hook, the Self trick didn't work for some reason. There is one more problem though. I can't unequip the hook, but I can drop it. Is there some trick to keep the character from dropping the hook, and possibly keep it from getting removed from my character when he is taken to jail? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 5, 2013 Share Posted November 5, 2013 I haven't tested this... and I'm not too sure on my handling of what happens when it is dropped. But it is at least worth a test. This script would go on the player alias on a dummy quest that is running start game enabled (note the quest doesn't have to be start game enabled if the hook is being given and maintained as part of another quest. So long as whatever quest has the player alias is going to run constantly for the life of the hook) ScriptName IronHookPlayerAliasScript Extends ReferenceAlias Armor Property IronHook Auto Actor Property PlayerRef Auto ;when hook is added to player -- equip it Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem == IronHook PlayerRef.EquipItem(IronHook,true,true) EndIf EndEvent ;when hook is removed from player -- send it back. when hook is dropped, disable created instance and add new to the player Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) If akBaseItem == IronHook ;if placed in valid container If akDestContainer akDestContainer.RemoveItem(akBaseItem,aiItemCount,true,PlayerRef) ;otherwise it was dropped to the ground Else ;if a reference was created when dropped, disable and delete it before giving new to the player. If akItemReference Disable(akItemReference) akItemReference.Delete() PlayerRef.AddItem(akBaseItem,1,true) EndIf EndIf EndIf EndEvent If it works, this script would also make the script on the object obsolete and unnecessary. Link to comment Share on other sites More sharing options...
IronDusk33 Posted November 6, 2013 Author Share Posted November 6, 2013 Thanks for the info, but when I tried putting this onto an alias, it gave an error saying Disable isn't a command. I think simply putting an alias onto the Iron Hook, and checking the quest item box should work. One problem, I'm not entirely sure how to make a constant running dummy quest. What I did was made a new quest, made it a miscellaneous quest, made sure Start Game Enabled was checked, unchecked Run Once, and checked Allow Repeated Stages. I made one stage (stage 0). I made an alias to the Iron Hook, checked Quest Item, and did Ctrl Shift R to make it allow reserved. I also made an alias to the player, and tried (and failed) to put your script on it. After I did all this, I loaded the game, and could still drop the hook. Could you clear any of this up? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 6, 2013 Share Posted November 6, 2013 See the section called Set Up A Reference Aliashttp://www.creationkit.com/Dynamically_Attaching_Scripts#Set_Up_a_Reference_Alias You could do what you suggested by making the hook itself an alias and having it treated as a quest item. You'd still need to use the original on item script (or on the new reference alias) to force the equip and keep the player from unequipping. Link to comment Share on other sites More sharing options...
IronDusk33 Posted November 7, 2013 Author Share Posted November 7, 2013 WHOOOO! Got it to work! Thanks for the help! For anyone else who finds this post in hope of doing something similar; I created the dummy quest I mentioned above, and then the forced player reference linked above, then I made another reference "Create Reference to Object" checked "In" and selected my other alias . I also checked the "Quest Object" box in the alias, obviously. Now I can play a hook-handed character! (Don't ask why) Link to comment Share on other sites More sharing options...
dubird Posted January 16, 2014 Share Posted January 16, 2014 Ok, I have yet to get this to work. Made a dummy quest with player alias, as described above. Made an object reference to the item, linking it to playeralias. The item appears in inventory when I start, but is not equipped, nor is it unequipable. I'm not sure what I'm doing wrong. Did I miss a step somewhere? I don't know if this is connected, but it will not compile with Extends anything. Tried typing it in Notepad++, regular Notepad, it keeps saying it can't find that script. When I try to do the New Script from CK, it gives me an error that it can't find that script. I'm new to scripting, so I'm sure it's something minor, but yeah, kinda lost here. Script I'm using (attaching to player alias) ScriptName ForceRingAliasScript{Armor Property EnchRingBlock01 AutoActor Property PlayerRef Auto;when hook is added to player -- equip itEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem == EnchRingBlock01 PlayerRef.EquipItem(EnchRingBlock01,true,true) EndIfEndEvent;when hook is removed from player -- send it back. when hook is dropped, disable created instance and add new to the playerEvent OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) If akBaseItem == EnchRingBlock01 ;if placed in valid container If akDestContainer akDestContainer.RemoveItem(akBaseItem,aiItemCount,true,PlayerRef) ;otherwise it was dropped to the ground Else ;if a reference was created when dropped, disable and delete it before giving new to the player. If akItemReference Disable(akItemReference) akItemReference.Delete() PlayerRef.AddItem(akBaseItem,true,true) EndIf EndIf EndIfEndEvent} Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 18, 2014 Share Posted January 18, 2014 Two things. One the script if attached to the player alias on a quest needs to extend ReferenceAlias. You may need to manually type that in. Second your events and functions are all inside the comment brackets. { } remove those and the script should compile provided everything else is correct. Link to comment Share on other sites More sharing options...
Recommended Posts