Jump to content

[LE] Need script help with unequipping items


Recommended Posts

Weapon NPCRightWeapon = NPC.GetEquippedWeapon()
Weapon NPCLeftWeapon = NPC.GetEquippedWeapon(true)
If NPCRightWeapon ; we got a valid object
  NPC.UnequipItem(NPCRightWeapon)
EndIf
IF NPCLeftWeapon ; we got a valid object
  NPC.UnequipItem(NPCLeftWeapon)
EndIf

These may be useful reading:

GetEquippedWeapon

GetEquippedShield

GetEquippedSpell

 

 

Sorry if I'm being thick here, but I input the code you suggested and got the following errors when trying to compile:

Starting 1 compile threads for 1 files...
Compiling "uni_poolunequip"...
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\uni_poolunequip.psc(15,25): no viable alternative at input 'NPC'
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\uni_poolunequip.psc(15,28): required (...)+ loop did not match anything at input '.'
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\uni_poolunequip.psc(15,8): Unknown user flag NPC
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\uni_poolunequip.psc(16,24): no viable alternative at input 'NPC'
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\uni_poolunequip.psc(16,27): required (...)+ loop did not match anything at input '.'
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\uni_poolunequip.psc(16,8): Unknown user flag NPC
No output generated for uni_poolunequip, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on uni_poolunequip
What did I do wrong?
Link to comment
Share on other sites

You posted a script, that IsharaMeradin has changed partly.

 

Update: I am sorry for my message above. You're right IsharaMeradin. The code snippet (you posted) was made for adivse and studying.

Scriptname UNI_PoolUnequip extends ObjectReference
; https://forums.nexusmods.com/index.php?/topic/9352773-need-script-help-with-unequipping-items/


EVENT OnTriggerEnter(ObjectReference akActionRef)

    actor who = akActionRef as Actor        ; who = NPC
    weapon w

    w = who.GetEquippedWeapon(False)        ; w = NPCRightWeapon
    IF ( w )                                ; we got a valid object
        who.UnequipItem(w as Form)
    ENDIF

    w = who.GetEquippedWeapon(TRUE)         ; w = NPCLeftWeapon
    IF ( w )                                ; we got a valid object
        who.UnequipItem(w as Form)
    ENDIF

ENDEVENT

TJHammersmith wrote: "What did I do wrong?"

- You took script sources (posted here) from other mods and asked for help without any script experience by your own. Not really useful for helper.

Edited by ReDragon2013
Link to comment
Share on other sites

To be fair, I merely looked at the CK wiki documentation, came up with a plausible usage scenario and linked said pages. I did not take any existing mod or game code and modify slightly.

 

NPC, the variable that caused issues, was just a place holder for whatever actor or actors needed to be dealt with. Suggested code should never be inserted without first ensuring it is adapted to ones needs.

Link to comment
Share on other sites

@ReDragon2013 @IsharaMeradin I've got the script working how I want now, which is great news.

 

Thanks for your help on this. Although I've been playing Skyrim for years now, I'm very new to scripting and I'd hoped that by seeing someone else's "correct" code, I could start to grasp the basics of scripting. It appears however that this approach may not be feasible and I may have some heavy reading infront of me.

Link to comment
Share on other sites

Hi folks.

 

I've tried doing the pool undress / redress thing too. Once again I am flailing around with little to no experience, so feel free to have some shots at me for that. Here's what I'm trying to do:

 

I have parked two triggerboxes next to each other, with each running a single script.

 

Undress box script:

Event OnTriggerEnter(ObjectReference akActionRef)
if(akActionRef != Game.GetPlayer())
actor who = akActionRef as actor
who.unequipall()
endif
EndEvent

 

And the Redress box next to it:

Armor property DummyRing auto
Event OnTriggerEnter(ObjectReference akActionRef)
if(akActionRef != Game.GetPlayer())
actor who = akActionRef as actor
who.AddItem(DummyRing, abSilent = true)
who.EquipItem(DummyRing, abSilent = true)
who.UnEquipItem(DummyRing, abSilent = true)
who.RemoveItem(DummyRing, abSilent = true)
endif
EndEvent

 

Yes, those are the same scripts from earlier in this thread. As I said, flailing.

 

The first one works fine; go into it and I have nudie followers (but not nudie self...)

 

Go into the second one and ... nothing happens, followers stay nudie.

 

The scripts both compiled fine (of course; had I written them myself it would be a different story).

 

Any ideas what might be missing? The triggers do not overlap. If I give a follower an item they re-equip all their stuff as normal. That makes me think that the whole dummyring thing is not actually being added/removed. Would perhaps using a non-dummy item help?

 

TV

Link to comment
Share on other sites

Better have everything in one script and in one trigger box.

Armor property DummyRing auto
 
Event OnTriggerEnter(ObjectReference akActionRef)
       if (akActionRef != Game.GetPlayer())
           actor who = akActionRef as actor
           who.unequipall()
           who.AddItem(DummyRing, abSilent = true)
           who.EquipItem(DummyRing, abSilent = true)
           who.UnEquipItem(DummyRing, abSilent = true)   ; I don't know why this is used.
           who.RemoveItem(DummyRing, abSilent = true)   ; I don't know why this is used.
endif
EndEvent

who.UnEquipItem(DummyRing, abSilent = true)
who.RemoveItem(DummyRing, abSilent = true)
I don't know why those two lines are used, it makes the 'DummyRing' to be immediately unequipped, but in the other hand i haven't read the whole topic..., so it may have a use.
* Don't forget to fill in the 'Property'.
Have a happy modding and merry christmas.
Edited by maxarturo
Link to comment
Share on other sites

  • Recently Browsing   0 members

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