2015-05-27, 18:54:34
Quote:Change Color Wrote:function Cond_Change_Color takes nothing returns boolean
return SubString(GetEventPlayerChatString(),0,1) == "-"
endfunction
function SetPlayerColorDK takes player changer, playercolor color returns nothing
local group g
local integer pid = GetPlayerId(changer)
local multiboarditem mbitem
call SetPlayerColor(changer, color)
set udg_Colors[pid+1] = GetPlayerTextColor(changer)
if pid < 3 then
set mbitem = MultiboardGetItem(udg_LeftBoard,pid+1,0)
else
set mbitem = MultiboardGetItem(udg_RightBoard,pid-2,0)
endif
call MultiboardSetItemValue(mbitem,GetPlayerNameColored(changer))
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(udg_OtherBoard,pid+1,0)
call MultiboardSetItemValue(mbitem,GetPlayerNameColored(changer))
call MultiboardReleaseItem(mbitem)
set bj_setPlayerTargetColor = color
set g = CreateGroup()
call GroupEnumUnitsOfPlayer(g, changer, Condition(function AlwaysTrue))
call ForGroup(g, function SetPlayerColorBJEnum)
call DestroyGroup(g)
endfunction
function Trig_Change_Color_Actions takes nothing returns nothing
local string color = SubString(GetEventPlayerChatString(),7,StringLength(GetEventPlayerChatString()))
local player tp = GetTriggerPlayer()
if color == "green" then
call SetPlayerColorDK(tp,PLAYER_COLOR_GREEN)
elseif color == "red" then
call SetPlayerColorDK(tp,PLAYER_COLOR_RED)
elseif color == "blue" then
call SetPlayerColorDK(tp,PLAYER_COLOR_BLUE)
elseif color == "aqua" or color == "dark green" or color == "dgreen" then
call SetPlayerColorDK(tp,PLAYER_COLOR_AQUA)
elseif color == "brown" then
call SetPlayerColorDK(tp,PLAYER_COLOR_BROWN)
elseif color == "light blue" or color == "lblue" then
call SetPlayerColorDK(tp,PLAYER_COLOR_LIGHT_BLUE)
elseif color == "orange" then
call SetPlayerColorDK(tp,PLAYER_COLOR_ORANGE)
elseif color == "yellow" then
call SetPlayerColorDK(tp,PLAYER_COLOR_YELLOW)
elseif color == "purple" then
call SetPlayerColorDK(tp,PLAYER_COLOR_PURPLE)
elseif color == "pink" then
call SetPlayerColorDK(tp,PLAYER_COLOR_PINK)
elseif color == "cyan" or color == "teal" then
call SetPlayerColorDK(tp,PLAYER_COLOR_CYAN)
elseif color == "gray" then
call SetPlayerColorDK(tp,PLAYER_COLOR_LIGHT_GRAY)
endif
endfunction
//===========================================================================
function InitTrig_Change_Color takes nothing returns nothing
set gg_trg_Change_Color = CreateTrigger( )
call TriggerRegisterAnyPlayerChatEventDK( gg_trg_Change_Color, "-color", false )
call TriggerAddCondition(gg_trg_Change_Color,Condition(function Cond_Change_Color))
call TriggerAddAction( gg_trg_Change_Color, function Trig_Change_Color_Actions )
endfunction