AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [CS:GO] HUD colors - Solved (https://forums.alliedmods.net/showthread.php?t=256058)

KissLick 01-23-2015 18:31

[CS:GO] HUD colors - Solved
 
Ciao guys,

is there any way, how to color text in HUD (function PrintHintText() and UserMessage KeyHintText) ?
I mean, in native CS:GO messages are colors (like red Alert)...
I tried escapes \x01, \x02 etc. but it didn't work...

Does anyone please know, how to do that?

KissLick 01-23-2015 18:33

Re: [CS:GO] HUD colors
 
Jeez, I didn't see this topic Hint Text color O:-) Well, I am gonna try that tomorow.

EngHell 01-23-2015 19:17

Re: [CS:GO] HUD colors
 
Quote:

Originally Posted by KissLick (Post 2252959)
Jeez, I didn't see this topic Hint Text color O:-) Well, I am gonna try that tomorow.

Give me a shot if it works as this:
PHP Code:

PrintHintText(attacker,"<span style='color:red;'>Damage</span> : %i",damage

I would like to try, but im working on something else, thanks ;D

Mitchell 01-23-2015 23:40

Re: [CS:GO] HUD colors
 
you could just used <font color="#ff0000"> </font>
which is sort of smaller.
Small parts of the hud supports basic html. You can also change the size and alignment.
Also the team names can be changed to support colors also:
http://cloud-2.steamusercontent.com/...917CBA996757E/

buzzace 01-23-2015 23:59

Re: [CS:GO] HUD colors
 
Quote:

Originally Posted by Mitchell (Post 2253057)
you could just used <font color="#ff0000"> </font>
which is sort of smaller.
Small parts of the hud supports basic html. You can also change the size and alignment.
Also the team names can be changed to support colors also:
http://cloud-2.steamusercontent.com/...917CBA996757E/

That would actually be not working. Instead of using "" simply use single quotes ''. So <font color='#FFFFFF'>hello</font>

KissLick 01-24-2015 11:08

Re: [CS:GO] HUD colors
 
So... I did some testing and HTML seems to be partialy working in PrintHintText() and UserMessage KeyHintText.

Some points I made:
  1. PrintHintText and KeyHintText seems to be working exactly the same way...
  2. CSS is not working...
  3. Only a few HTML tags are working (<font>, <b>, <i>, <u> and <br>)
  4. You can create new line with both <br> or \n
  5. HUD has only three lines (with default font size)
  6. Font
    1. Color could be set only via HEX RGB code and not names... I use this color mixer
    2. Default font size seems to be 20, but I am not sure about that...
    3. Smaller font means more lines
    4. Any custom font I tried to use with <font> gave me the same result
  7. And of course, you can combine tags...
Here is my test plugin I made:
PHP Code:

#include <sourcemod>

public Plugin:myinfo =
{
    
name "CSGO_ColorHudTest",
    
author "Raska",
    
description "",
    
version "0.1",
    
url ""
}

public 
OnClientSayCommand_Post(iClient, const String:sCommand[], const String:sArgs[])
{
    if (
StrEqual(sArgs"!1")) {
        
PrintHintText(iClient,"normal <font color='#ff0000'>red</font> normal <font color='#006699'>color #006699</font> normal");
    } else if (
StrEqual(sArgs"!2")) {
        
PrintHintText(iClient,"normal <font size='30'>size 30</font> normal");
    } else if (
StrEqual(sArgs"!3")) {
        
PrintHintText(iClient,"normal <font face='Arial'>custom font</font> normal");
    } else if (
StrEqual(sArgs"!4")) {
        
PrintHintText(iClient,"normal <b>bold</b> normal");
    } else if (
StrEqual(sArgs"!5")) {
        
PrintHintText(iClient,"normal <i>italica</i> normal");
    } else if (
StrEqual(sArgs"!6")) {
        
PrintHintText(iClient,"normal <u>underline</u> normal");
    } else if (
StrEqual(sArgs"!7")) {
        
PrintHintText(iClient,"line1\nline2<br/>line3");
    } else if (
StrEqual(sArgs"!8")) {
        
PrintHintText(iClient,"<font color='#006699'><b><u>PLAYER INFO</u></b></font>\n<font color='#990033'>PlayerName:</font> %N\n<font color='#666699'>PlayerUserID:</font> #%d"iClientGetClientUserId(iClient));
    } else if (
StrEqual(sArgs"!9")) {
        
PrintHintText(iClient,"<font size='10'>line1\nline2\nline3\nline4\nline5\nline6</font>");
    }
}

stock bool:PrintKeyHintText(client, const String:format[], any:...)
{
    new 
Handle:userMessage StartMessageOne("KeyHintText"client);
    if (
userMessage == INVALID_HANDLE) {
        return 
false;
    }

    
decl String:buffer[1024];
    
SetGlobalTransTarget(client);
    
VFormat(buffersizeof(buffer), format3);
    
    if (
GetUserMessageType() == UM_Protobuf)
    {
        
PbAddString(userMessage"hints"buffer);
    }
    else
    {
        
BfWriteByte(userMessage1);
        
BfWriteString(userMessagebuffer);
    }
    
    
EndMessage();
    return 
true;


And some images:
!1 !2 !3 !4 !5 !6 !7 !8 !9

EngHell 01-24-2015 12:23

Re: [CS:GO] HUD colors
 
Quote:

Originally Posted by KissLick (Post 2253334)
So... I did some testing and HTML seems to be partialy working in PrintHintText() and UserMessage KeyHintText.

Some points I made:
  1. PrintHintText and KeyHintText seems to be working exactly the same way...
  2. CSS is not working...
  3. Only a few HTML tags are working (<font>, <b>, <i>, <u> and <br>)
  4. You can create new line with both <br> or \n
  5. HUD has only three lines (with default font size)
  6. Font
    1. Color could be set only via HEX RGB code and not names... I use this color mixer
    2. Default font size seems to be 20, but I am not sure about that...
    3. Smaller font means more lines
    4. Any custom font I tried to use with <font> gave me the same result
  7. And of course, you can combine tags...
Here is my test plugin I made:
PHP Code:

#include <sourcemod>

public Plugin:myinfo =
{
    
name "CSGO_ColorHudTest",
    
author "Raska",
    
description "",
    
version "0.1",
    
url ""
}

public 
OnClientSayCommand_Post(iClient, const String:sCommand[], const String:sArgs[])
{
    if (
StrEqual(sArgs"!1")) {
        
PrintHintText(iClient,"normal <font color='#ff0000'>red</font> normal <font color='#006699'>color #006699</font> normal");
    } else if (
StrEqual(sArgs"!2")) {
        
PrintHintText(iClient,"normal <font size='30'>size 30</font> normal");
    } else if (
StrEqual(sArgs"!3")) {
        
PrintHintText(iClient,"normal <font face='Arial'>custom font</font> normal");
    } else if (
StrEqual(sArgs"!4")) {
        
PrintHintText(iClient,"normal <b>bold</b> normal");
    } else if (
StrEqual(sArgs"!5")) {
        
PrintHintText(iClient,"normal <i>italica</i> normal");
    } else if (
StrEqual(sArgs"!6")) {
        
PrintHintText(iClient,"normal <u>underline</u> normal");
    } else if (
StrEqual(sArgs"!7")) {
        
PrintHintText(iClient,"line1\nline2<br/>line3");
    } else if (
StrEqual(sArgs"!8")) {
        
PrintHintText(iClient,"<font color='#006699'><b><u>PLAYER INFO</u></b></font>\n<font color='#990033'>PlayerName:</font> %N\n<font color='#666699'>PlayerUserID:</font> #%d"iClientGetClientUserId(iClient));
    } else if (
StrEqual(sArgs"!9")) {
        
PrintHintText(iClient,"<font size='10'>line1\nline2\nline3\nline4\nline5\nline6</font>");
    }
}

stock bool:PrintKeyHintText(client, const String:format[], any:...)
{
    new 
Handle:userMessage StartMessageOne("KeyHintText"client);
    if (
userMessage == INVALID_HANDLE) {
        return 
false;
    }

    
decl String:buffer[1024];
    
SetGlobalTransTarget(client);
    
VFormat(buffersizeof(buffer), format3);
    
    if (
GetUserMessageType() == UM_Protobuf)
    {
        
PbAddString(userMessage"hints"buffer);
    }
    else
    {
        
BfWriteByte(userMessage1);
        
BfWriteString(userMessagebuffer);
    }
    
    
EndMessage();
    return 
true;


And some images:
!1 !2 !3 !4 !5 !6 !7 !8 !9

I was having this doubt about the hint text, cause I researched and there is not much info about it, I think we should start to update the wiki with some new info ;D

KissLick 01-24-2015 12:31

Re: [CS:GO] HUD colors
 
Quote:

Originally Posted by EngHell (Post 2253359)
I think we should start to update the wiki with some new info ;D

Totally! :-D For example: removing weapon in event weapon_fire will crash the server or editing player score in event player_death wouldn't work... Both must be at least one frame delayed.

P.S.: In CS:GO

EngHell 01-24-2015 21:31

Re: [CS:GO] HUD colors
 
Quote:

Originally Posted by KissLick (Post 2253364)
Totally! :-D For example: removing weapon in event weapon_fire will crash the server or editing player score in event player_death wouldn't work... Both must be at least one frame delayed.

P.S.: In CS:GO

I'm going to update and make some new articles on the wiki, but i think as much of us, we don't cause we think we are going to get something like "you are too newbie to update this and this" from the sourcemods developers :( but anyways the wiki mode is always open to new ones who want to contribute, then i think there is not problem about it, and if i ask, may there is any one who can confirm we can modify and update it? it will make learn sourcepawn easier faster and better with more resources ;D

Edit:
For example check this page of the wiki https://wiki.alliedmods.net/index.ph...&days=30&from= and tell me if is it not bad a wiki looks like it, now watch this live and healty wiki http://terraria.wikia.com/wiki/Special:WikiActivity , do you got it? we have to put hands on to update it ;D

lingzhidiyu 01-25-2015 01:44

Re: [CS:GO] HUD colors - Solved
 
the hinttext only can show 4 colors,how can i show more colors?


All times are GMT -4. The time now is 15:07.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.