Snippet String2PlayerColoredString

Blaaargh.
JASS:
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
    //NO NO NO NO NO.
endfunction</i></i></i>


JASS:
private function Init takes nothing returns nothing
    local integer i = 11

    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;

    loop
        exitwhen i &lt; 0
        set Players<i> = Player(i)
        set PlayerColor<i> = PlayerColorString<i>
        set i = i - 1
    endloop
    
endfunction</i></i></i>
 
Nice :D
Yet again... SILLY ME ! XD

Ok then... Is this correct ? :eek:
(Please say, YES ! XD)

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 = 11

    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;

    loop
        exitwhen i &lt; 0
        set Players<i> = Player(i)
        set PlayerColor<i> = PlayerColorString<i>
        set i = i - 1
    endloop
    
endfunction

endlibrary</i></i></i>
 
You should just manually put |c on all the strings and get rid of the concatenation. Save time and memory.
 
Get rid of StartString completely.
JASS:
set PlayerColorString[0] = &quot;00ff0202&quot;
set PlayerColorString[1] = &quot;000041ff&quot;
set PlayerColorString[2] = &quot;001be5b8&quot;

->
JASS:
set PlayerColorString[0] = &quot;|c00ff0202&quot;
set PlayerColorString[1] = &quot;|c000041ff&quot;
set PlayerColorString[2] = &quot;|c001be5b8&quot;
 
Ok, changed ;)

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;
endglobals

function PlayerColoredString takes string s, integer playerId returns string
    return PlayerColor[playerId] + s + EndString
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)]
endfunction

hook SetPlayerColor OnColorChange

private function Init takes nothing returns nothing
    local integer i = 11

    set PlayerColorString[0] = &quot;|c00ff0202&quot;
    set PlayerColorString[1] = &quot;|c000041ff&quot;
    set PlayerColorString[2] = &quot;|c001be5b8&quot;
    set PlayerColorString[3] = &quot;|c00530080&quot;
    set PlayerColorString[4] = &quot;|c00fffc00&quot;
    set PlayerColorString[5] = &quot;|c00fe890d&quot;
    set PlayerColorString[6] = &quot;|c001fbf00&quot;
    set PlayerColorString[7] = &quot;|c00e45aaf&quot;
    set PlayerColorString[8] = &quot;|c00949596&quot;
    set PlayerColorString[9] = &quot;|c007dbef1&quot;
    set PlayerColorString[10] = &quot;|c000f6145&quot;
    set PlayerColorString[11] = &quot;|c004d2903&quot;

    loop
        exitwhen i &lt; 0
        set Players<i> = Player(i)
        set PlayerColor<i> = PlayerColorString<i>
        set i = i - 1
    endloop
    
endfunction

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


Btw... Any ideas on what else this snippet/system could do ? :S
I'm out of imagination, and need ideas for more features :D
 
It seems to be perfect, except for one final thing...
[ljass]function PlayerColoredString takes string s, integer playerId returns string[/ljass]
Switch the arguments around, and that function will be inlined.
 
Done :D

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;
endglobals

function PlayerColoredString takes integer playerId, string s returns string
    return PlayerColor[playerId] + s + EndString
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)]
endfunction

hook SetPlayerColor OnColorChange

private function Init takes nothing returns nothing
    local integer i = 11

    set PlayerColorString[0] = &quot;|c00ff0202&quot;
    set PlayerColorString[1] = &quot;|c000041ff&quot;
    set PlayerColorString[2] = &quot;|c001be5b8&quot;
    set PlayerColorString[3] = &quot;|c00530080&quot;
    set PlayerColorString[4] = &quot;|c00fffc00&quot;
    set PlayerColorString[5] = &quot;|c00fe890d&quot;
    set PlayerColorString[6] = &quot;|c001fbf00&quot;
    set PlayerColorString[7] = &quot;|c00e45aaf&quot;
    set PlayerColorString[8] = &quot;|c00949596&quot;
    set PlayerColorString[9] = &quot;|c007dbef1&quot;
    set PlayerColorString[10] = &quot;|c000f6145&quot;
    set PlayerColorString[11] = &quot;|c004d2903&quot;

    loop
        exitwhen i &lt; 0
        set Players<i> = Player(i)
        set PlayerColor<i> = PlayerColorString<i>
        set i = i - 1
    endloop
    
