Snippet String2PlayerColoredString

tooltiperror

Super Moderator
Reaction score
231
JASS:
            //call SavePlayerHandle( StoredColors, 1, StringHash( PlayerColorWordString[ i ] ) / 20000000 + 96, Player( i ) )
            
            set StoredPlayers[ StringHash( PlayerColorWordString[ i ] ) / 20000000 + 96 ] = Player( i )
            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
        
        //call SavePlayerHandle( StoredColors, 1, StringHash( PlayerColorWordString[ 13 ] ) / 20000000 + 96, Player( 8 ) )
        //call SavePlayerHandle( StoredColors, 1, StringHash( PlayerColorWordString[ 14 ] ) / 20000000 + 96, Player( 2 ) )
        //call SavePlayerHandle( StoredColors, 1, StringHash( PlayerColorWordString[ 15 ] ) / 20000000 + 96, Player( 2 ) )
        //call SavePlayerHandle( StoredColors, 1, StringHash( PlayerColorWordString[ 16 ] ) / 20000000 + 96, Player( 12 ) )
        //call SavePlayerHandle( StoredColors, 1, StringHash( PlayerColorWordString[ 17 ] ) / 20000000 + 96, Player( 12 ) )
</i>


Why the comments?
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Oh, it's just some stuff I had when it was using hashtables...
Will be removed soon :p
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Ok, well this is my weak point... :(

I'm incredibly bad at writing a good documentation :S

Is there any chance anyone else would care to do it for me :eek: :D

I'd greatly appreciate it, and of course you'll be in the credits ;)
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
I'm incredibly bad at writing a good documentation :S

It's not an incredibly complicated process, just a bit tedious.

A good start would be to copy all the publicly available functions/variables, and paste them in a comment block.

Then, simply add a description below each function/variable with what it does. Try to be concise, but don't leave out anything important about what it returns. Thing such as
JASS:
 //WARNING: If you put an invalid player as an argument, in any of the functions, it WILL return Player( 0 ), or Player &quot;Red&quot;!
should be mentioned beneath each function description.

Last, if it is needed, give a general statement of the purpose of the system. Make sure to include a relevant example or two. You can take a look at any of my string/cmd Libraries if you want to see what my current standard for my own documentation is.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Would this be an ok documentation ? :eek:
JASS:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//***************************************************************************************************************************//
//@@/////////////////////////////////// *//PlayerColorUtils\\* ////////////////////////////////////////////////////////////@@//
//@@                                                                                                                       @@//
//@@                                                                                                                       @@//
//@@                 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                         @@//
//@@                 %%                                                         %%                                         @@//
//@@                 %%    //\\\\\               /////////  ///          \\\    %%                                         @@//
//@@                 %%    //\\   \\\        //////         ///          \\\    %%                                         @@//
//@@                 %%    //\\     \\\     /////           ///          \\\    %%                                         @@//
//@@                 %%    //\\     ///   ////              ///          \\\    %%                                         @@//
//@@                 %%    //\\   ///    ////               ///          \\\    %%                                         @@//
//@@                 %%    //\\///      ////                ///          \\\    %%                                         @@//
//@@                 %%    //\\         \\\\                ////        \\\\    %%                                         @@//
//@@                 %%    //\\          \\\\               ////        \\\\    %%                                         @@//
//@@                 %%    //\\           \\\\              ////        \\\\    %%                                         @@//
//@@                 %%    //\\             \\\\\            ////      \\\\     %%                                         @@//
//@@                 %%    //\\               \\\\\\          ////    \\\\      %%                                         @@//
//@@                 %%    //\\                  \\\\\\\\\       ///\\\         %%                                         @@//
//@@                 %%                                                         %%                                         @@//
//@@                 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                         @@//
//@@                                                                                                                       @@//
//@@                                                                                                                       @@//
//@@                                                                                                                       @@//
//@@                                                                                                                       @@//
//@@                                   Made by , Komaqtion                                                                 @@//
//@@                                                                                                                       @@//
//@@                                                                                                                       @@//
//@@                                        Purpose:                                                                       @@//
//@@                                                                                                                       @@//
//@@             ¤ This snippet is supposed to help people to, with ease, to use playercolors                              @@//
//@@               in all aspects they&#039;d possibly want.                                                                    @@//
//@@                                                                                                                       @@//
//@@                                         Usage:                                                                        @@//
//@@                                                                                                                       @@//
//@@             ¤ The function provided by this small system is:                                                          @@//
//@@               *NOTE* If you input an invalid player in any of the functions, it&#039;ll automatically work                 @@//
//@@               as if you inputted Player( 0 ), or Player (Red)...                                                      @@//
//@@                                                                                                                       @@//
//@@      function PlayerColoredString takes player p, string s returns string                                             @@//
//@@                                                                                                                       @@//
//@@               &quot;player p&quot; -&gt; The player of which you want to use the color for the                                     @@//
//@@               inputted string.                                                                                        @@//
//@@               &quot;string coloredString&quot; -&gt; The string which is to be returned                                            @@//
//@@               in the wanted playercolor.                                                                              @@//
//@@               &quot;returns string&quot; -&gt; This function will return the inputted string,                                      @@//
//@@               but in the playercolor of the player with the inputted playerid.                                        @@//
//@@               *NOTE* If                                                                                               @@//
//@@                                                                                                                       @@//
//@@                                                                                                                       @@//
//@@      function PlayerColoredStringById takes integer playerId, string s returns string                                 @@//
//@@                                                                                                                       @@//
//@@               &quot;integer playerId&quot; -&gt; The player-number of the player&#039;s color                                           @@//
//@@               you wish to use.                                                                                        @@//
//@@               &quot;string coloredString&quot; -&gt; The string which is to be returned                                            @@//
//@@               in the wanted playercolor.                                                                              @@//
//@@               &quot;returns string&quot; -&gt; This function will return the inputted string,                                      @@//
//@@               but in the playercolor of the player with the inputted playerid.                                        @@//
//@@                                                                                                                       @@//
//@@      function PlayerColoredTextTag takes texttag coloredTag, player p, integer alpha returns nothing                  @@//
//@@                                                                                                                       @@//
//@@               &quot;texttag coloredTag&quot; -&gt; The texttag of which the color is to be changed.                                @@//
//@@               &quot;player p&quot; -&gt; The player of which color the texttag is to be changed to.                                @@//
//@@               &quot;integer alpha&quot; -&gt; The amount of transparency the text (texttag) should have.                           @@//
//@@               /\ THIS RANGES FROM 0 TO 255, WITH 255 BEING 100% SEETHROUGH ! /\                                       @@//
//@@               &quot;returns nothing&quot; -&gt; This function will not return anything, as it just modifies                        @@//
//@@               the existing texttag, and can&#039;t be used in any variable or so.                                          @@//
//@@                                                                                                                       @@//
//@@      function PlayerColoredTextTagById takes texttag coloredTag, integer playerId, integer alpha returns nothing      @@//
//@@                                                                                                                       @@//
//@@               &quot;texttag coloredTag&quot; -&gt; The texttag of which the color is to be changed.                                @@//
//@@               &quot;integer playerId&quot; -&gt; The playerid of the player of which color the texttag                             @@//
//@@               is to be changed to.                                                                                    @@//
//@@               &quot;integer alpha&quot; -&gt; The amount of transparency the text (texttag) should have.                           @@//
//@@               /\ THIS RANGES FROM 0 TO 255, WITH 255 BEING 100% SEETHROUGH ! /\                                       @@//
//@@               &quot;returns nothing&quot; -&gt; This function will not return anything, as it just modifies                        @@//
//@@               the existing texttag, and can&#039;t be used in any variable or so.                                          @@//
//@@                                                                                                                       @@//
//@@      function GetPlayerColorString takes player p returns string                                                      @@//
//@@                                                                                                                       @@//
//@@               &quot;player p&quot; -&gt; The player we will be getting the &quot;color-code&quot; of.                                        @@//
//@@               &quot;returns string&quot; -&gt; This function will return the actual ARGB code (Not the system,                     @@//
//@@               but the hex-code).                                                                                      @@//
//@@                                                                                                                       @@//
//@@      function GetPlayerColorStringById takes integer playerId returns string                                          @@//
//@@                                                                                                                       @@//
//@@               &quot;integer playerId&quot; -&gt; The id of the player we will be getting the &quot;color-code&quot; of.                      @@//
//@@               &quot;returns string&quot; -&gt; This function will return the actual ARGB code (Not the system,                     @@//
//@@               but the hex-code).                                                                                      @@//
//@@                                                                                                                       @@//
//@@      function GetPlayerByColor takes string color returns player                                                      @@//
//@@                                                                                                                       @@//
//@@               &quot;string color&quot; -&gt; This is where you put the color of the player you want to get (E.g &quot;blue&quot;)            @@//
//@@               &quot;returns player&quot; -&gt; As said, this is the player who has the color you inputted.                         @@//
//@@                                                                                                                       @@//
//@@      function GetPlayerColorStringByColor takes string color returns string                                           @@//
//@@                                                                                                                       @@//
//@@               &quot;string color&quot; -&gt; This is the player&#039;s color of which you want to get it&#039;s &quot;color-code&quot; (Or hex-code)   @@//
//@@               &quot;returns string&quot; -&gt; This is the hex-code of the color the player uses (E.g &quot;|c00ff0202&quot;)                @@//
//@@                                                                                                                       @@//
//@@      That is it ! <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" /> Hope you&#039;ve understood all the functions clearly now !                                           @@//
//@@      If not, then just post in the thread and I&#039;ll update this documentation <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />                                       @@//
//@@                                                                                                                       @@//
//@@                                                                                                                       @@//
//@@                                    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 helping 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 &quot;GetPlayerByColor&quot; 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" />                                         @@//
//@@               Darthfett, for giving me some pointers on this documentation <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=";)" />                                                                           @@//
//@@                                                                                                                       @@//
//@@///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////@@//
//***************************************************************************************************************************//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 

