| 04-26-2007, 07:30 AM | #1 |
This is a script I'm trying to use to let the game detect the color of the player name and display it in the "player has left the game" message. I get a valid argument error. JASS:function Trig_Player_Leaves_Actions takes nothing returns nothing call DisplayTextToForce([GetPlayerId(GetTriggerPlayer())]+GetPlayerName(GetTriggerPlayer())+"|r"+"|c00ff0303 has left the game.|r") endfunction //=========================================================================== function InitTrig_Player_Leaves takes nothing returns nothing set gg_trg_Player_Leaves = CreateTrigger( ) call TriggerRegisterPlayerEventLeave( gg_trg_Player_Leaves, Player(0) ) call TriggerRegisterPlayerEventLeave( gg_trg_Player_Leaves, Player(1) ) call TriggerRegisterPlayerEventLeave( gg_trg_Player_Leaves, Player(10) ) call TriggerRegisterPlayerEventLeave( gg_trg_Player_Leaves, Player(5) ) call TriggerRegisterPlayerEventLeave( gg_trg_Player_Leaves, Player(6) ) call TriggerRegisterPlayerEventLeave( gg_trg_Player_Leaves, Player(9) ) call TriggerAddAction( gg_trg_Player_Leaves, function Trig_Player_Leaves_Actions ) endfunction |
| 04-26-2007, 07:51 AM | #2 |
You don't give enough arguments to pass that call, 1. You don't use any force to which the text should be displayed 2. You use GetPlayerId(GetTriggerPlayer()), which returns an integer and can't be used without an I2S in a display and also not as argument to whom the text should be displayed, because it's ont a force. Here's what you propably want: JASS:call DisplayTextToForce(GetPlayersAll(),GetPlayerName(GetTriggerPlayer())+"|r"+"|c00ff0303 has left the game.|r") JASS:GetPlayersAllies(GetTriggerPlayer()) |
| 04-26-2007, 01:36 PM | #3 |
The works but it only colorizes the "has left the game" part of the text. Is there no way to assign each player a text color so it appears like: Fireeye has left the game |
| 04-26-2007, 03:54 PM | #4 |
add this to your custom script JASS:function GetPlayerColorCode takes player whichPlayer returns string if ( whichPlayer == Player(0) ) then return "|c00FF0000" endif if ( whichPlayer == Player(1) ) then return "|c000000FF" endif if ( whichPlayer == Player(2) ) then return "|c0040E0D0" endif if ( whichPlayer == Player(3) ) then return "|c00A020F0" endif if ( whichPlayer == Player(4) ) then return "|c00FFFF00" endif if ( whichPlayer == Player(5) ) then return "|c00FFA500" endif if ( whichPlayer == Player(6) ) then return "|c0000FF00" endif if ( whichPlayer == Player(7) ) then return "|c00FFC0CB" endif if ( whichPlayer == Player(8) ) then return "|c00BEBEBE" endif if ( whichPlayer == Player(9) ) then return "|c00ADD8E6" endif if ( whichPlayer == Player(10) ) then return "|c00006400" endif if ( whichPlayer == Player(11) ) then return "|c00A52A2A" endif return null endfunction JASS:call DisplayTextToForce(GetPlayersAll(),GetPlayerName(GetTriggerPlayer())+"|r"+"|c00ff0303 has left the game.|r") JASS:call DisplayTextToForce(GetPlayersAll,GetPlayerColorCode(GetTriggerPlayer())+GetPlayerName(GetTriggerPlayer())+"|r"+"|c00ff0303 has left the game.|r") |
| 04-26-2007, 07:35 PM | #5 |
would also be possible with a global arrays, would look like this. What you need: a global string array called PlayerColor JASS:globals string array udg_PlayerColor endglobals function MapInit takes nothing returns nothing set udg_PlayerColor[0] = "|c00FF0000" set udg_PlayerColor[1] = "|c000000FF" set udg_PlayerColor[2] = "|c0040E0D0" set udg_PlayerColor[3] = "|c00A020F0" set udg_PlayerColor[4] = "|c00FFFF00" set udg_PlayerColor[5] = "|c00FFA500" set udg_PlayerColor[6] = "|c0000FF00" set udg_PlayerColor[7] = "|c00FFC0CB" set udg_PlayerColor[8] = "|c00BEBEBE" set udg_PlayerColor[9] = "|c00ADD8E6" set udg_PlayerColor[10] = "|c00006400" set udg_PlayerColor[11] = "|c00A52A2A" endfunction JASS:call DisplayTextToForce(GetPlayersAll(),GetPlayerName(GetTriggerPlayer())+"|r"+"|c00ff0303 has left the game.|r") JASS:call DisplayTextToForce(GetPlayersAll(),udg_PlayerColor[GetPlayerId(GetTriggerPlayer())]+GetPlayerName(GetTriggerPlayer())+"|r"+"|c00ff0303 has left the game.|r") |
| 04-26-2007, 07:39 PM | #6 |
that works too! |
| 04-26-2007, 07:44 PM | #7 |
Thanks to both of you. +rep |
| 04-27-2007, 03:23 AM | #8 |
I did this script for my project, probably it can be useful too. The other codes work fine, but this one returns the right color, even if the player has changed its color. JASS:function SetPlayerColorText takes player p, string s returns string //Set the color in the text local playercolor pc = GetPlayerColor(p) local string color if pc == ConvertPlayerColor(0) then set color = "|CFFFF0000" elseif pc == ConvertPlayerColor(1) then set color = "|CFF0000FF" elseif pc == ConvertPlayerColor(2) then set color = "|CFF18E7BD" elseif pc == ConvertPlayerColor(3) then set color = "|CFF520084" elseif pc == ConvertPlayerColor(4) then set color = "|CFFFFFF00" elseif pc == ConvertPlayerColor(5) then set color = "|CFFFF8A08" elseif pc == ConvertPlayerColor(6) then set color = "|CFF18BE00" elseif pc == ConvertPlayerColor(7) then set color = "|CFFE759AD" elseif pc == ConvertPlayerColor(8) then set color = "|CFF949694" elseif pc == ConvertPlayerColor(9) then set color = "|CFF7BBEF7" elseif pc == ConvertPlayerColor(10) then set color = "|CFF086142" elseif pc == ConvertPlayerColor(11) then set color = "|CFF4A2800" else set color = "|CFFFFFFFF" endif set pc = null return color + s endfunction |
