I need help with some function

i want create a “specific” script for “an item” that when i equip that i can transform to another form ( DisplayId) not all item i equip
And spent some time for research over again, i can not find function that catch event onquip /emoticons/default_sleep.png. But i have made this script :3

#include “ScriptPCH.h”

class lk_ilusion : public ItemScript
{
public:
lk_ilusion() : ItemScript(“lk_ilusion”) {}

bool OnUse(Player* player, Item* /*item*/, SpellCastTargets const& /*targets*/)
{
    player->SetDisplayId(21105);
    return false;

}

};

void AddSC_lk_ilusion()
{
new lk_ilusion();
}

Can you tell me where i can find function that catch unequip item event?

These are the current hooks that item scripts support: https://github.com/TrinityCore/TrinityCore/blob/6.x/src/server/game/Scripting/ScriptMgr.h#L371-L395

Unfortunately there’s no hook for equipping/unequipping (OnUse is called when the player uses the item, not equip), perhaps you can add it to ItemScript?

So sad to hear this. I’m using function “OnUse” but don’t know where i can catch event when player unequip it /emoticons/default_sad.png(

Somewhere in the Player class you have an Equip and Unequip methods and you can use those to trigger the hooks.

To be honest, i searched all methods in there, but i don’t see any of those can trigger the hook Unequip :-<

Maybe because i’m still in beginer for Trinity Structure :-<

He ment that you have to create the hooks by yourself. As a hint, he told you that you can find a equip and unequip function in the player class.

Thanks. I’m researching with method IsEquipmentPos() and IsEquipped().

Don’t know why what is problem in this function

#include "ScriptPCH.h"
#include "Player.h"
#include "Item.h"
#include "Spell.h"

class Unit;

class illidan : public ItemScript
{
public:
    illidan() : ItemScript("illidan") {}

    bool OnUse(Player* player, Item* /*item*/, SpellCastTargets const& /*targets*/)
    {
        player->SetDisplayId(21135);
        player->SetObjectScale(0.4);
        return false;

    }
    Unit* unitTarget;
    Player* item_owner = (Player*)unitTarget;
    Item* item = item_owner->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_BODY);
    Player* pPlayer;
    
    if(!item->IsEquipped())
    {
         pPlayer->DeMorph();
         pPlayer->GetDisplayId();
         pPlayer->SetObjectScale(1);
        return true;
    }



    /*if (Player* player->IsEquipPos(0, 3)){
        player->DeMorph();
        player->GetDisplayId();
        player->SetObjectScale(1);
        return true;
    }*/
};

void AddSC_illidan()
{
    new illidan();
}
 

You added code outside of a method inside a class declaration… that’s not valid, at all.

I recommend reading a C++ book/tutorial for starters, there are very good resources online.

I’m Done with this =.=

2 weeks research in code and compile all over again… fail /emoticons/default_sad.png(