Text Color Codes - GetColorPlayerName

Discussion in 'JASS Zone' started by jonadrian619, Dec 19, 2006.

  1. jonadrian619

    jonadrian619 -___-

    +238 / 0 / -0
    Text Color Codes - GetColorPlayerName
    by jonadrian619
    This tutorial is about the functions and sub functions of the GetColorPlayerName custom script code. GetColorPlayerName is a code where it sets the string color codes of players. When you want certain strings or text to become colored depending on the player that executes the trigger, then the color of the player will be the color of the specific string.

    I dont know a suitable title for this tutorial.. someone could help

    If you do not know this tutorial, download the map WarDraft. It uses a JASS code like this.
    NOTE: You need three variables in order for the triggers to fire correctly.

    Variables Required
    - A string variable that can show the name of a particular player. I name it KillingPlayerName
    - Another string variable which shows the text. I name it KillingPlayerString
    - A player variable which sets the killing player as it's value. I name it KillingPlayer
    Getting Started:
    Use this custom script in the maps custom script, not in the trigger.

    NOTE: You need this custom script. Without it, the player colors won't show.
    JASS Script:
    function GetPlayerColorFlag takes playercolor color returns string
    	if color == PLAYER_COLOR_RED then
    		return "|cffff0303"
    	elseif color == PLAYER_COLOR_BLUE then
    		return "|cff0042ff"
    	elseif color == PLAYER_COLOR_CYAN then
    		return "|cff1ce6b9"
    	elseif color == PLAYER_COLOR_PURPLE then
    		return "|cff540081"
    	elseif color == PLAYER_COLOR_YELLOW then
    		return "|cfffffc01"
    	elseif color == PLAYER_COLOR_ORANGE then
    		return "|cfffe8a0e"
    	elseif color == PLAYER_COLOR_GREEN then
    		return "|cff20c000"
    	elseif color == PLAYER_COLOR_PINK then
    		return "|cffe55bb0"
    	elseif color == PLAYER_COLOR_LIGHT_GRAY then
    		return "|cff959697"
    	elseif color == PLAYER_COLOR_LIGHT_BLUE then
    		return "|cff7ebff1"
    	elseif color == PLAYER_COLOR_AQUA then
    		return "|cff106246"
    	elseif color == PLAYER_COLOR_BROWN then
    		return "|cff4e2a04"
    	return "|cffffffff"
    function GetColorEnd takes nothing returns string
    	return "|r"
    function GetColorPlayerName takes player p returns string
    	return GetPlayerColorFlag(GetPlayerColor(p)) + GetPlayerName(p) + GetColorEnd()
    GUI Triggers:
    OPTIONAL: You can make different triggers like when a hero enters a region or when a hero dies for as long as the custom scripts and the variables are set.

    Tally Kills GUI
            A unit Dies
            (Killing Unit is a Hero) Equal To True
            (Dying Unit is a Hero) Equal To True
            Set KillingPlayer = (Owner of (Killing Unit))
            Custom script:   set udg_KillingPlayerName = GetColorPlayerName( udg_KillingPlayer )
            Set KillingPlayerString = ((KillingPlayerName +  has killed a hero. He gains |cffffcc005|r points.))
            Game - Display to (All players) the text: KillingPlayerString
    For example, when Player 3 kills a hero, the text displays as: Player 3 has killed a hero. He gains 5 points.

    The Player 3, as the player name, shows up color teal with the color code |cff1ce6b9 then ends in |r. If a different player kills a hero, the player name is colored the player color of the owner of the killing unit. That is how the GetColorPlayerName script works.
    Demo map will be supplied soon...

    Sorry i didnt convert the trigger into JASS code because i had no time. Just try it. You'll see the results when you apply the script..

    by jonadrian619
  2. SFilip

    SFilip Gone but not forgotten

    +634 / 0 / -0
    This belongs to the Free Trigger Code.

Share This Page