Dufftacular Posted November 25, 2021 Share Posted November 25, 2021 Hello! I need help with making a OnTriggerEnter script that will remove the players Weapons into a linked reference container. Or alternatively, a script where the player can not use any weapons while being in said trigger box. I'm not very good at making scripts myself so any and all help is appreciated! Link to comment Share on other sites More sharing options...
LarannKiar Posted November 25, 2021 Share Posted November 25, 2021 Attach this script to your triggerbox object reference. Scriptname YOURSCRIPTNAME extends ObjectReference Const Keyword Property ObjectTypeWeapon Auto Const {Every weapon should have this keyword.} ObjectReference Property myWeaponContainer Auto Const {Your weapon container.} Event OnTriggerEnter(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() RemoveWeapons() EndIf EndEvent Event OnTriggerLeave(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() AddWeapons() EndIf EndEvent Function RemoveWeapons() Actor PlayerRef = Game.GetPlayer() Int iWaponCount = PlayerRef.GetItemCount(ObjectTypeWeapon) If iWaponCount > 0 PlayerRef.RemoveItem(ObjectTypeWeapon, iWaponCount, abSilent = true, akOtherContainer = myWeaponContainer) EndIf EndFunction Function AddWeapons() Actor PlayerRef = Game.GetPlayer() Int iWaponCount = myWeaponContainer.GetItemCount(ObjectTypeWeapon) If iWaponCount > 0 myWeaponContainer.RemoveItem(ObjectTypeWeapon, iWaponCount, abSilent = true, akOtherContainer = PlayerRef) EndIf EndFunction Link to comment Share on other sites More sharing options...
Zorkaz Posted November 25, 2021 Share Posted November 25, 2021 Also make sure the target container is persistent or it will unload along with the items. The keyword "MustPersist" does help Link to comment Share on other sites More sharing options...
Dufftacular Posted November 25, 2021 Author Share Posted November 25, 2021 Thanks!!! Link to comment Share on other sites More sharing options...
Recommended Posts