Snippet String2PlayerColoredString

Reaction score
341
He means;

JASS:
globals
    private string array PlayerColor
    private player array PLAYER
    private constant string EndColor = "|r"
endglobals

function S2PCS takes string s, integer playerId returns string    
    return PlayerColor[GetHandleId( GetPlayerColor(PLAYER[playerId]))] + s + EndColor
endfunction

function GetPlayerColorString takes player p returns string   
    return PlayerColor[GetHandleId( GetPlayerColor(p))]
endfunction

function GetPlayerColorStringById takes integer playerId returns string    
    return PlayerColor[GetHandleId( GetPlayerColor(PLAYER[playerId]))]
endfunction

private function Init takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i > 10
        set PLAYER<i> = Player(i)
        set i = i + 1
    endloop
    set PlayerColor[0] = &quot;|c00ff0202&quot;
    set PlayerColor[1] = &quot;|c000041ff&quot;
    set PlayerColor[2] = &quot;|c001be5b8&quot;
    set PlayerColor[3] = &quot;|c00530080&quot;
    set PlayerColor[4] = &quot;|c00fffc00&quot;
    set PlayerColor[5] = &quot;|c00fe890d&quot;
    set PlayerColor[6] = &quot;|c001fbf00&quot;
    set PlayerColor[7] = &quot;|c00e45aaf&quot;
    set PlayerColor[8] = &quot;|c00949596&quot;
    set PlayerColor[9] = &quot;|c007dbef1&quot;
    set PlayerColor[10] = &quot;|c000f6145&quot;
    set PlayerColor[11] = &quot;|c004d2903&quot;
    
endfunction

endlibrary</i>
 

Komaqtion

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

Though, I've now discovered that the GetPlayerColorString doesn't really work :S

Here's how I test it, and nothing shows...
Trigger:
  • For each (Integer A) from 0 to 11, do (Actions)
    • Loop - Actions
      • Custom script: call BJDebugMsg(GetPlayerColorString(Player(bj_forLoopAIndex)))
      • Wait 0.10 seconds


Oh, btw... Here's how the code looks like now:
JASS:
library PlayerColors initializer Init


///////////////////////////////////////////////////////////////////////////////////////////////////
//                               //String2PlayerColoredString\\                                  //
//                                  //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 snipper, simply type &quot;call S2PCS(string, playerid)&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>                          //
//                                                                                               //
//                                        Credits:                                               //
//                                                                                               //
//             ¤ Well, at the moment, not that many has helped me really, so no                  //
//               credits has been given yet                                                      //
//                                                                                               //
//               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 player array Players
    private string array PlayerColor
    private constant string EndString = &quot;|r&quot;
    private constant string StartString = &quot;|c&quot;
endglobals

function S2PCS takes string s, integer playerId returns string    
    return StartString + PlayerColor[GetHandleId( GetPlayerColor(Players[playerId]))] + s + EndString
endfunction

function GetPlayerColorString takes player p returns string   
    return StartString + PlayerColor[GetHandleId( GetPlayerColor(p))]
endfunction

function GetPlayerColorStringById takes integer playerId returns string    
    return StartString + PlayerColor[GetHandleId( GetPlayerColor(Players[playerId]))]
endfunction

private function Init takes nothing returns nothing
    local integer i = 0
    loop
        set Players<i> = Player(i)
        set i = i + 1
        exitwhen i == 12
    endloop
    
    set PlayerColor[0] = &quot;00ff0202&quot;
    set PlayerColor[1] = &quot;000041ff&quot;
    set PlayerColor[2] = &quot;001be5b8&quot;
    set PlayerColor[3] = &quot;00530080&quot;
    set PlayerColor[4] = &quot;00fffc00&quot;
    set PlayerColor[5] = &quot;00fe890d&quot;
    set PlayerColor[6] = &quot;001fbf00&quot;
    set PlayerColor[7] = &quot;00e45aaf&quot;
    set PlayerColor[8] = &quot;00949596&quot;
    set PlayerColor[9] = &quot;007dbef1&quot;
    set PlayerColor[10] = &quot;000f6145&quot;
    set PlayerColor[11] = &quot;004d2903&quot;
    
endfunction

endlibrary</i>



EDIT: Nvw... Artificial "helped" me XD


EDIT2: Btw, what takes for this to get approved (If it's even approvable XD :S) ? :eek:
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Yeah, sure :D Will use then ;)

Is it ok if I use "PlayerColoredString" ? :eek:
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Adding an Endstring there would just negate the color code, making the call pointless.
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
:confused:

This
Trigger:
  • For each (Integer A) from 0 to 11, do (Actions)
    • Loop - Actions
      • Custom script: call BJDebugMsg(GetPlayerColorString(Player(bj_forLoopAIndex)))
      • Wait 0.10 seconds

does not work because of missing Endstring?
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Read what I posted, lol. The entire point of that call is to cause text following it to be colored in the color of the entered player.
GetPlayerColorString(Player(bj_forLoopAIndex)) just causes any text following it in that string to be colored in whatever color the current player is.

Try GetPlayerColorString(Player(bj_forLoopAIndex)) + "HELLO WORLD".

:)

Should display a bunch of coloured 'HELLO WORLD's.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Ok... But any thoughts about the actuall code ? :eek:
Any chance of approving it ? :eek:
 

Azlier

Old World Ghost
Reaction score
461
Instead of calling GetHandleId(GetPlayerColor()), you could hook SetPlayerColor() (or whatever the native is) and save the proper things in an array. You get a nice efficiency gain there.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Actuallt, I've never used the "Hook" functionality :S

But I'll try :D Thanks :thup:
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Ok, got the "Hook" stuff working now, I believe :S

Please take a look ;)

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(string, playerid)&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>                          //
//                                                                                               //
//                                        Credits:                                               //
//                                                                                               //
//             ¤ Well, at the moment, not that many has helped me really, so no                  //
//               credits has been given yet                                                      //
//                                                                                               //
//               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 player array Players
    private string array PlayerColor
    private string array PlayerColorString
    private constant string EndString = &quot;|r&quot;
    private constant string StartString = &quot;|c&quot;
endglobals

function PlayerColoredString takes string s, integer playerId returns string    
    return StartString + PlayerColor[GetPlayerId(Players[playerId])] + s + EndString
endfunction

function GetPlayerColorString takes player p returns string   
    return StartString + PlayerColor[GetPlayerId(p)]
endfunction

function GetPlayerColorStringById takes integer playerId returns string    
    return StartString + PlayerColor[GetPlayerId(Players[playerId])]
endfunction

private function OnColorChange takes player whichplayer, playercolor color returns nothing
    set PlayerColor[GetPlayerId(whichplayer)] = PlayerColorString[GetHandleId(color)]
endfunction

hook SetPlayerColor OnColorChange

private function Init takes nothing returns nothing
    local integer i = 0
    loop
        set Players<i> = Player(i)
        set i = i + 1
        exitwhen i == 12
    endloop
    
    set PlayerColorString[0] = &quot;00ff0202&quot;
    set PlayerColorString[1] = &quot;000041ff&quot;
    set PlayerColorString[2] = &quot;001be5b8&quot;
    set PlayerColorString[3] = &quot;00530080&quot;
    set PlayerColorString[4] = &quot;00fffc00&quot;
    set PlayerColorString[5] = &quot;00fe890d&quot;
    set PlayerColorString[6] = &quot;001fbf00&quot;
    set PlayerColorString[7] = &quot;00e45aaf&quot;
    set PlayerColorString[8] = &quot;00949596&quot;
    set PlayerColorString[9] = &quot;007dbef1&quot;
    set PlayerColorString[10] = &quot;000f6145&quot;
    set PlayerColorString[11] = &quot;004d2903&quot;
    
    set i = 0
    loop
        set PlayerColor<i> = PlayerColorString<i>
        set i = i + 1
        exitwhen i == 12
    endloop
    
endfunction

endlibrary</i></i></i>
 

Azlier

Old World Ghost
Reaction score
461
JASS:
function GetPlayerColorStringById takes integer playerId returns string    
    return StartString + PlayerColor[GetPlayerId(Players[playerId])]
endfunction

I should hit you!
JASS:
function GetPlayerColorStringById takes integer playerId returns string    
    return StartString + PlayerColor[playerId]
endfunction
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Ouch :(

Sorry 'bout that XD

This then ? :S
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(string, playerid)&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>                          //
//                                                                                               //
//                                        Credits:                                               //
//                                                                                               //
//             ¤ Well, at the moment, not that many has helped me really, so no                  //
//               credits has been given yet                                                      //
//                                                                                               //
//               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 player array Players
    private string array PlayerColor
    private string array PlayerColorString
    private constant string EndString = &quot;|r&quot;
    private constant string StartString = &quot;|c&quot;
endglobals

function PlayerColoredString takes string s, integer playerId returns string    
    return StartString + PlayerColor[playerId] + s + EndString
endfunction

function GetPlayerColorString takes player p returns string   
    return StartString + PlayerColor[GetPlayerId(p)]
endfunction

function GetPlayerColorStringById takes integer playerId returns string    
    return StartString + PlayerColor[playerId]
endfunction

private function OnColorChange takes player whichplayer, playercolor color returns nothing
    set PlayerColor[GetPlayerId(whichplayer)] = PlayerColorString[GetHandleId(color)]
endfunction

hook SetPlayerColor OnColorChange

private function Init takes nothing returns nothing
    local integer i = 0
    loop
        set Players<i> = Player(i)
        set i = i + 1
        exitwhen i == 12
    endloop
    
    set PlayerColorString[0] = &quot;00ff0202&quot;
    set PlayerColorString[1] = &quot;000041ff&quot;
    set PlayerColorString[2] = &quot;001be5b8&quot;
    set PlayerColorString[3] = &quot;00530080&quot;
    set PlayerColorString[4] = &quot;00fffc00&quot;
    set PlayerColorString[5] = &quot;00fe890d&quot;
    set PlayerColorString[6] = &quot;001fbf00&quot;
    set PlayerColorString[7] = &quot;00e45aaf&quot;
    set PlayerColorString[8] = &quot;00949596&quot;
    set PlayerColorString[9] = &quot;007dbef1&quot;
    set PlayerColorString[10] = &quot;000f6145&quot;
    set PlayerColorString[11] = &quot;004d2903&quot;
    
    set i = 0
    loop
        set PlayerColor<i> = PlayerColorString<i>
        set i = i + 1
        exitwhen i == 12
    endloop
    
endfunction

endlibrary</i></i></i>
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • 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
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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