Как конвертировать playercolor в строку типа |cffffffff
set udg_Colour[i + 1]=GetPlayerColor(Player(i))

Принятый ответ

Как-то так, в вызове указываешь игрока, а она возвращает цвет в виде строки:
function GetColor takes player whichplayer returns string
	local playercolor color = GetPlayerColor(whichplayer)
	
	if (color == PLAYER_COLOR_RED) then return "FF0303" endif
	if (color == PLAYER_COLOR_BLUE) then return "0042FF" endif
	if (color == PLAYER_COLOR_CYAN) then return "1CE6B9" endif
	if (color == PLAYER_COLOR_PURPLE) then return "540081" endif
	if (color == PLAYER_COLOR_YELLOW) then return "FFFC01" endif
	if (color == PLAYER_COLOR_ORANGE) then return "FEBA0E" endif
	if (color == PLAYER_COLOR_GREEN) then return "20C000" endif
	if (color == PLAYER_COLOR_PINK) then return "E55BB0" endif
	if (color == PLAYER_COLOR_LIGHT_GRAY) then return "959697" endif
	if (color == PLAYER_COLOR_LIGHT_BLUE) then return "7EBFF1" endif
	if (color == PLAYER_COLOR_AQUA) then return "106246" endif
	if (color == PLAYER_COLOR_BROWN) then return "4E2A04" endif
	return ""