Jesus4Lyf

Good Idea™
Reaction score
397
It's too wide. Will be difficult to read on many screens.
JASS:

//@@               &quot;returns string&quot; -&gt; This function will return the inputted string,                                      @@//
//@@               but in the playercolor of the player with the inputted playerid.                                        @@//
//@@               *NOTE* If                                                                                               @@//
//@@                                                                                                                       @@//

"If" noted..

In the Credits you only have a ¤ for the first entry. I would like to see these used a lot more, ie. before each parameter in your function documentation. Makes it easier to skim.
 

Weep

Godspeed to the sound of the pounding
Reaction score
401
In the Credits you only have a ¤ for the first entry. I would like to see these used a lot more
I'd like to request the substitution of a different character instead of ¤ at all, because when I tried to copy one of Komaqtion's systems into a text file for use with [ljass]//! import[/ljass], jEdit threw an error about an incompatibility with the character set.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
It's too wide. Will be difficult to read on many screens.

But some functions take up that much space... How should I narrow it off ? :S

In the Credits you only have a ¤ for the first entry. I would like to see these used a lot more, ie. before each parameter in your function documentation. Makes it easier to skim.

What lines do you think I should add it too ? :S

I'd like to request the substitution of a different character instead of ¤ at all, because when I tried to copy one of Komaqtion's systems into a text file for use with //! import, jEdit threw an error about an incompatibility with the character set.

Sure XD is "#" ok ? :S

JASS:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//***************************************************************************************************************************//
//@@/////////////////////////////////// *//PlayerColorUtils\\* ////////////////////////////////////////////////////////////@@//
//@@                                                                                                                       @@//
//@@                                                                                                                       @@//
//@@                 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                         @@//
//@@                 %%                                                         %%                                         @@//
//@@                 %%    //\\\\\               /////////  ///          \\\    %%                                         @@//
//@@                 %%    //\\   \\\        //////         ///          \\\    %%                                         @@//
//@@                 %%    //\\     \\\     /////           ///          \\\    %%                                         @@//
//@@                 %%    //\\     ///   ////              ///          \\\    %%                                         @@//
//@@                 %%    //\\   ///    ////               ///          \\\    %%                                         @@//
//@@                 %%    //\\///      ////                ///          \\\    %%                                         @@//
//@@                 %%    //\\         \\\\                ////        \\\\    %%                                         @@//
//@@                 %%    //\\          \\\\               ////        \\\\    %%                                         @@//
//@@                 %%    //\\           \\\\              ////        \\\\    %%                                         @@//
//@@                 %%    //\\             \\\\\            ////      \\\\     %%                                         @@//
//@@                 %%    //\\               \\\\\\          ////    \\\\      %%                                         @@//
//@@                 %%    //\\                  \\\\\\\\\       ///\\\         %%                                         @@//
//@@                 %%                                                         %%                                         @@//
//@@                 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                         @@//
//@@                                                                                                                       @@//
//@@                                                                                                                       @@//
//@@                                                                                                                       @@//
//@@                                                                                                                       @@//
//@@                                   Made by , Komaqtion                                                                 @@//
//@@                                                                                                                       @@//
//@@                                                                                                                       @@//
//@@                                        Purpose:                                                                       @@//
//@@                                                                                                                       @@//
//@@             # This snippet is supposed to help people to, with ease, to use playercolors                              @@//
//@@               in all aspects they&#039;d possibly want.                                                                    @@//
//@@                                                                                                                       @@//
//@@                                         Usage:                                                                        @@//
//@@                                                                                                                       @@//
//@@             # The function provided by this small system is:                                                          @@//
//@@               *NOTE* If you input an invalid player in any of the functions, it&#039;ll automatically work                 @@//
//@@               as if you inputted Player( 0 ), or Player (Red)...                                                      @@//
//@@                                                                                                                       @@//
//@@      function PlayerColoredString takes player p, string s returns string                                             @@//
//@@                                                                                                                       @@//
//@@               &quot;player p&quot; -&gt; The player of which you want to use the color for the                                     @@//
//@@               inputted string.                                                                                        @@//
//@@               &quot;string coloredString&quot; -&gt; The string which is to be returned                                            @@//
//@@               in the wanted playercolor.                                                                              @@//
//@@               &quot;returns string&quot; -&gt; This function will return the inputted string,                                      @@//
//@@               but in the playercolor of the player with the inputted playerid.                                        @@//
//@@                                                                                                                       @@//
//@@      function PlayerColoredStringById takes integer playerId, string s returns string                                 @@//
//@@                                                                                                                       @@//
//@@               &quot;integer playerId&quot; -&gt; The player-number of the player&#039;s color                                           @@//
//@@               you wish to use.                                                                                        @@//
//@@               &quot;string coloredString&quot; -&gt; The string which is to be returned                                            @@//
//@@               in the wanted playercolor.                                                                              @@//
//@@               &quot;returns string&quot; -&gt; This function will return the inputted string,                                      @@//
//@@               but in the playercolor of the player with the inputted playerid.                                        @@//
//@@                                                                                                                       @@//
//@@      function PlayerColoredTextTag takes texttag coloredTag, player p, integer alpha returns nothing                  @@//
//@@                                                                                                                       @@//
//@@               &quot;texttag coloredTag&quot; -&gt; The texttag of which the color is to be changed.                                @@//
//@@               &quot;player p&quot; -&gt; The player of which color the texttag is to be changed to.                                @@//
//@@               &quot;integer alpha&quot; -&gt; The amount of transparency the text (texttag) should have.                           @@//
//@@               /\ THIS RANGES FROM 0 TO 255, WITH 255 BEING 100% SEETHROUGH ! /\                                       @@//
//@@               &quot;returns nothing&quot; -&gt; This function will not return anything, as it just modifies                        @@//
//@@               the existing texttag, and can&#039;t be used in any variable or so.                                          @@//
//@@                                                                                                                       @@//
//@@      function PlayerColoredTextTagById takes texttag coloredTag, integer playerId, integer alpha returns nothing      @@//
//@@                                                                                                                       @@//
//@@               &quot;texttag coloredTag&quot; -&gt; The texttag of which the color is to be changed.                                @@//
//@@               &quot;integer playerId&quot; -&gt; The playerid of the player of which color the texttag                             @@//
//@@               is to be changed to.                                                                                    @@//
//@@               &quot;integer alpha&quot; -&gt; The amount of transparency the text (texttag) should have.                           @@//
//@@               /\ THIS RANGES FROM 0 TO 255, WITH 255 BEING 100% SEETHROUGH ! /\                                       @@//
//@@               &quot;returns nothing&quot; -&gt; This function will not return anything, as it just modifies                        @@//
//@@               the existing texttag, and can&#039;t be used in any variable or so.                                          @@//
//@@                                                                                                                       @@//
//@@      function GetPlayerColorString takes player p returns string                                                      @@//
//@@                                                                                                                       @@//
//@@               &quot;player p&quot; -&gt; The player we will be getting the &quot;color-code&quot; of.                                        @@//
//@@               &quot;returns string&quot; -&gt; This function will return the actual ARGB code (Not the system,                     @@//
//@@               but the hex-code).                                                                                      @@//
//@@                                                                                                                       @@//
//@@      function GetPlayerColorStringById takes integer playerId returns string                                          @@//
//@@                                                                                                                       @@//
//@@               &quot;integer playerId&quot; -&gt; The id of the player we will be getting the &quot;color-code&quot; of.                      @@//
//@@               &quot;returns string&quot; -&gt; This function will return the actual ARGB code (Not the system,                     @@//
//@@               but the hex-code).                                                                                      @@//
//@@                                                                                                                       @@//
//@@      function GetPlayerByColor takes string color returns player                                                      @@//
//@@                                                                                                                       @@//
//@@               &quot;string color&quot; -&gt; This is where you put the color of the player you want to get (E.g &quot;blue&quot;)            @@//
//@@               &quot;returns player&quot; -&gt; As said, this is the player who has the color you inputted.                         @@//
//@@                                                                                                                       @@//
//@@      function GetPlayerColorStringByColor takes string color returns string                                           @@//
//@@                                                                                                                       @@//
//@@               &quot;string color&quot; -&gt; This is the player&#039;s color of which you want to get it&#039;s &quot;color-code&quot; (Or hex-code)   @@//
//@@               &quot;returns string&quot; -&gt; This is the hex-code of the color the player uses (E.g &quot;|c00ff0202&quot;)                @@//
//@@                                                                                                                       @@//
//@@             # That is it ! <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" /> Hope you&#039;ve understood all the functions clearly now !                                  @@//
//@@               If not, then just post in the thread and I&#039;ll update this documentation <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />                              @@//
//@@                                                                                                                       @@//
//@@                                                                                                                       @@//
//@@                                    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 helping 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 &quot;GetPlayerByColor&quot; 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" />                                         @@//
//@@               Darthfett, for giving me some pointers on this documentation <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=";)" />                                                                           @@//
//@@                                                                                                                       @@//
//@@///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////@@//
//***************************************************************************************************************************//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Bit better ? (Except the narrowing part :p)
 

