Jump to content

Need help with a Script to remove weapons


Dufftacular

Recommended Posts

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...