brown8220 Posted April 3, 2012 Share Posted April 3, 2012 (edited) Ok, so I made a script to put on Items, which On Equip checks whether the player is the required level. If he/she is not then the script unequips the item. Here follows the code (note: for testing I set the level requirement to 10 or above): ScriptName ItemRestriction extends ObjectReference int requiredLvl = 10 Event OnEquipped(Actor akActor) if (akActor == Game.GetPlayer()) if (Game.GetPlayer().GetLevel() < requiredLvl) Game.GetPlayer().UnequipItem(Game.GetForm(0x02000d63), true, true) Debug.MessageBox("You are only level "+Game.GetPlayer().GetLevel()+". You must be level "+requiredLvl+" to equip this item.") endif endIf EndEvent The script works as intended, but with a few quirks. Firstly, and most importantly, I would like to just reference the base object to which the script is attached, so it will work on any object I wish it attached to, without changing the code every time. At the moment it is hard coded via Game.GetForm(0x02000d63), which means the script will only work on this particular object. I've tried using the keyword 'self' to reference the base object but it just returns: None. Secondly, I would like to add a string to the item description via the script. Something like item.addDescription("Requires level 10"). Is this possible, without actually adding it to the description in the CK? Thirdly, although the scripts work, the inventory screen does not update. The arrow indicating it is equipped persists, even though the item is not equipped. To remedy this you can just exit/enter the menu and it will show up properly. So is there anyway to just refresh the UI or simply Open/Close the inventory screen in the script? Thanks,Soulvomit Edited April 3, 2012 by brown8220 Link to comment Share on other sites More sharing options...
fg109 Posted April 3, 2012 Share Posted April 3, 2012 1. Try:Self.GetBaseObject() 2. No. 3. DisablePlayerControls(false, false, false, false, false, true) EnablePlayerControls(false, false, false, false, false, true) Link to comment Share on other sites More sharing options...
Recommended Posts