Jesus4Lyf

Good Idea™
Reaction score
397
An example of everything I was talking about from Damage:
JASS:
//          function Damage_Physical takes unit source, unit target, real amount,
//            attacktype whichType, boolean attack, boolean ranged returns boolean
//              - A clean wrapper for physical damage.
//              - &#039;attack&#039; determines if this is to be treated as a real physical
//                attack or just physical type damage.
//              - &#039;ranged&#039; determines if this is to be treated as a ranged or melee
//                attack.

I'm not saying the above is perfect, but...
- Using new lines is effective if a line is too long.
- Prefixing parameter explanations with a - (or # apparently in your case, which I think is ugly).

Still, this is approvable, almost..
JASS:
StringHash( StringCase( color, false ) )

I thought that StringHash was case-insensitive anyway. When we can either confirm that, and adjust the code, or confirm it is not true, I think this will get approved...

I'd like to personally test your hash adjustment algorithm for clashes or optimisation, but personally I don't have time.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Using new lines is effective if a line is too long.

Yeah, but I think it's kinda ugly if you do it with functions in a documentation XD

Prefixing parameter explanations with a - (or # apparently in your case, which I think is ugly).

I'll use '#' for the major "headlines" and '-' for those other stuff then ;)

I thought that StringHash was case-insensitive anyway. When we can either confirm that, and adjust the code, or confirm it is not true, I think this will get approved...

I'll confirm it :D (Just hash two or the same string, one with upper case, and one with lower case, and see if it produces the same integer right ? :S XD)
 

Jesus4Lyf

Good Idea™
Reaction score
397
Yeah, but I think it's kinda ugly if you do it with functions in a documentation XD
Find a way, because I really think a line which you have to scroll sideways to read in documentation is horrible.
I'll confirm it :D (Just hash two or the same string, one with upper case, and one with lower case, and see if it produces the same integer right ? :S XD)
Yep. And if they're the same, remove those manual lower-case functions. :)
 

Komaqtion

You can change this now in User CP.
Reaction score
469
JASS:
library PlayerColors initializer Init


/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*********************************************************************************************************//
//@@/////////////////////////////////// *//PlayerColorUtils\\* //////////////////////////////////////////@@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                      @@//
//@@                  %%                                                         %%                      @@//
//@@                  %%    //\\\\\               /////////  ///          \\\    %%                      @@//
//@@                  %%    //\\   \\\        //////         ///          \\\    %%                      @@//
//@@                  %%    //\\     \\\     /////           ///          \\\    %%                      @@//
//@@                  %%    //\\     ///   ////              ///          \\\    %%                      @@//
//@@                  %%    //\\   ///    ////               ///          \\\    %%                      @@//
//@@                  %%    //\\///      ////                ///          \\\    %%                      @@//
//@@                  %%    //\\         \\\\                ////        \\\\    %%                      @@//
//@@                  %%    //\\          \\\\               ////        \\\\    %%                      @@//
//@@                  %%    //\\           \\\\              ////        \\\\    %%                      @@//
//@@                  %%    //\\             \\\\\            ////      \\\\     %%                      @@//
//@@                  %%    //\\               \\\\\\          ////    \\\\      %%                      @@//
//@@                  %%    //\\                  \\\\\\\\\       ///\\\         %%                      @@//
//@@                  %%                                                         %%                      @@//
//@@                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                      @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                     Made by , Komaqtion                                             @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                         Purpose:                                                    @@//
//@@                                                                                                     @@//
//@@         # This snippet is supposed to help people to, with ease, to use playercolors                @@//
//@@           in all aspects they&#039;d possibly want.                                                      @@//
//@@                                                                                                     @@//
//@@                                         Usage:                                                      @@//
//@@                                                                                                     @@//
//@@         # The function provided by this small system is:                                            @@//
//@@           *NOTE* If you input an invalid player in any of the functions, it&#039;ll                      @@//
//@@           automatically work as if you inputted Player( 0 ), or Player (Red)...                     @@//
//@@                                                                                                     @@//
//@@      function PlayerColoredString takes player p, string s returns string                           @@//
//@@                                                                                                     @@//
//@@               - &quot;player p&quot; -&gt; The player of which you want to use the color for the                 @@//
//@@               inputted string.                                                                      @@//
//@@               - &quot;string coloredString&quot; -&gt; The string which is to be returned                        @@//
//@@               in the wanted playercolor.                                                            @@//
//@@               - &quot;returns string&quot; -&gt; This function will return the inputted string,                  @@//
//@@               but in the playercolor of the player with the inputted playerid.                      @@//
//@@                                                                                                     @@//
//@@      function PlayerColoredStringById takes integer playerId, string s returns string               @@//
//@@                                                                                                     @@//
//@@               - &quot;integer playerId&quot; -&gt; The player-number of the player&#039;s color                       @@//
//@@               you wish to use.                                                                      @@//
//@@               - &quot;string coloredString&quot; -&gt; The string which is to be returned                        @@//
//@@               in the wanted playercolor.                                                            @@//
//@@               - &quot;returns string&quot; -&gt; This function will return the inputted string,                  @@//
//@@               but in the playercolor of the player with the inputted playerid.                      @@//
//@@                                                                                                     @@//
//@@      function PlayerColoredTextTag takes texttag coloredTag,                                        @@//
//@@               player p, integer alpha returns nothing                                               @@//
//@@                                                                                                     @@//
//@@               - &quot;texttag coloredTag&quot; -&gt; The texttag of which the color is to be changed.            @@//
//@@               - &quot;player p&quot; -&gt; The player of which color the texttag is to be changed to.            @@//
//@@               - &quot;integer alpha&quot; -&gt; The amount of transparency the text (texttag) should have.       @@//
//@@               /\ THIS RANGES FROM 0 TO 255, WITH 255 BEING 100% SEETHROUGH ! /\                     @@//
//@@               - &quot;returns nothing&quot; -&gt; This function will not return anything, as it just             @@//
//@@               modifies the existing texttag, and can&#039;t be used in any variable or so.               @@//
//@@                                                                                                     @@//
//@@      function PlayerColoredTextTagById takes texttag coloredTag,                                    @@//
//@@               integer playerId, integer alpha returns nothing                                       @@//
//@@                                                                                                     @@//
//@@               - &quot;texttag coloredTag&quot; -&gt; The texttag of which the color is to be changed.            @@//
//@@               - &quot;integer playerId&quot; -&gt; The playerid of the player of which color the texttag         @@//
//@@               is to be changed to.                                                                  @@//
//@@               - &quot;integer alpha&quot; -&gt; The amount of transparency the text (texttag) should have.       @@//
//@@               /\ THIS RANGES FROM 0 TO 255, WITH 255 BEING 100% SEETHROUGH ! /\                     @@//
//@@               - &quot;returns nothing&quot; -&gt; This function will not return anything, as it just             @@//
//@@               modifies the existing texttag, and can&#039;t be used in any variable or so.               @@//
//@@                                                                                                     @@//
//@@      function GetPlayerColorString takes player p returns string                                    @@//
//@@                                                                                                     @@//
//@@               - &quot;player p&quot; -&gt; The player we will be getting the &quot;color-code&quot; of.                    @@//
//@@               - &quot;returns string&quot; -&gt; This function will return the actual ARGB code                  @@//
//@@               (Not the system, but the hex-code).                                                   @@//
//@@                                                                                                     @@//
//@@      function GetPlayerColorStringById takes integer playerId returns string                        @@//
//@@                                                                                                     @@//
//@@               - &quot;integer playerId&quot; -&gt; The id of the player we will be getting                       @@//
//@@               the &quot;color-code&quot; of.                                                                  @@//
//@@               - &quot;returns string&quot; -&gt; This function will return the actual ARGB code                  @@//
//@@               (Not the system, but the hex-code).                                                   @@//
//@@                                                                                                     @@//
//@@      function GetPlayerByColor takes string color returns player                                    @@//
//@@                                                                                                     @@//
//@@               - &quot;string color&quot; -&gt; This is where you put the color of the player                     @@//
//@@                you want to get (E.g &quot;blue&quot;)                                                         @@//
//@@               - &quot;returns player&quot; -&gt; As said, this is the player who has                             @@//
//@@               the color you inputted.                                                               @@//
//@@                                                                                                     @@//
//@@      function GetPlayerColorStringByColor takes string color returns string                         @@//
//@@                                                                                                     @@//
//@@               - &quot;string color&quot; -&gt; This is the player&#039;s color of which you                           @@//
//@@               want to get it&#039;s &quot;color-code&quot; (Or hex-code)                                           @@//
//@@               - &quot;returns string&quot; -&gt; This is the hex-code of the color the                           @@//
//@@               player uses (E.g &quot;|c00ff0202&quot;)                                                        @@//
//@@                                                                                                     @@//
//@@               - That is it ! <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" /> Hope you&#039;ve understood all the functions clearly now !              @@//
//@@               If not, then just post in the thread and I&#039;ll update this documentation <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />            @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                    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 helping 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 &quot;GetPlayerByColor&quot; 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" />                     @@//
//@@               - Darthfett, for giving me some pointers on this documentation <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=";)" />                                                         @@//
//@@                                                                                                     @@//
//@@/////////////////////////////////////////////////////////////////////////////////////////////////////@@//
//*********************************************************************************************************//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////


// Configuration, though it isn&#039;t much <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />

    globals
        private constant string EndString = &quot;|r&quot;     // This actually shouldn&#039;t be changeable XD
                                                     // But I made it so anyways <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
    endglobals

// End of Configuration !!!! DON&#039;T TOUCH BELOW THIS !!!!!
// End of Configuration !!!! DON&#039;T TOUCH BELOW THIS !!!!!
// End of Configuration !!!! DON&#039;T TOUCH BELOW THIS !!!!!
// End of Configuration !!!! DON&#039;T TOUCH BELOW THIS !!!!!

    globals
        private integer array Red                      // This is used to keep track of the &quot;redness&quot; in each player&#039;s the hex-codes
        private integer array Green                    // This is used to keep track of the &quot;greenness&quot; in each player&#039;s the hex-codes
        private integer array Blue                     // This is used to keep track of the &quot;blueness&quot; in each player&#039;s the hex-codes
        private integer array RedString                // And this is the the &quot;redness&quot; in all hex-codes <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" />
        private integer array GreenString              // And this is the the &quot;greenness&quot; in all hex-codes <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" />
        private integer array BlueString               // And this is the the &quot;blueness&quot; in all hex-codes <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" />
        
        private string array PlayerColor               // This is used to keep track of which player-color is used by which player <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" />
        private string array PlayerColorString         // And this is the same thing, but not bound to a player <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
        private string array PlayerColorWord           // This is used to keep track of which player-color-string (Like &quot;red&quot;, or &quot;teal&quot;) is used by which player <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" />
        private string array PlayerColorWordString     // And, yet again, this is the same thing, but not bound to a player <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
        
        private player array StoredPlayers
    endglobals
    
    function PlayerColoredStringById takes integer playerId, string coloredString returns string
        return PlayerColor[playerId] + coloredString + EndString
    endfunction
    
    function PlayerColoredString takes player p, string coloredString returns string
        return PlayerColor[GetPlayerId( p )] + coloredString + EndString
    endfunction
    
    function PlayerColoredTextTag takes texttag coloredTag, player p, integer alpha returns nothing
        local integer id
        
        if p != null then // We don&#039;t want to use a &#039;null&#039; player, do we ? <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite9" alt=":eek:" title="Eek!    :eek:" loading="lazy" data-shortname=":eek:" />
            set id = GetPlayerId( p ) // Gets the id of the inputted player
            call SetTextTagColor( coloredTag, Red[id], Green[id], Blue[id], alpha ) // Setting the color of the used texttag to the specified player&#039;s color
        endif

    endfunction
    
    function PlayerColoredTextTagById takes texttag coloredTag, integer playerId, integer alpha returns nothing
        call SetTextTagColor( coloredTag, Red[playerId], Green[playerId], Blue[playerId], alpha ) // Simply sets the color of the texttag to the wanted player&#039;s one <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
    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 GetPlayerByColor takes string color returns player
        return StoredPlayers[ StringHash( color ) / 20000000 + 96 ]
    endfunction
    
    function GetPlayerColorStringByColor takes string color returns string
        return PlayerColor[ GetPlayerId( StoredPlayers[ StringHash( color ) / 20000000 + 96 ] ) ]
    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]
        set StoredPlayers[ StringHash( PlayerColorWordString[ pc ] ) / 20000000 + 96 ] = whichPlayer
    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 PlayerColorWordString[0] = &quot;red&quot;
        
        set PlayerColorString[1] = &quot;|c000041ff&quot;
        set RedString[1] = 0x00
        set GreenString[1] = 0x41
        set BlueString[1] = 0xff
        set PlayerColorWordString[1] = &quot;blue&quot;
        
        set PlayerColorString[2] = &quot;|c001be5b8&quot;
        set RedString[2] = 0x1b
        set GreenString[2] = 0xe5
        set BlueString[2] = 0xb8
        set PlayerColorWordString[2] = &quot;teal&quot;
        
        set PlayerColorString[3] = &quot;|c00530080&quot;
        set RedString[3] = 0x53
        set GreenString[3] = 0x00
        set BlueString[3] = 0x80
        set PlayerColorWordString[3] = &quot;purple&quot;
        
        set PlayerColorString[4] = &quot;|c00fffc00&quot;
        set RedString[4] = 0xff
        set GreenString[4] = 0xfc
        set BlueString[4] = 0x00
        set PlayerColorWordString[4] = &quot;yellow&quot;
        
        set PlayerColorString[5] = &quot;|c00fe890d&quot;
        set RedString[5] = 0xfe
        set GreenString[5] = 0x89
        set BlueString[5] = 0x0d
        set PlayerColorWordString[5] = &quot;orange&quot;
        
        set PlayerColorString[6] = &quot;|c001fbf00&quot;
        set RedString[6] = 0x1f
        set GreenString[6] = 0xbf
        set BlueString[6] = 0x00
        set PlayerColorWordString[6] = &quot;green&quot;
        
        set PlayerColorString[7] = &quot;|c00e45aaf&quot;
        set RedString[7] = 0xe4
        set GreenString[7] = 0x5a
        set BlueString[7] = 0xaf
        set PlayerColorWordString[7] = &quot;pink&quot;
        
        set PlayerColorString[8] = &quot;|c00949596&quot;
        set RedString[8] = 0x94
        set GreenString[8] = 0x95
        set BlueString[8] = 0x96
        set PlayerColorWordString[8] = &quot;grey&quot;
        
        set PlayerColorString[9] = &quot;|c007dbef1&quot;
        set RedString[9] = 0x7d
        set GreenString[9] = 0xbe
        set BlueString[9] = 0xf1
        set PlayerColorWordString[9] = &quot;lightblue&quot;
        
        set PlayerColorString[10] = &quot;|c000f6145&quot;
        set RedString[10] = 0x0f
        set GreenString[10] = 0x61
        set BlueString[10] = 0x45
        set PlayerColorWordString[10] = &quot;darkgreen&quot;
        
        set PlayerColorString[11] = &quot;|c004d2903&quot;
        set RedString[11] = 0x4d
        set GreenString[11] = 0x29
        set BlueString[11] = 0x03
        set PlayerColorWordString[11] = &quot;brown&quot;

        set PlayerColorString[12] = &quot;|c00272727&quot;
        set RedString[12] = 0x27
        set GreenString[12] = 0x27
        set BlueString[12] = 0x27
        set PlayerColorWordString[12] = &quot;darkgrey&quot;
        
        set PlayerColorWordString[13] = &quot;gray&quot;
        set PlayerColorWordString[14] = &quot;aqua&quot;
        set PlayerColorWordString[15] = &quot;cyan&quot;
        set PlayerColorWordString[16] = &quot;darkgray&quot;
        set PlayerColorWordString[17] = &quot;neutral&quot;
    
        loop
            exitwhen i &lt; 0   
            
            set StoredPlayers[ StringHash( PlayerColorWordString[ i ] ) / 20000000 + 96 ] = Player( i )
            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
        
        set StoredPlayers[ StringHash( PlayerColorWordString[ 13 ] ) / 20000000 + 96 ] = Player( 8 )
        set StoredPlayers[ StringHash( PlayerColorWordString[ 14 ] ) / 20000000 + 96 ] = Player( 2 )
        set StoredPlayers[ StringHash( PlayerColorWordString[ 15 ] ) / 20000000 + 96 ] = Player( 2 )
        set StoredPlayers[ StringHash( PlayerColorWordString[ 16 ] ) / 20000000 + 96 ] = Player( 12 )
        set StoredPlayers[ StringHash( PlayerColorWordString[ 17 ] ) / 20000000 + 96 ] = Player( 12 )
    endfunction
    
endlibrary</i>
 

Komaqtion

You can change this now in User CP.
Reaction score
469
JASS:
library PlayerColors initializer Init


/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*********************************************************************************************************//
//@@/////////////////////////////////// *//PlayerColorUtils\\* //////////////////////////////////////////@@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                      @@//
//@@                  %%                                                         %%                      @@//
//@@                  %%    //\\\\\               /////////  ///          \\\    %%                      @@//
//@@                  %%    //\\   \\\        //////         ///          \\\    %%                      @@//
//@@                  %%    //\\     \\\     /////           ///          \\\    %%                      @@//
//@@                  %%    //\\     ///   ////              ///          \\\    %%                      @@//
//@@                  %%    //\\   ///    ////               ///          \\\    %%                      @@//
//@@                  %%    //\\///      ////                ///          \\\    %%                      @@//
//@@                  %%    //\\         \\\\                ////        \\\\    %%                      @@//
//@@                  %%    //\\          \\\\               ////        \\\\    %%                      @@//
//@@                  %%    //\\           \\\\              ////        \\\\    %%                      @@//
//@@                  %%    //\\             \\\\\            ////      \\\\     %%                      @@//
//@@                  %%    //\\               \\\\\\          ////    \\\\      %%                      @@//
//@@                  %%    //\\                  \\\\\\\\\       ///\\\         %%                      @@//
//@@                  %%                                                         %%                      @@//
//@@                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                      @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                     Made by , Komaqtion                                             @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                         Purpose:                                                    @@//
//@@                                                                                                     @@//
//@@         # This snippet is supposed to help people to, with ease, to use playercolors                @@//
//@@           in all aspects they&#039;d possibly want.                                                      @@//
//@@                                                                                                     @@//
//@@                                         Usage:                                                      @@//
//@@                                                                                                     @@//
//@@         # The function provided by this small system is:                                            @@//
//@@           *NOTE* If you input an invalid player in any of the functions, it&#039;ll                      @@//
//@@           automatically work as if you inputted Player( 0 ), or Player (Red)...                     @@//
//@@                                                                                                     @@//
//@@      function PlayerColoredString takes player p, string s returns string                           @@//
//@@                                                                                                     @@//
//@@               - &quot;player p&quot; -&gt; The player of which you want to use the color for the                 @@//
//@@               inputted string.                                                                      @@//
//@@               - &quot;string coloredString&quot; -&gt; The string which is to be returned                        @@//
//@@               in the wanted playercolor.                                                            @@//
//@@               - &quot;returns string&quot; -&gt; This function will return the inputted string,                  @@//
//@@               but in the playercolor of the player with the inputted playerid.                      @@//
//@@                                                                                                     @@//
//@@      function PlayerColoredStringById takes integer playerId, string s returns string               @@//
//@@                                                                                                     @@//
//@@               - &quot;integer playerId&quot; -&gt; The player-number of the player&#039;s color                       @@//
//@@               you wish to use.                                                                      @@//
//@@               - &quot;string coloredString&quot; -&gt; The string which is to be returned                        @@//
//@@               in the wanted playercolor.                                                            @@//
//@@               - &quot;returns string&quot; -&gt; This function will return the inputted string,                  @@//
//@@               but in the playercolor of the player with the inputted playerid.                      @@//
//@@                                                                                                     @@//
//@@      function PlayerColoredTextTag takes texttag coloredTag,                                        @@//
//@@               player p, integer alpha returns nothing                                               @@//
//@@                                                                                                     @@//
//@@               - &quot;texttag coloredTag&quot; -&gt; The texttag of which the color is to be changed.            @@//
//@@               - &quot;player p&quot; -&gt; The player of which color the texttag is to be changed to.            @@//
//@@               - &quot;integer alpha&quot; -&gt; The amount of transparency the text (texttag) should have.       @@//
//@@               /\ THIS RANGES FROM 0 TO 255, WITH 255 BEING 100% SEETHROUGH ! /\                     @@//
//@@               - &quot;returns nothing&quot; -&gt; This function will not return anything, as it just             @@//
//@@               modifies the existing texttag, and can&#039;t be used in any variable or so.               @@//
//@@                                                                                                     @@//
//@@      function PlayerColoredTextTagById takes texttag coloredTag,                                    @@//
//@@               integer playerId, integer alpha returns nothing                                       @@//
//@@                                                                                                     @@//
//@@               - &quot;texttag coloredTag&quot; -&gt; The texttag of which the color is to be changed.            @@//
//@@               - &quot;integer playerId&quot; -&gt; The playerid of the player of which color the texttag         @@//
//@@               is to be changed to.                                                                  @@//
//@@               - &quot;integer alpha&quot; -&gt; The amount of transparency the text (texttag) should have.       @@//
//@@               /\ THIS RANGES FROM 0 TO 255, WITH 255 BEING 100% SEETHROUGH ! /\                     @@//
//@@               - &quot;returns nothing&quot; -&gt; This function will not return anything, as it just             @@//
//@@               modifies the existing texttag, and can&#039;t be used in any variable or so.               @@//
//@@                                                                                                     @@//
//@@      function GetPlayerColorString takes player p returns string                                    @@//
//@@                                                                                                     @@//
//@@               - &quot;player p&quot; -&gt; The player we will be getting the &quot;color-code&quot; of.                    @@//
//@@               - &quot;returns string&quot; -&gt; This function will return the actual ARGB code                  @@//
//@@               (Not the system, but the hex-code).                                                   @@//
//@@                                                                                                     @@//
//@@      function GetPlayerColorStringById takes integer playerId returns string                        @@//
//@@                                                                                                     @@//
//@@               - &quot;integer playerId&quot; -&gt; The id of the player we will be getting                       @@//
//@@               the &quot;color-code&quot; of.                                                                  @@//
//@@               - &quot;returns string&quot; -&gt; This function will return the actual ARGB code                  @@//
//@@               (Not the system, but the hex-code).                                                   @@//
//@@                                                                                                     @@//
//@@      function GetPlayerByColor takes string color returns player                                    @@//
//@@                                                                                                     @@//
//@@               - &quot;string color&quot; -&gt; This is where you put the color of the player                     @@//
//@@                you want to get (E.g &quot;blue&quot;)                                                         @@//
//@@               - &quot;returns player&quot; -&gt; As said, this is the player who has                             @@//
//@@               the color you inputted.                                                               @@//
//@@                                                                                                     @@//
//@@      function GetPlayerColorStringByColor takes string color returns string                         @@//
//@@                                                                                                     @@//
//@@               - &quot;string color&quot; -&gt; This is the player&#039;s color of which you                           @@//
//@@               want to get it&#039;s &quot;color-code&quot; (Or hex-code)                                           @@//
//@@               - &quot;returns string&quot; -&gt; This is the hex-code of the color the                           @@//
//@@               player uses (E.g &quot;|c00ff0202&quot;)                                                        @@//
//@@                                                                                                     @@//
//@@               - That is it ! <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" /> Hope you&#039;ve understood all the functions clearly now !              @@//
//@@               If not, then just post in the thread and I&#039;ll update this documentation <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />            @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                    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 helping 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 &quot;GetPlayerByColor&quot; 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" />                     @@//
//@@               - Darthfett, for giving me some pointers on this documentation <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=";)" />                                                         @@//
//@@                                                                                                     @@//
//@@/////////////////////////////////////////////////////////////////////////////////////////////////////@@//
//*********************************************************************************************************//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////


// Configuration, though it isn&#039;t much <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />

    globals
        private constant string EndString = &quot;|r&quot;     // This actually shouldn&#039;t be changeable XD
                                                     // But I made it so anyways <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
    endglobals

// End of Configuration !!!! DON&#039;T TOUCH BELOW THIS !!!!!
// End of Configuration !!!! DON&#039;T TOUCH BELOW THIS !!!!!
// End of Configuration !!!! DON&#039;T TOUCH BELOW THIS !!!!!
// End of Configuration !!!! DON&#039;T TOUCH BELOW THIS !!!!!

    globals
        private integer array Red                      // This is used to keep track of the &quot;redness&quot; in each player&#039;s the hex-codes
        private integer array Green                    // This is used to keep track of the &quot;greenness&quot; in each player&#039;s the hex-codes
        private integer array Blue                     // This is used to keep track of the &quot;blueness&quot; in each player&#039;s the hex-codes
        private integer array RedString                // And this is the the &quot;redness&quot; in all hex-codes <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" />
        private integer array GreenString              // And this is the the &quot;greenness&quot; in all hex-codes <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" />
        private integer array BlueString               // And this is the the &quot;blueness&quot; in all hex-codes <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" />
        
        private string array PlayerColor               // This is used to keep track of which player-color is used by which player <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" />
        private string array PlayerColorString         // And this is the same thing, but not bound to a player <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
        private string array PlayerColorWord           // This is used to keep track of which player-color-string (Like &quot;red&quot;, or &quot;teal&quot;) is used by which player <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" />
        private string array PlayerColorWordString     // And, yet again, this is the same thing, but not bound to a player <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
        
        private player array StoredPlayers
    endglobals
    
    function PlayerColoredStringById takes integer playerId, string coloredString returns string
        return PlayerColor[playerId] + coloredString + EndString
    endfunction
    
    function PlayerColoredString takes player p, string coloredString returns string
        return PlayerColor[GetPlayerId( p )] + coloredString + EndString
    endfunction
    
    function PlayerColoredTextTag takes texttag coloredTag, player p, integer alpha returns nothing
        local integer id
        
        if p != null then // We don&#039;t want to use a &#039;null&#039; player, do we ? <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite9" alt=":eek:" title="Eek!    :eek:" loading="lazy" data-shortname=":eek:" />
            set id = GetPlayerId( p ) // Gets the id of the inputted player
            call SetTextTagColor( coloredTag, Red[id], Green[id], Blue[id], alpha ) // Setting the color of the used texttag to the specified player&#039;s color
        endif

    endfunction
    
    function PlayerColoredTextTagById takes texttag coloredTag, integer playerId, integer alpha returns nothing
        call SetTextTagColor( coloredTag, Red[playerId], Green[playerId], Blue[playerId], alpha ) // Simply sets the color of the texttag to the wanted player&#039;s one <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
    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 GetPlayerByColor takes string color returns player
        return StoredPlayers[ StringHash( color ) / 20000000 + 96 ]
    endfunction
    
    function GetPlayerColorStringByColor takes string color returns string
        return PlayerColor[ GetPlayerId( StoredPlayers[ StringHash( color ) / 20000000 + 96 ] ) ]
    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]
        set StoredPlayers[ StringHash( PlayerColorWordString[ pc ] ) / 20000000 + 96 ] = whichPlayer
    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 PlayerColorWordString[0] = &quot;red&quot;
        
        set PlayerColorString[1] = &quot;|c000041ff&quot;
        set RedString[1] = 0x00
        set GreenString[1] = 0x41
        set BlueString[1] = 0xff
        set PlayerColorWordString[1] = &quot;blue&quot;
        
        set PlayerColorString[2] = &quot;|c001be5b8&quot;
        set RedString[2] = 0x1b
        set GreenString[2] = 0xe5
        set BlueString[2] = 0xb8
        set PlayerColorWordString[2] = &quot;teal&quot;
        
        set PlayerColorString[3] = &quot;|c00530080&quot;
        set RedString[3] = 0x53
        set GreenString[3] = 0x00
        set BlueString[3] = 0x80
        set PlayerColorWordString[3] = &quot;purple&quot;
        
        set PlayerColorString[4] = &quot;|c00fffc00&quot;
        set RedString[4] = 0xff
        set GreenString[4] = 0xfc
        set BlueString[4] = 0x00
        set PlayerColorWordString[4] = &quot;yellow&quot;
        
        set PlayerColorString[5] = &quot;|c00fe890d&quot;
        set RedString[5] = 0xfe
        set GreenString[5] = 0x89
        set BlueString[5] = 0x0d
        set PlayerColorWordString[5] = &quot;orange&quot;
        
        set PlayerColorString[6] = &quot;|c001fbf00&quot;
        set RedString[6] = 0x1f
        set GreenString[6] = 0xbf
        set BlueString[6] = 0x00
        set PlayerColorWordString[6] = &quot;green&quot;
        
        set PlayerColorString[7] = &quot;|c00e45aaf&quot;
        set RedString[7] = 0xe4
        set GreenString[7] = 0x5a
        set BlueString[7] = 0xaf
        set PlayerColorWordString[7] = &quot;pink&quot;
        
        set PlayerColorString[8] = &quot;|c00949596&quot;
        set RedString[8] = 0x94
        set GreenString[8] = 0x95
        set BlueString[8] = 0x96
        set PlayerColorWordString[8] = &quot;grey&quot;
        
        set PlayerColorString[9] = &quot;|c007dbef1&quot;
        set RedString[9] = 0x7d
        set GreenString[9] = 0xbe
        set BlueString[9] = 0xf1
        set PlayerColorWordString[9] = &quot;lightblue&quot;
        
        set PlayerColorString[10] = &quot;|c000f6145&quot;
        set RedString[10] = 0x0f
        set GreenString[10] = 0x61
        set BlueString[10] = 0x45
        set PlayerColorWordString[10] = &quot;darkgreen&quot;
        
        set PlayerColorString[11] = &quot;|c004d2903&quot;
        set RedString[11] = 0x4d
        set GreenString[11] = 0x29
        set BlueString[11] = 0x03
        set PlayerColorWordString[11] = &quot;brown&quot;

        set PlayerColorString[12] = &quot;|c00272727&quot;
        set RedString[12] = 0x27
        set GreenString[12] = 0x27
        set BlueString[12] = 0x27
        set PlayerColorWordString[12] = &quot;darkgrey&quot;
        
        set PlayerColorWordString[13] = &quot;gray&quot;
        set PlayerColorWordString[14] = &quot;aqua&quot;
        set PlayerColorWordString[15] = &quot;cyan&quot;
        set PlayerColorWordString[16] = &quot;darkgray&quot;
        set PlayerColorWordString[17] = &quot;neutral&quot;
    
        loop
            exitwhen i &lt; 0   
            
            set StoredPlayers[ StringHash( PlayerColorWordString[ i ] ) / 20000000 + 96 ] = Player( i )
            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
        
        set StoredPlayers[ StringHash( PlayerColorWordString[ 13 ] ) / 20000000 + 96 ] = Player( 8 )
        set StoredPlayers[ StringHash( PlayerColorWordString[ 14 ] ) / 20000000 + 96 ] = Player( 2 )
        set StoredPlayers[ StringHash( PlayerColorWordString[ 15 ] ) / 20000000 + 96 ] = Player( 2 )
        set StoredPlayers[ StringHash( PlayerColorWordString[ 16 ] ) / 20000000 + 96 ] = Player( 12 )
        set StoredPlayers[ StringHash( PlayerColorWordString[ 17 ] ) / 20000000 + 96 ] = Player( 12 )
    endfunction
    
