• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Dialog colors?

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
I've been having some difficulty with my dialog color(s) via GUI. I've decided to go about it a different way. I have this code:
Code:
function SetPlayerPrefix takes unit hero returns nothing
    local string txt
    local player player_owner = GetOwningPlayer(hero)
    local integer player_owner_id = GetPlayerId(player_owner)
    set txt = udg_PlayerName[player_owner_id] + " (" + GetUnitName(hero) + ")"
    call SetPlayerName(player_owner, txt)
    set txt = null
    set player_owner = null
endfunction

function StorePlayerNames takes nothing returns nothing
    local integer index = 0
    local player player_check
    loop
        exitwhen (index > 11)
        set player_check = Player(index)
        set udg_PlayerName[index] = GetPlayerName(player_check)
        set player_check = null
        set index = index + 1
    endloop
endfunction

Now what i was wondering is, is it possible to get dialog colors incorporated with this code? And if so , could you tell me how to call the function via
  • call custom script: ???
If not. Could anyone tell me how to set this in JASS, And then call forth the function in gui in times of need?
EDIT : This code is for setting hero pretext for selected player hero's.
 
Level 9
Joined
Jun 7, 2008
Messages
440
Yes. Player colors. For instance:
Code:
function Trig_Forbidden_Zone_Actions takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), ( GetPlayerName(GetTriggerPlayer()) + " has entered the forbidden!" ) )
endfunction


function InitTrig_Forbidden_Zone takes nothing returns nothing
    set gg_trg_Forbidden_Zone = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Forbidden_Zone, null )
    call TriggerAddAction( gg_trg_Forbidden_Zone, function Trig_Forbidden_Zone_Actions )
endfunction

But instead of display to all players, i want the name of the player, as well as his.her corresponding player color displyed as well. Since i already have the custom Jass Script from the pretext. I was wondering if there is anyway to incorporate diaglogue colors.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
|cffRRGGBB text |r is the format for colors in wc3.
Each of the capitalized letters is an hexadecimel value which means that it ranges between 0 and F (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F).
RR is red, GG is green, and BB is blue.

If for example you want a white "Hello" message, you'll set a string/whatever to "|cffffffffHello|r".
 
Level 9
Joined
Jun 7, 2008
Messages
440
Yes I'm aware of that. But for these you have to set player colors as a variable. I already have the players stored through JASS (refer to top). I was wondering if there is a way to incorporate those JASS triggers so that i could also include preset player colors. Its hard to input a color if every player is able to enter a certain area. I need their respective colors displayed when they trigger this event.
 
Level 7
Joined
Jul 20, 2008
Messages
377
Yes, something like that. But remember arrays start from 0, so if you want to be really efficient, do player number - 1. :p
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
How would i call forth the trigger array?
  • Player - player number of (triggering player)
Something like that?

Declare a string array called, let's say, player_colors.

Then set each index to the corresponding color, for example

JASS:
player_colors[0] = "|cffff0000" // red player
player_colors[1] = "|cff0000ff" // blue player
// etc

And then just use the slot you want, for example
  • someTextFunction: player_colors[number of (Triggering Player)] + "Hello|r"
And I recon that if your whole text should be colored you don't even need to end the color with |r.
 
Level 6
Joined
Sep 5, 2007
Messages
264
JASS:
function PlayerColouredText takes player p, string txt returns string
    local playercolor pc = GetPlayerColor(p)
    if pc == PLAYER_COLOR_RED then
        set txt = "|cffFF0202"+txt+"|r"
    elseif pc == PLAYER_COLOR_BLUE then
        set txt = "|cff0041FF"+txt+"|r"
    elseif pc == PLAYER_COLOR_CYAN then
        set txt = "|Cff1BE5B8"+txt+"|r"
    elseif pc == PLAYER_COLOR_PURPLE then
        set txt = "|CFF530080"+txt+"|r"
    elseif pc == PLAYER_COLOR_YELLOW then
        set txt = "|CFFFFFC00"+txt+"|r"
    elseif pc == PLAYER_COLOR_ORANGE then
        set txt = "|CFFFE890D"+txt+"|r"
    elseif pc == PLAYER_COLOR_GREEN then
        set txt = "|CFF1FBF00"+txt+"|r"
    elseif pc == PLAYER_COLOR_PINK then
        set txt = "|CFFE45AAF"+txt+"|r"
    elseif pc == PLAYER_COLOR_LIGHT_GRAY then
        set txt = "|CFF949596"+txt+"|r"
    elseif pc == PLAYER_COLOR_LIGHT_BLUE then
        set txt = "|CFF7DBEF1"+txt+"|r"
    elseif pc == PLAYER_COLOR_AQUA then
        set txt = "|CFF0F6145"+txt+"|r"
    elseif pc == PLAYER_COLOR_BROWN then
        set txt = "|CFF4D2903"+txt+"|r"
    else  // A safty function
        set txt = "|CFFFFFFFF"+txt+"|r"
    endif
    set pc = null
    return txt
endfunction
Got it from here, and altered it a little... Credits to PurgeAndFire.

Add that code above the other two functions.
Then change this function:
JASS:
function SetPlayerPrefix takes unit hero returns nothing
    local string txt
    local player player_owner = GetOwningPlayer(hero)
    local integer player_owner_id = GetPlayerId(player_owner)
    set txt = udg_PlayerName[player_owner_id] + " (" + GetUnitName(hero) + ")"
    set txt = PlayerColouredText(player_owner, txt)
    call SetPlayerName(player_owner, txt)
    set txt = null
    set player_owner = null
endfunction

Just a side note.... Please use <JASS> tags instead of <CODE> tags when posting, it's far easier to read. :thumbs_up:
 
Status
Not open for further replies.
Top