Welcome to AC Web.
Results 1 to 3 of 3
  1. #1

    LUA script help needed - getting player hair colour.


    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    So, I have a script on my server to change the display ID of troll druids in cat and bear form. It functions well for this purpose, though lacks one specific feature I desire.

    This script (originally created by Deathorous from Model-Changing.net for my needs) is currently what I am using. I need to modify it to check the player's hair colour to choose the correctly-coloured display ID.

    Code:
    local function Troll_OnSpellCast(event, player, spell, skipCheck)
    	local race = player:GetRace()
    	
    	if ( race == 8 ) then
    		player:RegisterEvent(trollDruidDisplayChange, 10, 1)
    	end
    end
    
    function trollDruidDisplayChange(event, delay, pCall, player)
    	local displayId = player:GetDisplayId()
    	
    	if ( displayId == 2289 ) then
    		player:SetDisplayId( 36002 )
    	elseif ( displayId == 8571 ) then
    		player:SetDisplayId( 36003 )
    	end
    end
    
    RegisterPlayerEvent(5, Troll_OnSpellCast)
    What can I use to check for the hairColor used for a character in the database? And how can I make it so that the function that changes the display ID checks for both the original display ID of the druid form (to check for cat or bear form), and the hair colour of the character?

  2. #2
    Just go in characters > characters > haircolor.
    Then just do so it check hair before and after u enter w/e form it switch back to old value

  3. #3

    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    Quote Originally Posted by Pyzayt View Post
    What can I use to check for the hairColor used for a character in the database? And how can I make it so that the function that changes the display ID checks for both the original display ID of the druid form (to check for cat or bear form), and the hair colour of the character?
    Try this.

    Code:
    local catcolors = {
    [0] = {29409}, --white
    [1] = {29410}, --tan
    [2] = {29411}, --brown
    [3] = {29412}, --black
    [4] = {8571}, --Dark Brown
    [5] = {29405}, -- purple
    [6] = {29407}, --blue
    [7] = {29406}, --violet
    }
    
    local bearcolors = {
    [0] = {29413}, --purple nightelf
    [1] = {29414}, --black nightelf
    [2] = {29415}, --grey nightelf
    [3] = {29416}, --white nightelf
    [4] = {29417 }, --Brown nightelf
    [5] = {29420}, -- tan tauren
    [6] = {29412}, --Black tauren
    [7] = {29419 }, --grey tauren
    }
    
    
    local function getPlayerCharacterGUID(player)
        query = CharDBQuery(string.format("SELECT guid FROM characters WHERE name='%s'", player:GetName()))
    
        if query then 
          local row = query:GetRow()
    
          return tonumber(row["guid"])
        end
    
        return nil
      end
    
    local function Troll_OnSpellCast(event, player, spell, skipCheck)
    	local race = player:GetRace()
    	
    	if ( race == 6 ) then
    		spell1 = tostring(spell)
    		player:RegisterEvent(trollDruidDisplayChange, 10, 1)
    	end
    	
    end
    
    function trollDruidDisplayChange(event, delay, pCall, player)
    local queryhaircolor = CharDBQuery(string.format("SELECT hairColor FROM characters WHERE guid=%i", getPlayerCharacterGUID(player)))
    local displayId = player:GetDisplayId()
    
    
    
    
    if queryhaircolor then   
    	local Hcolor = queryhaircolor:GetInt8( 0 )
    
    	
    	--player:ModifyPower( 10000, 0 ) --for testing
    
    	if player:GetAura( 768 )  then
    		if Hcolor ~= nil then
    		for _,v in ipairs(catcolors[tonumber(Hcolor)]) do
    		player:SetDisplayId( v )
    		end
    		end
    
    	elseif player:GetAura( 5487 ) or player:GetAura( 9634 ) then
    		if Hcolor ~= nil then
    		for _,v in ipairs(bearcolors[tonumber(Hcolor)]) do
    		player:SetDisplayId( v )
    		end
    		end
    	end
    	
    	end
    	
    	
    	
    end
    
    RegisterPlayerEvent(5, Troll_OnSpellCast)
    You might want to change the DisplayID's in the catcolors and bearcolors tables at the top to your liking.
    I used only the WOTLK DisplayID's from HERE because I'm using wotlk Trinitycore.


    Quote Originally Posted by Pyzayt View Post
    How can I make it so that the function that changes the display ID checks for both the original display ID of the druid form (to check for cat or bear form), and the hair color of the character?
    I'm confused by that question, not sure what you mean or want.

    The script I made for you should change the player form based on their hair color and it works anytime they cast bear or cat form instead of using a single DisplayID like your script does
    Last edited by skuly; 07-28-2021 at 10:50 PM.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •