Snippet String2PlayerColoredString

Azlier

Old World Ghost
Reaction score
461
JASS:
set PlayerColorString[4] = "|c00fffc00"
set Red[0] = 0xff
set Green[0] = 0xfc
set Blue[0] = 0x00
set PlayerColorString[5] = "|c00fe890d"
set Red[0] = 0xfe
set Green[0] = 0x89
set Blue[0] = 0x0d

Can you see it?

Again, you have to treat those arrays like you do with PlayerColor. With the whole hook business.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Such a stupid mistake XD

And by "treat those arrays like you do with PlayerColor" you mean by having two of the same ? :S

Like PlayerColor and PlayerColorString ?
 

Azlier

Old World Ghost
Reaction score
461
Yes. But, I would just have an integer array and use that as an index for all four other arrays. I wish I could show you what I meant.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Well, yeah me 2 ! XD
As I don't really understand :(

Well, this is what I have atm:
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" />                                                        //
//                                                                                               //
//                                    Requirements:                                              //
//                                                                                               //
//             ¤ This snippet&#039;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&#039;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" />                                    //
//                                                                                               //
//               And credits, if you use this that is, is not needed to give me                  //
//               though it&#039;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 string array PlayerColor
        private string array PlayerColorString
        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 constant string EndString = &quot;|r&quot;
    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
        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
    
    private function OnColorChange takes player whichplayer, playercolor color returns nothing
        set PlayerColor[GetPlayerId(whichplayer)] = PlayerColorString[GetHandleId(color)]
        set Red[GetPlayerId(whichplayer)] = RedString[GetHandleId(color)]
        set Green[GetPlayerId(whichplayer)] = GreenString[GetHandleId(color)]
        set Blue[GetPlayerId(whichplayer)] = BlueString[GetHandleId(color)]
    endfunction
    
    hook SetPlayerColor OnColorChange
    
    private function Init takes nothing returns nothing
        local integer i = 11
    
        set PlayerColorString[0] = &quot;|c00ff0202&quot;
        set RedString[0] = 0xff
        set GreenString[0] = 0x02
        set BlueString[0] = 0x02
        set PlayerColorString[1] = &quot;|c000041ff&quot;
        set RedString[1] = 0x00
        set GreenString[1] = 0x41
        set BlueString[1] = 0xff
        set PlayerColorString[2] = &quot;|c001be5b8&quot;
        set RedString[2] = 0x1b
        set GreenString[2] = 0xe5
        set BlueString[2] = 0xb8
        set PlayerColorString[3] = &quot;|c00530080&quot;
        set RedString[3] = 0x53
        set GreenString[3] = 0x00
        set BlueString[3] = 0x80
        set PlayerColorString[4] = &quot;|c00fffc00&quot;
        set RedString[4] = 0xff
        set GreenString[4] = 0xfc
        set BlueString[4] = 0x00
        set PlayerColorString[5] = &quot;|c00fe890d&quot;
        set RedString[5] = 0xfe
        set GreenString[5] = 0x89
        set BlueString[5] = 0x0d
        set PlayerColorString[6] = &quot;|c001fbf00&quot;
        set RedString[6] = 0x1f
        set GreenString[6] = 0xbf
        set BlueString[6] = 0x00
        set PlayerColorString[7] = &quot;|c00e45aaf&quot;
        set RedString[7] = 0xe4
        set GreenString[7] = 0x5a
        set BlueString[7] = 0xaf
        set PlayerColorString[8] = &quot;|c00949596&quot;
        set RedString[8] = 0x94
        set GreenString[8] = 0x95
        set BlueString[8] = 0x96
        set PlayerColorString[9] = &quot;|c007dbef1&quot;
        set RedString[9] = 0x7d
        set GreenString[9] = 0xbe
        set BlueString[9] = 0xf1
        set PlayerColorString[10] = &quot;|c000f6145&quot;
        set RedString[10] = 0x0f
        set GreenString[10] = 0x61
        set BlueString[10] = 0x45
        set PlayerColorString[11] = &quot;|c004d2903&quot;
        set RedString[11] = 0x4d
        set GreenString[11] = 0x29
        set BlueString[11] = 0x03
    
        loop
            exitwhen i &lt; 0
            set PlayerColor<i> = PlayerColorString[GetHandleId(GetPlayerColor(Player(i)))]
            set Red<i> = RedString[GetHandleId(GetPlayerColor(Player(i)))]
            set Green<i> = GreenString[GetHandleId(GetPlayerColor(Player(i)))]
            set Blue<i> = BlueString[GetHandleId(GetPlayerColor(Player(i)))]
            set i = i - 1
        endloop
        
    endfunction
    
endlibrary</i></i></i></i>


is it what you mean ? :S
(I don't think so...)


EDIT: Well, it now shows the correct color !!! :D:D Yay ! ;)
Thanks :D
 

Azlier

Old World Ghost
Reaction score
461
Exactly. One tweak though:

JASS:
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]
endfunction
 

Azlier

Old World Ghost
Reaction score
461
Dark grey. Very dark. |c00cccccc?
 

Azlier

Old World Ghost
Reaction score
461
Try mine? If mine doesn't work, go |c00dddddd.
 

Azlier

Old World Ghost
Reaction score
461
I believe so. There are only 13 player colors (excluding the hidden, unstable "player colors").
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Ok, thanks ! :D

But, "|c00cccccc" didn't work :( It displayed white...

Will try with the "d"s now ;)
 

Azlier

Old World Ghost
Reaction score
461
...White? How? Odd.

Test script, please?
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Here's the test:
Trigger:
  • Test Colors
    • Events
      • Player - Player 1 (Red) types a chat message containing color as An exact match
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 12, do (Actions)
        • Loop - Actions
          • Custom script: call BJDebugMsg(PlayerColoredString(GetPlayerId(Player(bj_forLoopAIndex)),GetEventPlayerChatString()))
          • Wait 0.10 seconds
      • Custom script: call SetPlayerColor(Player(0), PLAYER_COLOR_BLUE)
      • Wait 2.00 seconds
      • For each (Integer A) from 0 to 12, do (Actions)
        • Loop - Actions
          • Custom script: call BJDebugMsg(PlayerColoredString(GetPlayerId(Player(bj_forLoopAIndex)),GetEventPlayerChatString()))
          • Wait 0.10 seconds


Everything shows correct, until the las one...

And here's the script again.

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&#039;s own color!                                   //
//                                                                                               //
//                                         Usage:                                                //
//                                                                                               //
//             ¤ To use this snippet, simply type &quot;call PlayerColoredString(playerid, string)&quot;   //
//               where &quot;string&quot; is the string you want to colorize, and &quot;playerid&quot;               //
//               is the player number of the player, whose color you wan to use.                 //
//               Note: This uses JASS&#039; player number range, meaning that                         //
//               Player 1(Red)&#039;s number is 0, and Player 2(Blue)&#039;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 &quot;GetPlayerColorString&quot;               //
//               which takes the player to get the string, or you can also use                   //
//               the GetPlayerColorStringById function, which takes the player&#039;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" />                                                        //
//                                                                                               //
//                                    Requirements:                                              //
//                                                                                               //
//             ¤ This snippet&#039;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&#039;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" />                                    //
//                                                                                               //
//               And credits, if you use this that is, is not needed to give me                  //
//               though it&#039;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 constant string EndString = &quot;|r&quot;
    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
        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
    
    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]
    endfunction
    
    hook SetPlayerColor OnColorChange
    
    private function Init takes nothing returns nothing
        local integer i = 12
        local integer i2
    
        set PlayerColorString[0] = &quot;|c00ff0202&quot;
        set RedString[0] = 0xff
        set GreenString[0] = 0x02
        set BlueString[0] = 0x02
        set PlayerColorString[1] = &quot;|c000041ff&quot;
        set RedString[1] = 0x00
        set GreenString[1] = 0x41
        set BlueString[1] = 0xff
        set PlayerColorString[2] = &quot;|c001be5b8&quot;
        set RedString[2] = 0x1b
        set GreenString[2] = 0xe5
        set BlueString[2] = 0xb8
        set PlayerColorString[3] = &quot;|c00530080&quot;
        set RedString[3] = 0x53
        set GreenString[3] = 0x00
        set BlueString[3] = 0x80
        set PlayerColorString[4] = &quot;|c00fffc00&quot;
        set RedString[4] = 0xff
        set GreenString[4] = 0xfc
        set BlueString[4] = 0x00
        set PlayerColorString[5] = &quot;|c00fe890d&quot;
        set RedString[5] = 0xfe
        set GreenString[5] = 0x89
        set BlueString[5] = 0x0d
        set PlayerColorString[6] = &quot;|c001fbf00&quot;
        set RedString[6] = 0x1f
        set GreenString[6] = 0xbf
        set BlueString[6] = 0x00
        set PlayerColorString[7] = &quot;|c00e45aaf&quot;
        set RedString[7] = 0xe4
        set GreenString[7] = 0x5a
        set BlueString[7] = 0xaf
        set PlayerColorString[8] = &quot;|c00949596&quot;
        set RedString[8] = 0x94
        set GreenString[8] = 0x95
        set BlueString[8] = 0x96
        set PlayerColorString[9] = &quot;|c007dbef1&quot;
        set RedString[9] = 0x7d
        set GreenString[9] = 0xbe
        set BlueString[9] = 0xf1
        set PlayerColorString[10] = &quot;|c000f6145&quot;
        set RedString[10] = 0x0f
        set GreenString[10] = 0x61
        set BlueString[10] = 0x45
        set PlayerColorString[11] = &quot;|c004d2903&quot;
        set RedString[11] = 0x4d
        set GreenString[11] = 0x29
        set BlueString[11] = 0x03

        set PlayerColorString[12] = &quot;|c00dddddd&quot;
        set RedString[12] = 0xcc
        set GreenString[12] = 0xcc
        set BlueString[12] = 0xcc
    
        loop
            exitwhen i &lt; 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 i = i - 1
        endloop
        
    endfunction
    
endlibrary</i></i></i></i>


Also tested with this, and also white:
Trigger:
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TempPoint = (Center of Region 1 &lt;gen&gt;)
      • Floating Text - Create floating text that reads Region 1! at TempPoint with Z offset 0.00, using font size 15.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Set TempPoint = (Center of Region 2 &lt;gen&gt;)
      • Floating Text - Create floating text that reads Region 2! at TempPoint with Z offset 0.00, using font size 15.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Custom script: call PlayerColoredTextTag( 100, Player(12), GetLastCreatedTextTag())
      • Custom script: call RemoveLocation(udg_TempPoint)
 

Azlier

Old World Ghost
Reaction score
461
How very strange. Try replacing the current contents of player 12's color with red. Test that.
 

Azlier

Old World Ghost
Reaction score
461
Indeed. I wonder what I did wrong.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
I think it might be this one, "|c001f1f1f"

Just took a Color Picker on a Neutral-owned Paladin, and that's what I got from the cape ;)

Will test it :D

(Btw, I put your color-code in there too, and it displayed white too ...)
 

Azlier

Old World Ghost
Reaction score
461
Nooow I know what I did wrong. I forgot that adding color makes white, and removing color makes black.

|c00202020 sounds good. But, you probably found the ideal color.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Yeah, my color is fine ;)
Thanks anyways ;)

So... Now what do I do with this ? :eek:
(I mean the snippet/system :eek:)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top