endfunction
`
ОЖИДАНИЕ РЕКЛАМЫ...

Показан только небольшой набор комментариев вокруг указанного. Перейти к актуальным.
0
27
4 года назад
0
KaneThaumaturge, Создаем базу цветов, держим их по индексу цвета, пишем функцию покраски в цвет, вызываем функцию где нам это нужно
0
19
4 года назад
0
Ev3nt:
Так, напомните, вы хотите, чтобы несколько игроков могли выбрать один цвет, или добавить новые цвета?
Хочу чтобы игрок мог выбрать себе цвет в лобби, а я потом смог отловить тот цвет, который он выбрал.

Феникс, Так игрок с индексом 0 (красный), может выбрать темно-зеленый цвет.
0
27
4 года назад
0
KaneThaumaturge, Я о том и говорю, библиотека (массив) завязывается не на индексе игрока, а на цвете, что выше приводит в пример ScorpioT1000
0
19
4 года назад
0
Феникс, Окей, но мне нужна именно строка. Просто определить какой цвет выбрал игрок.
6
19
4 года назад
Отредактирован Ev3nt
6
Как-то так, в вызове указываешь игрока, а она возвращает цвет в виде строки:
function GetColor takes player whichplayer returns string
	local playercolor color = GetPlayerColor(whichplayer)
	
	if (color == PLAYER_COLOR_RED) then return "FF0303" endif
	if (color == PLAYER_COLOR_BLUE) then return "0042FF" endif
	if (color == PLAYER_COLOR_CYAN) then return "1CE6B9" endif
	if (color == PLAYER_COLOR_PURPLE) then return "540081" endif
	if (color == PLAYER_COLOR_YELLOW) then return "FFFC01" endif
	if (color == PLAYER_COLOR_ORANGE) then return "FEBA0E" endif
	if (color == PLAYER_COLOR_GREEN) then return "20C000" endif
	if (color == PLAYER_COLOR_PINK) then return "E55BB0" endif
	if (color == PLAYER_COLOR_LIGHT_GRAY) then return "959697" endif
	if (color == PLAYER_COLOR_LIGHT_BLUE) then return "7EBFF1" endif
	if (color == PLAYER_COLOR_AQUA) then return "106246" endif
	if (color == PLAYER_COLOR_BROWN) then return "4E2A04" endif
	return ""
endfunction
Принятый ответ
0
19
4 года назад
0
Не буду же я переделывать все тексты в карте. У меня везде используется вариант с добавлением строки, а не playercolor

Ev3nt, во, да, чет я сам не додумался

Ev3nt, Спасибо.
0
19
4 года назад
Отредактирован Ev3nt
0
Пожалуйста.
0
27
4 года назад
Отредактирован Феникс
0
KaneThaumaturge, ну у тебя просто нет вариантов, я опять же говорю, проще создать функциию:
function Colorizer(player, text)
	text = color[GetPlayerColor(player)]..text.."|r"
end
где color[n] - библиотека цветов
2
28
4 года назад
Отредактирован PT153
2
Можно воспользоваться моей либой.
раскрыть
library ColorLibrary uses CommonLibrary
function GetPlayerColorIndex takes playercolor pc returns integer
    return GetHandleId(pc)
endfunction

struct Color extends array
    private static integer counter = -1

    static thistype White
    
    static thistype Gold
    static thistype Experience
    static thistype Food
    static thistype Income
    static thistype Lives
    static thistype Kills
    
    static thistype Numbers
    static thistype Important
    static thistype Hints
    static thistype Warnings
    static thistype Errors
    static thistype Leaved
    
    integer red
    integer green
    integer blue
    string hex
    string icon
    
    private static method GetIndex takes nothing returns thistype
        set counter = counter + 1
        return counter
    endmethod
    
    private static method InitPlayerColors takes nothing returns nothing
        local thistype i = GetIndex()
        set i.red = 255
        set i.green = 3
        set i.blue = 3
        set i.hex = "|cffff0303"
        set i.icon = "Icons\\Player colors\\00. Red.blp"
        
        set i = GetIndex()
        set i.red = 0
        set i.green = 66
        set i.blue = 255
        set i.hex = "|cff0042ff"
        set i.icon = "Icons\\Player colors\\01. Blue.blp"
        
        set i = GetIndex()
        set i.red = 28
        set i.green = 230
        set i.blue = 185
        set i.hex = "|cff1ce6b9"
        set i.icon = "Icons\\Player colors\\02. Teal.blp"
        
        set i = GetIndex()
        set i.red = 84
        set i.green = 0
        set i.blue = 129
        set i.hex = "|cff540081"
        set i.icon = "Icons\\Player colors\\03. Purple.blp"
        
        set i = GetIndex()
        set i.red = 255
        set i.green = 252
        set i.blue = 0
        set i.hex = "|cfffffc00"
        set i.icon = "Icons\\Player colors\\04. Yellow.blp"
        
        set i = GetIndex()
        set i.red = 254
        set i.green = 138
        set i.blue = 14
        set i.hex = "|cfffe8a0e"
        set i.icon = "Icons\\Player colors\\05. Orange.blp"
        
        set i = GetIndex()
        set i.red = 32
        set i.green = 192
        set i.blue = 0
        set i.hex = "|cff20c000"
        set i.icon = "Icons\\Player colors\\06. Green.blp"
        
        set i = GetIndex()
        set i.red = 229
        set i.green = 91
        set i.blue = 176
        set i.hex = "|cffe55bb0"
        set i.icon = "Icons\\Player colors\\07. Pink.blp"
        
        set i = GetIndex()
        set i.red = 149
        set i.green = 150
        set i.blue = 151
        set i.hex = "|cff959697"
        set i.icon = "Icons\\Player colors\\08. Gray.blp"
        
        set i = GetIndex()
        set i.red = 126
        set i.green = 191
        set i.blue = 241
        set i.hex = "|cff7ebff1"
        set i.icon = "Icons\\Player colors\\09. Light Blue.blp"
        
        set i = GetIndex()
        set i.red = 16
        set i.green = 98
        set i.blue = 70
        set i.hex = "|cff106246"
        set i.icon = "Icons\\Player colors\\10. Dark Green.blp"
        
        set i = GetIndex()
        set i.red = 78
        set i.green = 42
        set i.blue = 4
        set i.hex = "|cff4e2a04"
        set i.icon = "Icons\\Player colors\\11. Brown.blp"
        
        set i = GetIndex()
        set i.red = 155
        set i.green = 0
        set i.blue = 0
        set i.hex = "|cff9b0000"
        set i.icon = "Icons\\Player colors\\12. Maroon.blp"
        
        set i = GetIndex()
        set i.red = 0
        set i.green = 0
        set i.blue = 195
        set i.hex = "|cff0000c3"
        set i.icon = "Icons\\Player colors\\13. Navy.blp"
        
        set i = GetIndex()
        set i.red = 0
        set i.green = 234
        set i.blue = 255
        set i.hex = "|cff00eaff"
        set i.icon = "Icons\\Player colors\\14. Turquoise.blp"
        
        set i = GetIndex()
        set i.red = 190
        set i.green = 0
        set i.blue = 254
        set i.hex = "|cffbe00fe"
        set i.icon = "Icons\\Player colors\\15. Violet.blp"
        
        set i = GetIndex()
        set i.red = 235
        set i.green = 205
        set i.blue = 135
        set i.hex = "|cffebcd87"
        set i.icon = "Icons\\Player colors\\16. Wheat.blp"
        
        set i = GetIndex()
        set i.red = 248
        set i.green = 164
        set i.blue = 139
        set i.hex = "|cfff8a48b"
        set i.icon = "Icons\\Player colors\\17. Peach.blp"
        
        set i = GetIndex()
        set i.red = 191
        set i.green = 255
        set i.blue = 128
        set i.hex = "|cffbfff80"
        set i.icon = "Icons\\Player colors\\18. Mint.blp"
        
        set i = GetIndex()
        set i.red = 220
        set i.green = 185
        set i.blue = 235
        set i.hex = "|cffdcb9eb"
        set i.icon = "Icons\\Player colors\\19. Lavender.blp"
        
        set i = GetIndex()
        set i.red = 40
        set i.green = 40
        set i.blue = 40
        set i.hex = "|cff282828"
        set i.icon = "Icons\\Player colors\\20. Coal.blp"
        
        set i = GetIndex()
        set i.red = 235
        set i.green = 240
        set i.blue = 255
        set i.hex = "|cffebf0ff"
        set i.icon = "Icons\\Player colors\\21. Snow.blp"
        
        set i = GetIndex()
        set i.red = 0
        set i.green = 120
        set i.blue = 30
        set i.hex = "|cff00781e"
        set i.icon = "Icons\\Player colors\\22. Emerald.blp"
        
        set i = GetIndex()
        set i.red = 164
        set i.green = 111
        set i.blue = 51
        set i.hex = "|cffa46f33"
        set i.icon = "Icons\\Player colors\\23. Peanut.blp"
    endmethod
    
    private static method onInit takes nothing returns nothing
        call InitPlayerColors()
    
        set White = GetIndex()
        set White.red = 255
        set White.green = 255
        set White.blue = 255
        set White.hex = "|cffffff"
    
        set Gold = GetIndex()
        set Gold.red = 226
        set Gold.green = 176
        set Gold.blue = 7
        set Gold.hex = "|cffe2b007"
        
        set Experience = GetIndex()
        set Experience.red = 127
        set Experience.green = 204
        set Experience.blue = 255
        set Experience.hex = "|cff7fccff"
        
        set Food = GetIndex()
        set Food.red = 209
        set Food.green = 91
        set Food.blue = 143
        set Food.hex = "|cffd15b8f"
        
        set Income = GetIndex()
        set Income.red = 118
        set Income.green = 165
        set Income.blue = 175
        set Income.hex = "|cff76a5af"
        
        set Lives = GetIndex()
        set Lives.red = 0
        set Lives.green = 187
        set Lives.blue = 46
        set Lives.hex = "|cff00bb2e"
        
        set Kills = GetIndex()
        set Kills.red = 204
        set Kills.green = 33
        set Kills.blue = 33
        set Kills.hex = "|cffcc3333"
        
        set Numbers = GetIndex()
        set Numbers.red = 0
        set Numbers.green = 204
        set Numbers.blue = 255
        set Numbers.hex = "|cff00ccff"
        
        set Important = GetIndex()
        set Important.red = 255
        set Important.green = 204
        set Important.blue = 128
        set Important.hex = "|cffffcc80"
        
        set Hints = GetIndex()
        set Hints.red = 51
        set Hints.green = 204
        set Hints.blue = 51
        set Hints.hex = "|cff33cc33"
        
        set Leaved = GetIndex()
        set Leaved.red = 15
        set Leaved.green = 15
        set Leaved.blue = 15
        set Leaved.hex = "|cff0f0f0f"
        
        set Warnings = Kills
        set Errors = Kills
    endmethod
endstruct

function ShadowMultiboardItem takes multiboarditem mbitem returns nothing
    call MultiboardSetItemValueColor(mbitem, Color.Leaved.red, Color.Leaved.green, Color.Leaved.blue, CellAlpha)
endfunction

function HideMultiboardItem takes multiboarditem mbitem returns nothing
    call MultiboardSetItemStyle(mbitem, false, false)
endfunction

endlibrary
Цвет игрока получается так
Color[GetPlayerColorIndex(GetPlayerColor(Player(0)))] + "Red Player|r"
Показан только небольшой набор комментариев вокруг указанного. Перейти к актуальным.
Чтобы оставить комментарий, пожалуйста, войдите на сайт.