Jump to content

Script not removing the aura


Il_Picasso

Recommended Posts

Hello, I am trying to make this script remove the Aura of the player when he removes his shirt 

 

This is the code 

 

--[[
  * TITLE  : Morph Shirts
  * AUTHOR : hates_sundays
  * CONTACT: http://sundays.org.uk/
  * VERSION: 1.0
  * CREATED: 19/3/2016
  * UPDATED: 19/3/2016
  * DESC   : Applies an aura to your character depending on which shirt you equip.
--]]

local Auras = {
  37810, -- TaurenMale
  37811, -- TaurenFemale
  35466, -- HumanMale
  37805, -- HumanFemale
  37808, -- GnomeMale
  37809, -- GnomeFemale
  37807, -- BloodelfMale
  37806; -- BloodelfFemale
};

local Shirts = {
  6384,  -- Stylish Blue Shirt
  6385,  -- Stylish Green Shirt
  4330,  -- Stylish Red SHirt
  41251, -- Yellow Lumberjack Shirt
  2576,  -- White Linen Shirt
  10056, -- Orange Mageweave Shirt
  10054, -- Lavender Mageweave Shirt
  11840; -- Master Builder's Shirt
};

local function OnEquip(event, player, item, bag, slot)
  if slot == 3 then -- Shirt slot id
    for i, v in ipairs(Shirts) do
      if item:GetEntry() == v then
        player:AddAura(Auras[i], player);
        player:SendBroadcastMessage("You feel tingly all over.");
        break;
      else
        for i, v in ipairs(Auras) do
          if player:HasAura(v) then
            player:RemoveAura(v);
          end
        end
      end
    end
  end
end

RegisterPlayerEvent(29, OnEquip); -- PLAYER_EVENT_ON_EQUIP

 

Link to comment
Share on other sites

Ok I managed to fix this

This is the code, Line 41, 42 was changed, before it was



 

          if player:HasAura(Auras[i]) then
            player:RemoveAura(Auras[i]);

Now it is

 


 

          if player:HasAura(Auras[i]) then
            player:RemoveAura(Auras[i]);
--[[
  * TITLE  : Morph Shirts
  * AUTHOR : hates_sundays
  * CONTACT: http://sundays.org.uk/
  * VERSION: 1.0
  * CREATED: 19/3/2016
  * UPDATED: 19/3/2016
  * DESC   : Applies an aura to your character depending on which shirt you equip.
--]]

local Auras = {
  37810, -- TaurenMale
  37811, -- TaurenFemale
  35466, -- HumanMale
  37805, -- HumanFemale
  37808, -- GnomeMale
  37809, -- GnomeFemale
  37807, -- BloodelfMale
  37806; -- BloodelfFemale
};

local Shirts = {
  6384,  -- Stylish Blue Shirt
  6385,  -- Stylish Green Shirt
  4330,  -- Stylish Red SHirt
  41251, -- Yellow Lumberjack Shirt
  2576,  -- White Linen Shirt
  10056, -- Orange Mageweave Shirt
  10054, -- Lavender Mageweave Shirt
  11840; -- Master Builder's Shirt
};

local function OnEquip(event, player, item, bag, slot)
  if slot == 3 then -- Shirt slot id
    for i, v in ipairs(Shirts) do
      if item:GetEntry() == v then
        player:AddAura(Auras[i], player);
        player:SendBroadcastMessage("You feel tingly all over.");
        break;
      else
        for i, v in ipairs(Auras) do
          if player:HasAura(Auras[i]) then
            player:RemoveAura(Auras[i]);
          end
        end
      end
    end
  end
end

RegisterPlayerEvent(29, OnEquip); -- PLAYER_EVENT_ON_EQUIP

 

Link to comment
Share on other sites

You would be better off using the existing DB functionality for items to cast a spell on equip.
https://www.getmangos.eu/wiki/referenceinfo/dbinfo/mangosdb/mangoszeroworlddb/item_template-r1064/#spellid_1
Im not sure if or when we would implement unequip hook in Eluna.

If you do need something, do report it at https://github.com/ElunaLuaEngine/Eluna/issues

 

Link to comment
Share on other sites

6 hours ago, Rochet2 said:

You would be better off using the existing DB functionality for items to cast a spell on equip.
https://www.getmangos.eu/wiki/referenceinfo/dbinfo/mangosdb/mangoszeroworlddb/item_template-r1064/#spellid_1
Im not sure if or when we would implement unequip hook in Eluna.

If you do need something, do report it at https://github.com/ElunaLuaEngine/Eluna/issues

 

Ok, I will use the DB functionality, but for testing puropose

 

At the moment you wouldn't say I am able to remove the aura on item unequip?

Link to comment
Share on other sites

On 30.7.2017 at 6:30 PM, Il_Picasso said:

At the moment you wouldn't say I am able to remove the aura on item unequip?

There is no hook for it so its not possible.

You can try make different workarounds though, like check every second what item is equipped, but  using the DB solution is better in many ways as it is more efficient, a part of the item itself, needs no code etc.
Unless you need it for something else than this script presented here of course.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use