endfunction

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


Anything else ? :S
 
Ahh. This is perhaps more efficient than any other player color string snippet out there, and this one works correctly when players switch colors. And now, I take my leave of you.

Though, you may want to set initial colors appropriately on MapInit, using GetHandleId. I don't know if hooks get the calls inside functions created by the World Editor.
 
Like this ? :S

JASS:
private function Init takes nothing returns nothing
    local integer i = 11

    set PlayerColorString[0] = &quot;|c00ff0202&quot;
    set PlayerColorString[1] = &quot;|c000041ff&quot;
    set PlayerColorString[2] = &quot;|c001be5b8&quot;
    set PlayerColorString[3] = &quot;|c00530080&quot;
    set PlayerColorString[4] = &quot;|c00fffc00&quot;
    set PlayerColorString[5] = &quot;|c00fe890d&quot;
    set PlayerColorString[6] = &quot;|c001fbf00&quot;
    set PlayerColorString[7] = &quot;|c00e45aaf&quot;
    set PlayerColorString[8] = &quot;|c00949596&quot;
    set PlayerColorString[9] = &quot;|c007dbef1&quot;
    set PlayerColorString[10] = &quot;|c000f6145&quot;
    set PlayerColorString[11] = &quot;|c004d2903&quot;

    loop
        exitwhen i &lt; 0
        set Players<i> = Player(i)
        set PlayerColor<i> = PlayerColorString[GetHandleId(GetPlayerColor(Players<i>))]
        set i = i - 1
    endloop
    
endfunction</i></i></i>
 
Ok then :D Thanks ! ;)

So now, any suggestions for more features for it ? :eek:
 
BUMP ...

Is there no other features you want this system/snippet to contain ? :(
 
You should really update the first post with the latest and greatest version.
 
Yeah, wonder why I haven't done that... :S

Will do now ! ;)
Thanks :D
 
Fixing time. This is looking good. :thup:
JASS:
loop
    set PlayerColor<i> = PlayerColorString[GetHandleId(GetPlayerColor(Player(i)))]
    exitwhen i == 0
    set i = i - 1
endloop</i>

Steal please. Get rid of Players array (??).
This won't work for Neutral Passive/Neutral Hostile, etc. Please fix for all 0-15 players (16 players). :thup:
Requires: vJASS compiler (JassHelper, which is included in JASS Newgen Pack)
Untrue - this requires an updated JassHelper, the one that comes with NewGen will not compile this as it uses hooks.

And in regards to your "credits" section, pretty sure I had to explicitly teach you how to use hooks and more or less tell you what to write. Not that I care much, but you said no one really helped... so at least remove that, if not thank. ;)

Edit: Hate to say it but this will probably get graveyarded, as this was released long ago...
 
Steal please. Get rid of Players array (??).

Shouldn't I use it there, instead ? :S

This won't work for Neutral Passive/Neutral Hostile, etc. Please fix for all 0-15 players (16 players).

Will do ! ;)

Untrue - this requires an updated JassHelper, the one that comes with NewGen will not compile this as it uses hooks.

Which version is it that gives you the ability to "Hook" ? :S

And in regards to your "credits" section, pretty sure I had to explicitly teach you how to use hooks and more or less tell you what to write. Not that I care much, but you said no one really helped... so at least remove that, if not thank.

