Tiziano74 Posted September 19, 2021 Share Posted September 19, 2021 (edited) HiI would like to create a script that allows you to move a weapon, when placed in a container, on a specific weapon rack, following some restrictions.I give an example so you can understand better:If I put a weapon in a container and this weapon is within a specific Form List, or it has two specific Keywords, for example WeapMaterialSteel and WeapTypeSword (it's a Steel Sword), then it will be moved from the container to be displayed on the WeaponRack01.I know how to do this between containers, but I have no idea how to do it by interacting with the WeaponRackActivateSCRIPTCan anyone help me build a script that does this?Thanks in advance to those who will answer! Edited September 19, 2021 by Tiziano74 Link to comment Share on other sites More sharing options...
Tiziano74 Posted September 25, 2021 Author Share Posted September 25, 2021 Well... now i have my script working, with only one last problem to fix Scriptname QLH_Espositore_Armi_multiplo_scr_02 extends ObjectReference Actor Property PlayerRef AutoKeyword Property MaterialeArmi AutoKeyword Property MaterialeArmi2 AutoWeaponRackActivateSCRIPT WRAScriptObjectReference Property WRackArco Auto Keyword Property KeyArco Auto GlobalVariable Property GlobalArcoEsposto Auto Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)If (GlobalArcoEsposto.GetValue() == 0) If (akBaseItem.HasKeyword(MaterialeArmi) || akBaseItem.HasKeyword(MaterialeArmi2)) If akBaseItem.HasKeyword(KeyArco) RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer) Utility.Wait(0.5) PlayerRef.EquipItem(akBaseItem, true, true) WRackArco.Activate(Game.GetPlayer()) GlobalArcoEsposto.SetValue(1) Utility.Wait(0.1) EndIf EndIfElse Debug.MessageBox("C'è già un'arma esposta sulla placca per Archi")EndIfEndEvent The problem is that, until I manually close the container inventory window, the weapon is not equipped by the player and then displayed on the weapon rack.Is there a command to include in the script to close the container inventory window?I tried with Input.TapKey (48), which is supposed to simulate pressing the key, but absolutely nothing happens (it's a SKSE command that I have correctly implemented for scripts) Thanks Link to comment Share on other sites More sharing options...
ReDragon2013 Posted September 25, 2021 Share Posted September 25, 2021 Hmm.. did not really understand your issue. You wrote: "now I have my script working, The problem is that, until I manually close the container inventory window, the weapon is not equipped by the player and then displayed on the weapon rack." Try next code.. maybe helpfulQLH_Espositore_Armi_multiplo_scr_02 Scriptname QLH_Espositore_Armi_multiplo_scr_02 extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/10513658-script-from-a-container-to-a-weapon-rack-with-restrictions/ GlobalVariable PROPERTY GlobalArcoEsposto auto Keyword PROPERTY MaterialeArmi auto Keyword PROPERTY MaterialeArmi2 auto Keyword PROPERTY KeyArco auto ObjectReference PROPERTY WRackArco auto ; the Ref which should have attached script "WeaponRackActivateSCRIPT" ; -- EVENTs -- EVENT OnInit() Debug.Trace(" OnInit() - has been called for .. " +self) ENDEVENT EVENT OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) IF akBaseItem.HasKeyword(MaterialeArmi) ELSE RETURN ; - STOP - kw1 does not match ENDIF ;--------------------- IF akBaseItem.HasKeyword(MaterialeArmi2) ELSE RETURN ; - STOP - kw2 does not match ENDIF ;--------------------- IF akBaseItem.HasKeyword(KeyArco) ELSE RETURN ; - STOP - kw3 does not match ENDIF ;--------------------- every keyword was found for the added item/itemstack IF myF_IsOK( akSourceContainer ) ELSE RETURN ; - STOP - something goes wrong, see function below ENDIF ;--------------------- Debug.Notification("Please left this menu!") WHILE Utility.IsInMenuMode() Utility.Wait(0.1) ; wait as long the container menu is open ENDWHILE IF (self.GetItemCount(akBaseItem) == aiItemCount) ; make sure player does not have removed the items ; (1) remove item(s) from container back to source, if player added and globalVar has value Zero self.RemoveItem(akBaseItem, aiItemCount, TRUE, akSourceContainer) ; (2) equip the item to player myF_Equip(akBaseItem) ; (3) now simulate weaponrack activation by player WRackArco.Activate(akSourceContainer) ENDIF ENDEVENT ; -- FUNCTIONs -- 2 ;--------------------------------------------------- FUNCTION myF_IsOK(ObjectReference akSourceContainer) ;--------------------------------------------------- IF (akSourceContainer == Game.GetPlayer() as ObjectReference) ; https://www.creationkit.com/index.php?title=OnItemAdded_-_ObjectReference ELSE Return False ; safety net, item was not added by the player ENDIF ;--------- IF (GlobalArcoEsposto.GetValue() == 1.0) ; get the TriggerMarker which has attached "WeaponRackTriggerSCRIPT" objectReference oRef = WRackArco.GetLinkedRef( (WRackArco as WeaponRackActivateSCRIPT).WRackTrigger ) IF (oRef) && (oRef.GetTriggerObjectCount() == 0) ; weaponrack triggerMarker is valid and empty ELSE Debug.MessageBox("C'è già un'arma esposta sulla placca per Archi") Return False ; globalVar is already TRUE ENDIF ; ---------- ENDIF GlobalArcoEsposto.SetValue(1.0) ; set TRUE Return TRUE ENDFUNCTION ;---------------------------------- FUNCTION myF_Equip(Form akBaseItem) ;---------------------------------- actor player = Game.GetPlayer() player.EquipItem(akBaseItem, TRUE, TRUE) ; let player equip the item Utility.Wait(0.1) ; https://www.creationkit.com/index.php?title=IsEquipped_-_Actor int i = 10 WHILE (i) ; WHILE (i != 0) IF player.IsEquipped(akBaseItem) Debug.Notification("counter is " +i) i = 1 ELSE Utility.Wait(0.1) ENDIF i = i - 1 ENDWHILE ENDFUNCTION Link to comment Share on other sites More sharing options...
Tiziano74 Posted September 25, 2021 Author Share Posted September 25, 2021 (edited) Hmm.. did not really understand your issue. You wrote: "now I have my script working, The problem is that, until I manually close the container inventory window, the weapon is not equipped by the player and then displayed on the weapon rack." 1st af all thanks for the answerI understand that you don't understand what my problem is. . . probably because I didn't explain myself well enough, and sorry for my bad english but is not my lenguage.I'll give you an example of what I do, and I'll explain what happens, so maybe I'll explain better (I also have a short video but I don't know how to show it to you).I have 8 weapon racks on the wall and for each of these there is a different type of weapon to put on, a sword, a bow, etc. and all these 8 weapons must be of the same material.I have a container, I open the container inventory and insert a weapon.If the weapon I inserted is made of the material of the weapons that are to be displayed, the weapon returns to the player, is equipped (if it is not equipped it cannot go to the weapon rack) and then it is moved to the specific weapon rack for that type of weapon. The problem is that i open the container inventory to do that, and the script cant finish and display the weapon on the rack if i don't close manually the container inventory.So my question is, is there a command to script that closes the container inventory just after the weapon has been returned from the container to the player, before the player equips the weapon, so that I don't have to close the inventory of the container manually? I had thought of inserting something like Debug.Notification ("Please left this menu!") too, but I wish the process was utomatic. . . Edited September 25, 2021 by Tiziano74 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 26, 2021 Share Posted September 26, 2021 Unfortunately, the trick to closing menus ( DisablePlayerControls ) does not work with container menus. If tapping the key via script does not work, I have no ideas for an "automatic process". Link to comment Share on other sites More sharing options...
Tiziano74 Posted September 28, 2021 Author Share Posted September 28, 2021 Unfortunately, the trick to closing menus ( DisablePlayerControls ) does not work with container menus. If tapping the key via script does not work, I have no ideas for an "automatic process".Command found with help from a friend:UI.InvokeString("HUD Menu", "_global.skse.CloseMenu", "ContainerMenu") Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 29, 2021 Share Posted September 29, 2021 That is good to know. Link to comment Share on other sites More sharing options...
Recommended Posts