endlibrary</i>


You can at least see all of the text of the documentation now XD

Is it enough ? :eek:
 

Komaqtion

You can change this now in User CP.
Reaction score
469
A small update here...

Added another function, [ljass]GetPlayerNameColored( player p ) -> string[/ljass] :D
This will get you the player's name, in it's color too :D

JASS:
library PlayerColors initializer Init


/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*********************************************************************************************************//
//@@/////////////////////////////////// *//PlayerColorUtils\\* //////////////////////////////////////////@@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                      @@//
//@@                  %%                                                         %%                      @@//
//@@                  %%    //\\\\\               /////////  ///          \\\    %%                      @@//
//@@                  %%    //\\   \\\        //////         ///          \\\    %%                      @@//
//@@                  %%    //\\     \\\     /////           ///          \\\    %%                      @@//
//@@                  %%    //\\     ///   ////              ///          \\\    %%                      @@//
//@@                  %%    //\\   ///    ////               ///          \\\    %%                      @@//
//@@                  %%    //\\///      ////                ///          \\\    %%                      @@//
//@@                  %%    //\\         \\\\                ////        \\\\    %%                      @@//
//@@                  %%    //\\          \\\\               ////        \\\\    %%                      @@//
//@@                  %%    //\\           \\\\              ////        \\\\    %%                      @@//
//@@                  %%    //\\             \\\\\            ////      \\\\     %%                      @@//
//@@                  %%    //\\               \\\\\\          ////    \\\\      %%                      @@//
//@@                  %%    //\\                  \\\\\\\\\       ///\\\         %%                      @@//
//@@                  %%                                                         %%                      @@//
//@@                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                      @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                     Made by , Komaqtion                                             @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                         Purpose:                                                    @@//
//@@                                                                                                     @@//
//@@         # This snippet is supposed to help people to, with ease, to use playercolors                @@//
//@@           in all aspects they&#039;d possibly want.                                                      @@//
//@@                                                                                                     @@//
//@@                                         Usage:                                                      @@//
//@@                                                                                                     @@//
//@@         # The function provided by this small system is:                                            @@//
//@@           *NOTE* If you input an invalid player in any of the functions, it&#039;ll                      @@//
//@@           automatically work as if you inputted Player( 0 ), or Player (Red)...                     @@//
//@@                                                                                                     @@//
//@@      function PlayerColoredString takes player p, string s returns string                           @@//
//@@                                                                                                     @@//
//@@               - &quot;player p&quot; -&gt; The player of which you want to use the color for the                 @@//
//@@               inputted string.                                                                      @@//
//@@               - &quot;string coloredString&quot; -&gt; The string which is to be returned                        @@//
//@@               in the wanted playercolor.                                                            @@//
//@@               - &quot;returns string&quot; -&gt; This function will return the inputted string,                  @@//
//@@               but in the playercolor of the player with the inputted playerid.                      @@//
//@@                                                                                                     @@//
//@@      function PlayerColoredStringById takes integer playerId, string s returns string               @@//
//@@                                                                                                     @@//
//@@               - &quot;integer playerId&quot; -&gt; The player-number of the player&#039;s color                       @@//
//@@               you wish to use.                                                                      @@//
//@@               - &quot;string coloredString&quot; -&gt; The string which is to be returned                        @@//
//@@               in the wanted playercolor.                                                            @@//
//@@               - &quot;returns string&quot; -&gt; This function will return the inputted string,                  @@//
//@@               but in the playercolor of the player with the inputted playerid.                      @@//
//@@                                                                                                     @@//
//@@      function GetPlayerNameColored takes player p returns string                                    @@//
//@@                                                                                                     @@//
//@@               - &quot;player p&quot; -&gt; The player of which you want to use the color for the                 @@//
//@@               inputted string. (And also the name <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />)                                               @@//
//@@               - &quot;returns string&quot; -&gt; This function will return the player&#039;s name you                 @@//
//@@               inputted, but in the playercolor of that player.                                      @@//
//@@                                                                                                     @@//
//@@      function PlayerColoredTextTag takes texttag coloredTag,                                        @@//
//@@               player p, integer alpha returns nothing                                               @@//
//@@                                                                                                     @@//
//@@               - &quot;texttag coloredTag&quot; -&gt; The texttag of which the color is to be changed.            @@//
//@@               - &quot;player p&quot; -&gt; The player of which color the texttag is to be changed to.            @@//
//@@               - &quot;integer alpha&quot; -&gt; The amount of transparency the text (texttag) should have.       @@//
//@@               /\ THIS RANGES FROM 0 TO 255, WITH 255 BEING 100% SEETHROUGH ! /\                     @@//
//@@               - &quot;returns nothing&quot; -&gt; This function will not return anything, as it just             @@//
//@@               modifies the existing texttag, and can&#039;t be used in any variable or so.               @@//
//@@                                                                                                     @@//
//@@      function PlayerColoredTextTagById takes texttag coloredTag,                                    @@//
//@@               integer playerId, integer alpha returns nothing                                       @@//
//@@                                                                                                     @@//
//@@               - &quot;texttag coloredTag&quot; -&gt; The texttag of which the color is to be changed.            @@//
//@@               - &quot;integer playerId&quot; -&gt; The playerid of the player of which color the texttag         @@//
//@@               is to be changed to.                                                                  @@//
//@@               - &quot;integer alpha&quot; -&gt; The amount of transparency the text (texttag) should have.       @@//
//@@               /\ THIS RANGES FROM 0 TO 255, WITH 255 BEING 100% SEETHROUGH ! /\                     @@//
//@@               - &quot;returns nothing&quot; -&gt; This function will not return anything, as it just             @@//
//@@               modifies the existing texttag, and can&#039;t be used in any variable or so.               @@//
//@@                                                                                                     @@//
//@@      function GetPlayerColorString takes player p returns string                                    @@//
//@@                                                                                                     @@//
//@@               - &quot;player p&quot; -&gt; The player we will be getting the &quot;color-code&quot; of.                    @@//
//@@               - &quot;returns string&quot; -&gt; This function will return the actual ARGB code                  @@//
//@@               (Not the system, but the hex-code).                                                   @@//
//@@                                                                                                     @@//
//@@      function GetPlayerColorStringById takes integer playerId returns string                        @@//
//@@                                                                                                     @@//
//@@               - &quot;integer playerId&quot; -&gt; The id of the player we will be getting                       @@//
//@@               the &quot;color-code&quot; of.                                                                  @@//
//@@               - &quot;returns string&quot; -&gt; This function will return the actual ARGB code                  @@//
//@@               (Not the system, but the hex-code).                                                   @@//
//@@                                                                                                     @@//
//@@      function GetPlayerByColor takes string color returns player                                    @@//
//@@                                                                                                     @@//
//@@               - &quot;string color&quot; -&gt; This is where you put the color of the player                     @@//
//@@                you want to get (E.g &quot;blue&quot;)                                                         @@//
//@@               - &quot;returns player&quot; -&gt; As said, this is the player who has                             @@//
//@@               the color you inputted.                                                               @@//
//@@                                                                                                     @@//
//@@      function GetPlayerColorStringByColor takes string color returns string                         @@//
//@@                                                                                                     @@//
//@@               - &quot;string color&quot; -&gt; This is the player&#039;s color of which you                           @@//
//@@               want to get it&#039;s &quot;color-code&quot; (Or hex-code)                                           @@//
//@@               - &quot;returns string&quot; -&gt; This is the hex-code of the color the                           @@//
//@@               player uses (E.g &quot;|c00ff0202&quot;)                                                        @@//
//@@                                                                                                     @@//
//@@               - That is it ! <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" /> Hope you&#039;ve understood all the functions clearly now !              @@//
//@@               If not, then just post in the thread and I&#039;ll update this documentation <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />            @@//
//@@                                                                                                     @@//
//@@                                                                                                     @@//
//@@                                    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 helping 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 &quot;GetPlayerByColor&quot; 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" />                     @@//
//@@               - Darthfett, for giving me some pointers on this documentation <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=";)" />                                                         @@//
//@@                                                                                                     @@//
//@@/////////////////////////////////////////////////////////////////////////////////////////////////////@@//
//*********************************************************************************************************//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////


