Jump to content

Clone/copy weapon by script?


Recommended Posts


Scriptname DropDupesScript extends Quest

Event OnQuestInit()
AddInventoryEventFilter(akFilter = None)
RegisterForRemoteEvent(Game.GetPlayer(), "OnItemRemoved")
EndEvent

Event ObjectReference.OnItemRemoved(ObjectReference akSenderRef, Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
If !akDestContainer && akBaseItem As Weapon
ObjectReference Duplicate = akSenderRef.PlaceAtMe(akBaseItem)
;----- Needs F4se (GetAllMods) ----------------------------
If Duplicate
ObjectMod[] WeaponMods = akItemReference.GetAllMods()
If WeaponMods.Length > 0
Int i = 0
While i < WeaponMods.Length
Duplicate.AttachMod(WeaponMods[i])
i += 1
EndWhile
EndIf
EndIf
;----- Needs F4se End -------------------------------------
EndIf
EndEvent
Link to comment
Share on other sites

Well, I've tested it and it works fine, at least for the weapons I've tested, there could be two reasons, the weapons I've tested are persistent references or, since you are dropping them to the world, they are no more in the inventory, so I think they actually have a reference.

 

Test the code before discarding it.

Link to comment
Share on other sites

Nope I dont think it will work, objects in containers dont have objectreference if they arent persistent. So when dropping that weapon from inventory akItemReference parameter of the onitemremoved event will be none

I think this issue only arises when using removeItem. The code also isn't checking for equipped items, which would only make the intended outcome complicating, if not impossible.

Edited by Rasikko
Link to comment
Share on other sites

  • Recently Browsing   0 members

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