Komaqtion
You can change this now in User CP.
- Reaction score
- 469
Ok, so looks like this now.
I've added that "If" to only 1 function, should I add it to all which "takes" a player ?
I also added a slight update to the doc too
I've added that "If" to only 1 function, should I add it to all which "takes" a player ?
I also added a slight update to the doc too
JASS:
library PlayerColors initializer Init
///////////////////////////////////////////////////////////////////////////////////////////////////
// *//PlayerColoredString\\* //
// *//Made by , Komaqtion\\* //
// //
// //
// Purpose: //
// //
// ¤ This snippet is supposed to help people to, with ease, convert //
// a string to use a desired player's own color! //
// //
// Usage: //
// //
// ¤ To use this snippet, simply type "call PlayerColoredString(playerid, string)" //
// where "string" is the string you want to colorize, and "playerid" //
// is the player number of the player, whose color you wan to use. //
// Note: This uses JASS' player number range, meaning that //
// Player 1(Red)'s number is 0, and Player 2(Blue)'s number is 1, //
// and so on... //
// You can also get only the players color-string for own usage... //
// This is accomplished by using the function "GetPlayerColorString" //
// which takes the player to get the string, or you can also use //
// the GetPlayerColorStringById function, which takes the player's //
// Id, or number instead <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" /> //
// You can also change the color of texttags using this snippet... //
// The function is called "PlayerColoredTextTag" and takes integer alpha //
// which is transparency, player p, the playercolor you which to use, and //
// texttag tag which is the texttag you which to change the color of ! //
// You can also use the function "GetPlayerByColor" which takes a string (color) //
// and returns the player which has that specific color. You can even type //
// "ReD" or "REd" or even "..,, R, e.., d" and it'll return Player(0) or //
// player red in all three cases. And, you can also get the player's color //
// this way. //
// //
// WARNING: If you put an invalid player as an argument, in any of the functions, //
// it WILL return Player( 0 ), or Player "Red" ! //
// //
// //
// Requirements: //
// //
// ¤ This snippet's only requirement is vJASS compilement, which is //
// easiest achieved by downloading JASS Newgen Pack, at //
// <a href="http://www.thehelper.net/forums/showthread.php?t=73936" class="link link--internal">http://www.thehelper.net/forums/showthread.php?t=73936</a> //
// You'll also have to update JASS Helper to the latest version... //
// //
// //
// Credits: //
// //
// ¤ Azlier, for helpong me out alot with several bugfixes and tweaking ! //
// Jesus4Lyf, for also helping me out alot ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" /> //
// Quraji, for helping me add the "GetPlayerByColor" function ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" /> //
// //
// And credits, if you use this that is, is not needed to give me //
// though it's always welcome <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" /> //
// //
///////////////////////////////////////////////////////////////////////////////////////////////////
globals
private integer array Red
private integer array Green
private integer array Blue
private integer array RedString
private integer array GreenString
private integer array BlueString
private string array PlayerColor
private string array PlayerColorString
private string array PlayerColorWord
private string array PlayerColorWordString
private constant string EndString = "|r"
endglobals
function PlayerColoredString takes integer playerId, string s returns string
return PlayerColor[playerId] + s + EndString
endfunction
function PlayerColoredTextTag takes integer alpha, player p, texttag tag returns nothing
if p == null then
debug call BJDebugMsg( "An invalid player was used!" )
return
endif
call SetTextTagColor( tag, Red[GetPlayerId( p )], Green[GetPlayerId( p )], Blue[GetPlayerId( p )], alpha )
endfunction
function PlayerColoredTextTagById takes integer alpha, integer playerId, texttag tag returns nothing
call SetTextTagColor( tag, Red[playerId], Green[playerId], Blue[playerId], alpha )
endfunction
function GetPlayerColorString takes player p returns string
return PlayerColor[GetPlayerId( p )]
endfunction
function GetPlayerColorStringById takes integer playerId returns string
return PlayerColor[playerId]
endfunction
function CompressString takes string compstring returns string
local integer w = StringLength( compstring )
local integer i = 0
local string s = ""
loop
if not( SubString( compstring, i, i + 1 ) == " " or SubString( compstring, i, i + 1 ) == "." or SubString( compstring, i, i + 1 ) == "," ) then
set s = s + SubString( compstring, i, i + 1 )
endif
set i = i + 1
exitwhen i > w
endloop
return s
endfunction
function GetPlayerByColor takes string color returns player
local string s = StringCase( color, false )
local integer i = 0
set s = CompressString( s )
loop
if s == PlayerColorWordString<i> then
return Player( i )
elseif s == PlayerColorWordString[13] then
return Player( 8 )
elseif s == PlayerColorWordString[14] or s == PlayerColorWordString[15] then
return Player( 2 )
endif
set i = i + 1
exitwhen ( i >= 13 )
endloop
return null
endfunction
function GetPlayerColorByColor takes string color returns string
local string s = StringCase( color, false )
local integer i = 0
set s = CompressString( s )
loop
if s == PlayerColorWordString<i> then
return PlayerColor<i>
endif
set i = i + 1
exitwhen ( i >= 13 )
endloop
if s == PlayerColorWordString[13] then
return PlayerColor[8]
elseif s == PlayerColorWordString[14] or s == PlayerColorWordString[15] then
return PlayerColor[2]
endif
return ""
endfunction
private function OnColorChange takes player whichplayer, playercolor color returns nothing
local integer id = GetPlayerId( whichplayer )
local integer pc = GetHandleId( color )
set PlayerColor[id] = PlayerColorString[pc]
set Red[id] = RedString[pc]
set Green[id] = GreenString[pc]
set Blue[id] = BlueString[pc]
set PlayerColorWord[id] = PlayerColorWordString[pc]
endfunction
hook SetPlayerColor OnColorChange
private function Init takes nothing returns nothing
local integer i = 12
local integer i2
set PlayerColorString[0] = "|c00ff0202"
set RedString[0] = 0xff
set GreenString[0] = 0x02
set BlueString[0] = 0x02
set PlayerColorWordString[0] = "red"
set PlayerColorString[1] = "|c000041ff"
set RedString[1] = 0x00
set GreenString[1] = 0x41
set BlueString[1] = 0xff
set PlayerColorWordString[1] = "blue"
set PlayerColorString[2] = "|c001be5b8"
set RedString[2] = 0x1b
set GreenString[2] = 0xe5
set BlueString[2] = 0xb8
set PlayerColorWordString[2] = "teal"
set PlayerColorString[3] = "|c00530080"
set RedString[3] = 0x53
set GreenString[3] = 0x00
set BlueString[3] = 0x80
set PlayerColorWordString[3] = "purple"
set PlayerColorString[4] = "|c00fffc00"
set RedString[4] = 0xff
set GreenString[4] = 0xfc
set BlueString[4] = 0x00
set PlayerColorWordString[4] = "yellow"
set PlayerColorString[5] = "|c00fe890d"
set RedString[5] = 0xfe
set GreenString[5] = 0x89
set BlueString[5] = 0x0d
set PlayerColorWordString[5] = "orange"
set PlayerColorString[6] = "|c001fbf00"
set RedString[6] = 0x1f
set GreenString[6] = 0xbf
set BlueString[6] = 0x00
set PlayerColorWordString[6] = "green"
set PlayerColorString[7] = "|c00e45aaf"
set RedString[7] = 0xe4
set GreenString[7] = 0x5a
set BlueString[7] = 0xaf
set PlayerColorWordString[7] = "pink"
set PlayerColorString[8] = "|c00949596"
set RedString[8] = 0x94
set GreenString[8] = 0x95
set BlueString[8] = 0x96
set PlayerColorWordString[8] = "grey"
set PlayerColorString[9] = "|c007dbef1"
set RedString[9] = 0x7d
set GreenString[9] = 0xbe
set BlueString[9] = 0xf1
set PlayerColorWordString[9] = "lightblue"
set PlayerColorString[10] = "|c000f6145"
set RedString[10] = 0x0f
set GreenString[10] = 0x61
set BlueString[10] = 0x45
set PlayerColorWordString[10] = "darkgreen"
set PlayerColorString[11] = "|c004d2903"
set RedString[11] = 0x4d
set GreenString[11] = 0x29
set BlueString[11] = 0x03
set PlayerColorWordString[11] = "brown"
set PlayerColorString[12] = "|c001f1f1f"
set RedString[12] = 0x1f
set GreenString[12] = 0x1f
set BlueString[12] = 0x1f
set PlayerColorWordString[12] = "darkgrey"
set PlayerColorWordString[13] = "gray"
set PlayerColorWordString[14] = "aqua"
set PlayerColorWordString[15] = "cyan"
loop
exitwhen i < 0
set i2 = GetHandleId( GetPlayerColor( Player( i ) ) )
set PlayerColor<i> = PlayerColorString[i2]
set Red<i> = RedString[i2]
set Green<i> = GreenString[i2]
set Blue<i> = BlueString[i2]
set PlayerColorWord<i> = PlayerColorWordString<i>
set i = i - 1
endloop
endfunction
endlibrary</i></i></i></i></i></i></i></i></i>