// Configuration, though it isn&#039;t much <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />

    globals
        private constant string EndString = &quot;|r&quot;     // This actually shouldn&#039;t be changeable XD
                                                     // But I made it so anyways <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
    endglobals

// End of Configuration !!!! DON&#039;T TOUCH BELOW THIS !!!!!
// End of Configuration !!!! DON&#039;T TOUCH BELOW THIS !!!!!
// End of Configuration !!!! DON&#039;T TOUCH BELOW THIS !!!!!
// End of Configuration !!!! DON&#039;T TOUCH BELOW THIS !!!!!

    globals
        private integer array Red                      // This is used to keep track of the &quot;redness&quot; in each player&#039;s the hex-codes
        private integer array Green                    // This is used to keep track of the &quot;greenness&quot; in each player&#039;s the hex-codes
        private integer array Blue                     // This is used to keep track of the &quot;blueness&quot; in each player&#039;s the hex-codes
        private integer array RedString                // And this is the the &quot;redness&quot; in all hex-codes <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" />
        private integer array GreenString              // And this is the the &quot;greenness&quot; in all hex-codes <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" />
        private integer array BlueString               // And this is the the &quot;blueness&quot; in all hex-codes <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" />
        
        private string array PlayerColor               // This is used to keep track of which player-color is used by which player <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" />
        private string array PlayerColorString         // And this is the same thing, but not bound to a player <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
        private string array PlayerColorWord           // This is used to keep track of which player-color-string (Like &quot;red&quot;, or &quot;teal&quot;) is used by which player <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" />
        private string array PlayerColorWordString     // And, yet again, this is the same thing, but not bound to a player <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
        
        private player array StoredPlayers
    endglobals
    
    function PlayerColoredStringById takes integer playerId, string coloredString returns string
        return PlayerColor[playerId] + coloredString + EndString
    endfunction
    
    function PlayerColoredString takes player p, string coloredString returns string
        return PlayerColor[GetPlayerId( p )] + coloredString + EndString
    endfunction
    
    function GetPlayerNameColored takes player p returns string
        return PlayerColor[GetPlayerId( p )] + GetPlayerName( p ) + EndString
    endfunction
    
    function PlayerColoredTextTag takes texttag coloredTag, player p, integer alpha returns nothing
        local integer id
        
        if p != null then // We don&#039;t want to use a &#039;null&#039; player, do we ? <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite9" alt=":eek:" title="Eek!    :eek:" loading="lazy" data-shortname=":eek:" />
            set id = GetPlayerId( p ) // Gets the id of the inputted player
            call SetTextTagColor( coloredTag, Red[id], Green[id], Blue[id], alpha ) // Setting the color of the used texttag to the specified player&#039;s color
        endif

    endfunction
    
    function PlayerColoredTextTagById takes texttag coloredTag, integer playerId, integer alpha returns nothing
        call SetTextTagColor( coloredTag, Red[playerId], Green[playerId], Blue[playerId], alpha ) // Simply sets the color of the texttag to the wanted player&#039;s one <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
    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 GetPlayerByColor takes string color returns player
        return StoredPlayers[ StringHash( color ) / 20000000 + 96 ]
    endfunction
    
    function GetPlayerColorStringByColor takes string color returns string
        return PlayerColor[ GetPlayerId( StoredPlayers[ StringHash( color ) / 20000000 + 96 ] ) ]
    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]
        set StoredPlayers[ StringHash( PlayerColorWordString[ pc ] ) / 20000000 + 96 ] = whichPlayer
    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 PlayerColorWordString[0] = &quot;red&quot;
        
        set PlayerColorString[1] = &quot;|c000041ff&quot;
        set RedString[1] = 0x00
        set GreenString[1] = 0x41
        set BlueString[1] = 0xff
        set PlayerColorWordString[1] = &quot;blue&quot;
        
        set PlayerColorString[2] = &quot;|c001be5b8&quot;
        set RedString[2] = 0x1b
        set GreenString[2] = 0xe5
        set BlueString[2] = 0xb8
        set PlayerColorWordString[2] = &quot;teal&quot;
        
        set PlayerColorString[3] = &quot;|c00530080&quot;
        set RedString[3] = 0x53
        set GreenString[3] = 0x00
        set BlueString[3] = 0x80
        set PlayerColorWordString[3] = &quot;purple&quot;
        
        set PlayerColorString[4] = &quot;|c00fffc00&quot;
        set RedString[4] = 0xff
        set GreenString[4] = 0xfc
        set BlueString[4] = 0x00
        set PlayerColorWordString[4] = &quot;yellow&quot;
        
        set PlayerColorString[5] = &quot;|c00fe890d&quot;
        set RedString[5] = 0xfe
        set GreenString[5] = 0x89
        set BlueString[5] = 0x0d
        set PlayerColorWordString[5] = &quot;orange&quot;
        
        set PlayerColorString[6] = &quot;|c001fbf00&quot;
        set RedString[6] = 0x1f
        set GreenString[6] = 0xbf
        set BlueString[6] = 0x00
        set PlayerColorWordString[6] = &quot;green&quot;
        
        set PlayerColorString[7] = &quot;|c00e45aaf&quot;
        set RedString[7] = 0xe4
        set GreenString[7] = 0x5a
        set BlueString[7] = 0xaf
        set PlayerColorWordString[7] = &quot;pink&quot;
        
        set PlayerColorString[8] = &quot;|c00949596&quot;
        set RedString[8] = 0x94
        set GreenString[8] = 0x95
        set BlueString[8] = 0x96
        set PlayerColorWordString[8] = &quot;grey&quot;
        
        set PlayerColorString[9] = &quot;|c007dbef1&quot;
        set RedString[9] = 0x7d
        set GreenString[9] = 0xbe
        set BlueString[9] = 0xf1
        set PlayerColorWordString[9] = &quot;lightblue&quot;
        
        set PlayerColorString[10] = &quot;|c000f6145&quot;
        set RedString[10] = 0x0f
        set GreenString[10] = 0x61
        set BlueString[10] = 0x45
        set PlayerColorWordString[10] = &quot;darkgreen&quot;
        
        set PlayerColorString[11] = &quot;|c004d2903&quot;
        set RedString[11] = 0x4d
        set GreenString[11] = 0x29
        set BlueString[11] = 0x03
        set PlayerColorWordString[11] = &quot;brown&quot;

        set PlayerColorString[12] = &quot;|c00272727&quot;
        set RedString[12] = 0x27
        set GreenString[12] = 0x27
        set BlueString[12] = 0x27
        set PlayerColorWordString[12] = &quot;darkgrey&quot;
        
        set PlayerColorWordString[13] = &quot;gray&quot;
        set PlayerColorWordString[14] = &quot;aqua&quot;
        set PlayerColorWordString[15] = &quot;cyan&quot;
        set PlayerColorWordString[16] = &quot;darkgray&quot;
        set PlayerColorWordString[17] = &quot;neutral&quot;
    
        loop
            exitwhen i &lt; 0   
            
            set StoredPlayers[ StringHash( PlayerColorWordString[ i ] ) / 20000000 + 96 ] = Player( i )
            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
        
        set StoredPlayers[ StringHash( PlayerColorWordString[ 13 ] ) / 20000000 + 96 ] = Player( 8 )
        set StoredPlayers[ StringHash( PlayerColorWordString[ 14 ] ) / 20000000 + 96 ] = Player( 2 )
        set StoredPlayers[ StringHash( PlayerColorWordString[ 15 ] ) / 20000000 + 96 ] = Player( 2 )
        set StoredPlayers[ StringHash( PlayerColorWordString[ 16 ] ) / 20000000 + 96 ] = Player( 12 )
        set StoredPlayers[ StringHash( PlayerColorWordString[ 17 ] ) / 20000000 + 96 ] = Player( 12 )
    endfunction
    
