• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[REQUEST] Change A Gossip Menu Object To . Creature Gossip Menu

Status
Not open for further replies.

m8fun

Member
hi guys . who can set a eluna script in a npc for me ? thanks all


Code:
    --[[ ELUNA LUA APPEARANCE CHANGER
     CREDITS: Asandru@ wwW.FraGGs.Org
    ]]--
     
    local MenuId = 9998
    local PLAYER_BYTES = 239
    local PLAYER_BYTES_2 = 240
    local SMSG_FORCE_DISPLAY_UPDATE = 1026
     
    MaxHairColors = {
        [0]   = { 0 },              -- invalid race
        [1]   = { 9 },              -- RACE_HUMAN = 1,
        [2]   = { 7 },              -- RACE_ORC = 2,
        [3]   = { 9 },              -- RACE_DWARF = 3,
        [4]   = { 7 },              -- RACE_NIGHTELF = 4,
        [5]   = { 9 },              -- RACE_UNDEAD_PLAYER = 5,
        [6]   = { 2 },              -- RACE_TAUREN = 6,
        [7]   = { 8 },              -- RACE_GNOME = 7,
        [8]   = { 9 },              -- RACE_TROLL = 8,
        [10] = { 9 },              -- RACE_BLOODELF = 10,
        [11] = { 6 },              -- RACE_DRAENEI = 11
    }
     
    MaxHairStyles = {
        [0]   = { 0, 0 },          -- invalid race
        [1]   = { 11, 18 },      -- RACE_HUMAN = 1,
        [2]   = { 6, 6 },          -- RACE_ORC = 2,
        [3]   = { 10, 13 },      -- RACE_DWARF = 3,
        [4]   = { 6, 6 },          -- RACE_NIGHTELF = 4,
        [5]   = { 10, 9 },        -- RACE_UNDEAD_PLAYER = 5,
        [6]   = { 7, 6 },          -- RACE_TAUREN = 6,
        [7]   = { 6, 6 },          -- RACE_GNOME = 7,
        [8]   = { 5, 4 },          -- RACE_TROLL = 8,
        [10] = { 9, 13 },        -- RACE_BLOODELF = 10,
        [11] = { 7, 10 },        -- RACE_DRAENEI = 11
    }
     
    MaxFacialFeatures = {
        [0]   = { 0, 0 },          -- invalid race
        [1]   = { 8, 6 },          -- RACE_HUMAN = 1,
        [2]   = { 10, 6 },        -- RACE_ORC = 2,
        [3]   = { 10, 5 },        -- RACE_DWARF = 3,
        [4]   = { 5, 9 },          -- RACE_NIGHTELF = 4,
        [5]   = { 16, 7 },        -- RACE_UNDEAD_PLAYER = 5,
        [6]   = { 6, 4 },          -- RACE_TAUREN = 6,
        [7]   = { 7, 6 },          -- RACE_GNOME = 7,
        [8]   = { 10, 5 },        -- RACE_TROLL = 8,
        [10] = { 10, 9 },        -- RACE_BLOODELF = 10,
        [11] = { 7, 6 },          -- RACE_DRAENEI = 11
    }
     
    function Player:AppearanceUpdate()
        local data = CreatePacket(SMSG_FORCE_DISPLAY_UPDATE, 8)
        data:WriteGUID(self:GetGUIDLow())
        self:SendPacket(data)
        self:CastSpell(self, 24222)
    end
     
    function Player:ChangeHairColor(_next)
        local maxHairColor = table.unpack(MaxHairColors[self:GetRace()])
     
        local currentBytes = (self:GetByteValue(PLAYER_BYTES, 3)+1)
        if (_next == false) then
            currentBytes = (self:GetByteValue(PLAYER_BYTES, 3)-1)
        end
     
        if (currentBytes > maxHairColor) then
            currentBytes = 0
        elseif (currentBytes < 0) then
            currentBytes = maxHairColor
        end
     
        self:SetByteValue(PLAYER_BYTES, 3, currentBytes)
     
        self:AppearanceUpdate()
    end
     
    function Player:ChangeHairStyle(_next)
        local _male, _female = table.unpack(MaxHairStyles[self:GetRace()])
        local maxHairStyle = _male
     
        if (self:GetGender() ~= 0) then
            maxHairStyle = _female
        end
     
        local currentBytes = (self:GetByteValue(PLAYER_BYTES, 2)+1)
        if (_next == false) then
            currentBytes = (self:GetByteValue(PLAYER_BYTES, 2)-1)
        end
     
        if (currentBytes > maxHairStyle) then
            currentBytes = 0
        elseif (currentBytes < 0) then
            currentBytes = maxHairStyle
        end
     
        self:SetByteValue(PLAYER_BYTES, 2, currentBytes)
     
        self:AppearanceUpdate()
    end
     
    function Player:ChangeFacialFeature(_next)
        local _male, _female = table.unpack(MaxFacialFeatures[self:GetRace()])
        local maxFacialFeature = _male
     
        if (self:GetGender() ~= 0) then
            maxFacialFeature = _female
        end
     
        local currentBytes = (self:GetByteValue(PLAYER_BYTES_2, 0)+1)
        if (_next == false) then
            currentBytes = (self:GetByteValue(PLAYER_BYTES_2, 0)-1)
        end
     
        if (currentBytes > maxFacialFeature) then
            currentBytes = 0
        elseif (currentBytes < 0) then
            currentBytes = maxFacialFeature
        end
     
        self:SetByteValue(PLAYER_BYTES_2, 0, currentBytes)
     
        self:AppearanceUpdate()
    end
     
    local function OnGossipHello(event, player, object)
        player:GossipClearMenu()
        player:GossipSetText(string.format("Barber Services"))
        player:GossipMenuAddItem(2, "Change Hair Color", 1, 1)
        player:GossipMenuAddItem(2, "Change Hair Style", 1, 2)
        player:GossipMenuAddItem(2, "Change Facial Feature", 1, 3)
        player:GossipSendMenu(0x7FFFFFFF, player, MenuId)
    end
     
    local function OnGossipSelect(event, player, object, sender, intid, code, menuid)
        if (intid == 1) then -- change hair color
            player:GossipClearMenu()
            player:GossipMenuAddItem(7, "[Return]", 1, 0)
            player:GossipMenuAddItem(2, " (Prev) Hair Color", 1, 100) -- Previous Color
            player:GossipMenuAddItem(2, " (Next) Hair Color", 1, 200) -- Next Color
            player:GossipSetText(string.format("Change Hair Color"))
            player:GossipSendMenu(0x7FFFFFFF, player, MenuId)
        elseif (intid == 2) then -- change hair style
            player:GossipClearMenu()
            player:GossipMenuAddItem(7, "[Return]", 1, 0)
            player:GossipMenuAddItem(2, " (Prev) Hair Style", 1, 300) -- Previous Style
            player:GossipMenuAddItem(2, " (Next) Hair Style", 1, 400) -- Next Style
            player:GossipSetText(string.format("Change Hair Style"))
            player:GossipSendMenu(0x7FFFFFFF, player, MenuId)
        elseif (intid == 3) then -- change facial feature
            player:GossipClearMenu()
            player:GossipMenuAddItem(7, "[Return]", 1, 0)
            player:GossipMenuAddItem(2, " (Prev) Facial Feature", 1, 500) -- Previous Feature
            player:GossipMenuAddItem(2, " (Next) Facial Feature", 1, 600) -- Next Feature
            player:GossipSetText(string.format("Change Facial Feature"))
            player:GossipSendMenu(0x7FFFFFFF, player, MenuId)
     
        elseif (intid == 100) then -- hair color [prev]
            player:ChangeHairColor(false)
            player:GossipClearMenu()
            player:GossipMenuAddItem(1, "", 0, 1)
            player:GossipSendMenu(0x7FFFFFFF, player, MenuId)
     
        elseif (intid == 200) then -- hair color [next]
            player:ChangeHairColor(true)
            player:GossipClearMenu()
            player:GossipMenuAddItem(1, "", 0, 1)
            player:GossipSendMenu(0x7FFFFFFF, player, MenuId)
     
        elseif (intid == 300) then -- hair style [prev]
            player:ChangeHairStyle(true)
            player:GossipClearMenu()
            player:GossipMenuAddItem(1, "", 0, 2)
            player:GossipSendMenu(0x7FFFFFFF, player, MenuId)
     
        elseif (intid == 400) then -- hair style [next]
            player:ChangeHairStyle(true)
            player:GossipClearMenu()
            player:GossipMenuAddItem(1, "", 0, 2)
            player:GossipSendMenu(0x7FFFFFFF, player, MenuId)
           
            elseif (intid == 500) then -- facial feature [prev]
            player:ChangeFacialFeature(true)
            player:GossipClearMenu()
            player:GossipMenuAddItem(1, "", 0, 3)
            player:GossipSendMenu(0x7FFFFFFF, player, MenuId)
           
            elseif (intid == 600) then -- facial feature [next]
            player:ChangeFacialFeature(true)
            player:GossipClearMenu()
            player:GossipMenuAddItem(1, "", 0, 3)
            player:GossipSendMenu(0x7FFFFFFF, player, MenuId)
           
        elseif (intid == 0) then -- Return to main menu
            OnGossipHello(event, player, player)
        else -- Close Gossip Menu
            player:GossipComplete()
        end
    end
     
    local function OnChatCommand(event, player, msg, Type, lang)
        if (msg == "#barber") then
            OnGossipHello(event, player, player)
            return false
        end
    end
     
    RegisterPlayerEvent(18, OnChatCommand)
    RegisterPlayerGossipEvent(MenuId, 2, OnGossipSelect)


Here is Code > Thanks
 

Vitrex

Moderator
Closed due to following rule Section: 1D, Rule#19
Do not post requests. We don't have a mass member request section for a reason. People don't do the requests, the requester is too lazy to do it themselves or the requester asks for too much. Exception is only made for the Graphics -> Request section.

Use search for you script if it's already shared on the forum, if not, simply open support thread and ask for guidelines instead of asking for ready to use script.
Best regards, Vitrex.
 
Status
Not open for further replies.
Top