You are here

destroying two held objects

1 post / 0 new
Ubai
destroying two held objects

Hello,

I had a script that would copy the item a player held in his hand, then destroy it. It worked perfectly, but when I try to add a check for an offhand object it

only destroys one of them. Here is my code:

 

[code]

void UnequipFirearm(object oWeapon)

{

SpeakString("I'm out of ammunition!");


object oPC = OBJECT_SELF;

//check for off hand firearm

//if you don't check this first the off hand weapon moves to the main hand

object oWeapon2 = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC);

if (GetTag(oWeapon2) == "firearm")

{ 

SendMessageToPC(GetFirstPC(FALSE), "tag of oWeapon2 is " + GetTag(oWeapon2));

CopyObject(oWeapon2, GetLocation(oPC), oPC);

DestroyObject(oWeapon2, 0.875f, TRUE);

}

CopyObject(oWeapon, GetLocation(oPC), oPC);

DestroyObject(oWeapon, 0.90f, TRUE);


}

[/code]

edit: I was able to fix this by explicitly finding the object within the function instead of passing it as a parameter, I forgot I had switched from checking the right hand slot to using the last weapon used.

 

 
  • up
    50%
  • down
    50%