endlibrary</i>
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Bump...

C'mon guys, this REALLY is getting ridiculus from your side, as I've basically just done as you've said this entire time, and it's been well optimized and is quite (If not VERY) usefull...

Feel like I'm being ignored with my thread again here :(
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
"This snippet is supposed to help people to, with ease, to use playercolors"
I thought playercolor was a type. I can't see any of the functions take or return it so whatgives?

JASS:
function PlayerColoredString takes player p, string s returns string
    .
    .
- &quot;string coloredString&quot; -&gt; The string which is to be returned in the wanted playercolor.


Is this supposed to be [lJASS]function PlayerColoredString takes player p, string coloredString returns string[/lJASS] ? (I mean that the parameters in the documentation don't match those of the actual functions. That's not a big thing though ^^)

PS: No offence but I really don't understand why you care if this is approved or not... (I know you put a lot of work in this but still...)

Edit: woot my #2^9 post (but no "Been there done that." xD)
 

Komaqtion

You can change this now in User CP.
Reaction score
469
It's just for the cause if it getting thoroughly reviewed, and I mean it's been an ongoing thread for a year now, and it's just the principal of the moderators "doing their job"...

I mean, I currently have two REALLY long threads of systems/snippets in the Tutorials and Resources area, and then also three other snippets (Which I don't care too much about but I bump them too :p XD) that just never really get's properly reviewed by anyone and I'm getting tired of it :'(

And gonna change that ;)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top