Jump to content

Home

Equip item to player


darthbdaman

Recommended Posts

I am trying to add and equip clothing to the player at the beginning of the game. The adding item part of the script works, as does the execution of the original area script, and the clothes are added to the inventory fine. However the item will not equip. No matter what I try. Increasing the delay, firing the script in different spots. I cannot get items to equip to the PC. Does anyone know a solution?

 

void main()
{
   object oEnter = GetEnteringObject();

   if ((oEnter == GetFirstPC()) && !GetLocalBoolean(OBJECT_SELF, 2))
   {
       object oItem = CreateItemOnObject("g_a_clothes01", oEnter);
       DelayCommand(0.5, AssignCommand(oEnter, ActionEquipItem(oItem, INVENTORY_SLOT_BODY, TRUE)));

       SetLocalBoolean(OBJECT_SELF, 2, TRUE);
   }

   ExecuteScript("k_pend_area01_1", OBJECT_SELF);
}

Link to comment
Share on other sites

I am trying to add and equip clothing to the player at the beginning of the game. The adding item part of the script works, as does the execution of the original area script, and the clothes are added to the inventory fine. However the item will not equip. No matter what I try. Increasing the delay, firing the script in different spots. I cannot get items to equip to the PC. Does anyone know a solution?

 

void main()
{
   object oEnter = GetEnteringObject();

   if ((oEnter == GetFirstPC()) && !GetLocalBoolean(OBJECT_SELF, 2))
   {
       object oItem = CreateItemOnObject("g_a_clothes01", oEnter);
       DelayCommand(0.5, AssignCommand(oEnter, ActionEquipItem(oItem, INVENTORY_SLOT_BODY, TRUE)));

       SetLocalBoolean(OBJECT_SELF, 2, TRUE);
   }

   ExecuteScript("k_pend_area01_1", OBJECT_SELF);
}

 

Try adding SetCommandable(1, oEnter); before the equip piece.

Link to comment
Share on other sites

Try adding SetCommandable(1, oEnter); before the equip piece.

 

Didn't fix it :(

 

void main()
{
object oPC = GetFirstPC();
object oItem = CreateItemOnObject("g_a_clothes01", oPC);
SetCommandable(1, oPC);
DelayCommand(0.5, AssignCommand(oPC, ActionEquipItem(oItem, INVENTORY_SLOT_BODY, TRUE)));
}

Link to comment
Share on other sites

Try spawning the item directly on the PC. For example here's how the PC gets Pazaak cards in TSLRCM 1.8.3;

 

DelayCommand(0.2, AssignCommand(oPC, ActionEquipItem(CreateItemOnObject("w_pazaak_01", oPC, 1, 1), 4, 1)));

Do note that that completely deletes the item previously in that slot, while that might not be a problem for this mod specifacally, for most you want to spawn the actual used item in the inventory before overriding it like this...

Link to comment
Share on other sites

Try spawning the item directly on the PC. For example here's how the PC gets Pazaak cards in TSLRCM 1.8.3;

 

DelayCommand(0.2, AssignCommand(oPC, ActionEquipItem(CreateItemOnObject("w_pazaak_01", oPC, 1, 1), 4, 1)));

Do note that that completely deletes the item previously in that slot, while that might not be a problem for this mod specifacally, for most you want to spawn the actual used item in the inventory before overriding it like this...

 

It worked!!! :D:D:D:D:D

 

Thanks :)

Link to comment
Share on other sites

You're welcome, glad it worked.

 

Drived me crazy figuring out why the PC wouldn't equip the Pazaak cards (but still loose his or her current hand) till finally I noticed Atton and the PC were using the very same pazaakdeck, even if I spawned different ones for them both. Inserting them like that fixed that issue (even though I had to remove unequipping with duping items in hands before they got simply deleted).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...