Changed now ! :D
Forgot to update that XD (Sorry, you've been very helpful, believe me ! ;)

Edit: Hate to say it but this will probably get graveyarded, as this was released long ago...

Yeah, I also almost "know" that, but I'll atleast try to do as much with this as I can, until it get graveyarded, because I'm learning alot !!! :D
 
>Shouldn't I use it there, instead ? :S
What for?

You could get the tiniest of efficiency gains, Darthfett, by saving all the players to a player array.

?

>Which version is it that gives you the ability to "Hook" ? :S
The latest (the actual version where it was added isn't really relevant, point is the user must update JassHelper). :thup:

Ok :D Thanks ! ;)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    Or even third party. Like if you don't have an original one in a functional condition, you cannot play this game properly. Like yeah the keyboard mods exist, but I think those are BARELY functional
  • Varine Varine:
    And since almost all of my programming experience is with defunct shit now, I figure my best place is helping preserve legacy stuff. Which I don't know how to do necessarily, but I need some kind of a hobby and figuring out how older things worked is the only shit that really interests me. Well soldering and restoration is fun too, but no one is bringing me new stuff to fix and restore, so it's mostly old shit, and I LOVE OG Xbox so much. I want to make sure it can function as long as possible, until someone can effectively emulate it at least. I have like 15 I was going to fix over the winter and didn't get to.
    +1
  • Varine Varine:
    I also have a couple OG gameboys, but idk if I can do that without like, manufacturing new parts that no one makes anymore and I can't do that right now
  • tom_mai78101 tom_mai78101:
    Currently in the middle of getting the probate process going. We're doing the informal probate process.
    +3
  • Varine Varine:
    A probate is usually done with a will, yes? If so I am sorry for your loss
    +1
  • The Helper The Helper:
    Yeah Tom, me too sorry for your loss buddy my mom told me she finds out her olds friend died from Google searching them. She had not talked to one of her old friends in a year and found out she died from Google. Also another one in the same session. RIP all of them my sincere condolences Tom
    +1
  • Varine Varine:
    We have some elderly guests that regularly come hang out at the bar at the end of the night, and every once in a while we don't see someone for a few weeks and then someone shows up with their obituary.
  • Varine Varine:
    We usually let them do their memorials there in the morning if they want to and I'll make them some snacks and drinks. There was one guy named Tom that came in like every night and would sit by himself and get a bunch of soup and a glass of wine. idk why but he LOVED our fucking soup, like he would order a fucking quart of it at a time and would always get so sad when we stop doing it for the summer.
    +1
  • Varine Varine:
    But he also loved our calamari, which is another thing I hate but it sells super well so I can't change it. There was one day he came in and was asking me how to make it, because he tried to at home once in the off season when we stop running it and he really wanted it lol
  • Varine Varine:
    I think he's one of the only people I've made recipes for for free because he really wanted a broccoli cheddar, and it was like dude I don't have a recipe, it's just whatever I have, but here, this is how you do it
  • Varine Varine:
    I don't think he ever figured out how to do the calamari in a pan though, like idk how to do that either. He was afraid of the at home deep fryers though and it's like yeah, that's fair, I am too
  • Varine Varine:
    He was just such a sweet old man, we had two servers pregnant and they held a baby shower together, he was soooooo fucking excited to get to see a baby. Unfortunately he died a month or so before they were born
  • The Helper The Helper:
    So I decided to Google some people that I had not seen or heard from in a while and sure enough one of my old best friends, we had a falling out years ago but whatever, find out he died of Pancreatic Cancer in January. I have also lost a few of my closer acquaintances from growing up the last year. Getting old - people die - I kinda thought it was going to be this way a few years ago....
    +2
  • The Helper The Helper:
    Forum running super slow again
  • Ghan Ghan:
    Not really clear from the stats as to what is causing the slowness.
  • Ghan Ghan:
    We get a lot of guest traffic so it may just be the load is getting too high and not from any particular source.
  • Ghan Ghan:
    Looks like the server is maxed out on CPU.
  • Ghan Ghan:
    Oh it looks like a lot of the traffic is Silkroad Forums. That domain isn't protected by Cloudflare.
  • Ghan Ghan:
    But the old Silkroad site is still on its own server. I just had a test site set up on this server for it.
  • Ghan Ghan:
    I just disabled that test site. Let's see if that helps the load.
  • Ghan Ghan:
    Looks much better already.
  • The Helper The Helper:
    I had actually forgot about the Silkroad site. I had asked
  • The Helper The Helper:
    SD Ryoko about it and he said the couple of people left on there really like it, that was a few years ago, maybe I should check back
  • jonas jonas:
    I guess when you're getting old, and the last day of soup season draws near, you start wondering
  • jonas jonas:
    will I make it to the start of the next season? or was this the last time I'll ever have my favorite dish?

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top