Raised This Month: $32 Target: $400
 8% 

[L4D] Suggest me color library (red color etc)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 12-17-2020 , 00:53   [L4D] Suggest me color library (red color etc)
Reply With Quote #1

Hi,

suggest me, please, a normal color library (or code) and list of prefixes for L4D.

I tried several:

stamm-colors.inc, morecolors.inc, multicolors.inc, colorvariables.inc, colorsLib.inc

but nothing works for me, or I just fucked up.

I need red and blue colors. Some of the above libs give blue, but not red (even if an infected player exists).

PS. BTW, does anybody found a way how to get "red" without even the requirement to have at least 1 player in the infected team?
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 12-17-2020 at 00:57.
Dragokas is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 12-17-2020 , 02:42   Re: [L4D] Suggest me color library (red color etc)
Reply With Quote #2

I don't think it's possible to color a text red without a player or bot in the Infected team.
cravenge is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 12-17-2020 , 08:01   Re: [L4D] Suggest me color library (red color etc)
Reply With Quote #3

I made this once, but as cravenge said I was unable to make the colours work without a client in the team, maybe creating a fake client and kicking next after chat event would make it work, don't know.

But if the creation failed, I think the text output in "White"

I'm not sure but PrintToChat may use SayText and to get team colors we have to use SayText2 (has one thread here)

Here is some info I used to add to my translation file, most of them are based on your color tutorial for translation files

Code:
	Using color tags:
		• {default} // Default (use instead of \x01)
		• {lightyellow} // Light Yellow (use instead of \x01) = Default
		• {orange} // Orange(use instead of \x04)
		• {olive} // Olive (use instead of \x05)
		• {lightgreen} // Light Green (use instead of \x03)
		***Extended color tags***:
		• {team} // Team color chat (use instead of \x03). Color based on the current client team.
		• {blue} // Blue (use instead of \x03). Requires at least one client on the Survivor team.
		• {red} // Red (use instead of \x03). Requires at least one client on the Infected team.
		• {white} // White (use instead of \x03)
Then to output in Red/Blue/White color I have to use this stock

PHP Code:
void SayText2(int clientint author, const char[] formatany ...)
{
    
char sMessage[MAX_MESSAGE_LENGTH];
    
VFormat(sMessagesizeof(sMessage), format4);
    
    
Handle hBuffer StartMessageOne("SayText2"client);
    
BfWriteByte(hBufferauthor);
    
BfWriteByte(hBuffertrue);
    
BfWriteString(hBuffersMessage);
    
EndMessage();

Would be nice to have some way, as you asked, to output in e.g. Red without a client.
__________________

Last edited by Marttt; 12-17-2020 at 08:06.
Marttt is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 12-18-2020 , 10:21   Re: [L4D] Suggest me color library (red color etc)
Reply With Quote #4

Marttt, thank you. Are you mean a real (not fake) infected player?

With your snippet, red color is white for me. here it is:

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
//#include <colors>

int g_Infected;

const 
int MAX_MESSAGE_LENGTH 250;

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_t"Command_Colors);
    
    
HookEvent("player_team"Event_PlayerTeamEventHookMode_Post);
}

public 
Action Event_PlayerTeam(Event eventchar[] namebool dontBroadcast)
{
    if( !
event.GetBool("disconnect") )
    {
        if( 
event.GetInt("team") == )
        {
            
g_Infected GetClientOfUserId(event.GetInt("userid"));
            
            
PrintToChatAll("new inf: %i"g_Infected);
        }
    }
}

public 
void OnClientDisconnect(int client)
{
    
PrintToChatAll("disc: %i"client);

    if( 
g_Infected == client // check, isn't it too late
    
{
        
g_Infected 0;
    }
}

public 
Action Command_Colors(int clientint args)
{
    if( 
g_Infected )
    {
        
SayText(clientg_Infected"\x03RED");
        
SayText(clientg_Infected"\x01\x03RED");
    }
    
    return 
Plugin_Handled;
}

void SayText(int clientint author, const char[] formatany ...)
{
    
char sMessage[MAX_MESSAGE_LENGTH];
    
VFormat(sMessagesizeof(sMessage), format4);
    
    
Handle hBuffer StartMessageOne("SayText2"client);
    
BfWriteByte(hBufferauthor);
    
BfWriteByte(hBuffertrue);
    
BfWriteString(hBuffersMessage);
    
EndMessage();

I'm spawning a boomer, and execute "sm_t", text is white.
Am I doing something wrong? PS. Tested in L4D1.

Also, it makes no sense for me color tags you described. Can you please clarify:
Quote:
{lightgreen} // Light Green (use instead of \x03)
{team} // Team color chat (use instead of \x03). Color based on the current client team.
{blue} // Blue (use instead of \x03). Requires at least one client on the Survivor team.
{white} // White (use instead of \x03)
All uses code \x03, so what's the difference?
Also, {white} (or actually, grey) is uses \x01, AFAIK. Is there a real white?

Amazingly, that nobody still didn't create a color lib specially for L4D.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 12-18-2020 at 10:27.
Dragokas is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 12-18-2020 , 16:48   Re: [L4D] Suggest me color library (red color etc)
Reply With Quote #5

Is an old file when I started with SM, but from what I remember \x03 is necessary to output red/blue/white colors.

Here is the snippet that I used to use, I did copy paste so may be missing some things

PHP Code:
#define TEAM_SURVIVOR                2
#define TEAM_INFECTED                3

case teamSayText2(clientclient"\x01%s"sMessage);
case 
blue:  SayText2(clientFindRandomPlayerByTeam(TEAM_SURVIVOR), "\x01%s"sMessage);
case 
red:   SayText2(clientFindRandomPlayerByTeam(TEAM_INFECTED), "\x01%s"sMessage);
case 
whiteSayText2(client, -1"\x01%s"sMessage);

void SayText2(int clientint author, const char[] formatany ...)
{
    
char sMessage[MAX_MESSAGE_LENGTH];
    
VFormat(sMessagesizeof(sMessage), format4);

    
Handle hBuffer StartMessageOne("SayText2"client);
    
BfWriteByte(hBufferauthor);
    
BfWriteByte(hBuffertrue);
    
BfWriteString(hBuffersMessage);
    
EndMessage();
}

int FindRandomPlayerByTeam(int color_team)
{
    if (!
<= color_team <= 4)
        return 
0;

    for (
int client 1client <= MaxClientsclient++)
    {
        if (
IsClientInGame(client) && GetClientTeam(client) == color_team)
            return 
client;
    }

    return 
0;

About creating a bot (and swapping team) I think it may have to wait for some frames before sending the message.
I didn't created a bot, I use the FindRandomPlayerByTeam function, but I noticed that when there is no "infected" player, for example, it fails and output white.

The white color can be achieved by the spec player (or by -1)
__________________

Last edited by Marttt; 12-18-2020 at 16:50.
Marttt is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 12-18-2020 , 23:15   Re: [L4D] Suggest me color library (red color etc)
Reply With Quote #6

Thanks a lot. Better, but still, not enough.

Quote:
Originally Posted by Marttt
Code:
case team: SayText2(client, client, "\x01%s", sMessage);
case blue:  SayText2(client, FindRandomPlayerByTeam(TEAM_SURVIVOR), "\x01%s", sMessage);
case red:   SayText2(client, FindRandomPlayerByTeam(TEAM_INFECTED), "\x01%s", sMessage);
case white: SayText2(client, -1, "\x01%s", sMessage);
Did you mean \x03 ?

With your snippet:
PHP Code:
const int MAX_MESSAGE_LENGTH 255;

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_tt"Command_Colors);
}

public 
Action Command_Colors(int clientint args)
{
    
char[] sMessage "Hello!";
        
    
SayText2(clientclient"\x03%s"sMessage);
    
SayText2(clientFindRandomPlayerByTeam(TEAM_SURVIVOR), "\x03%s"sMessage);
    
SayText2(clientFindRandomPlayerByTeam(TEAM_INFECTED), "\x03%s"sMessage);
    
SayText2(client, -1"\x03%s"sMessage);

    return 
Plugin_Handled;

in L4D2:
Quote:
blue
blue
red
white
yeah, finally RED, but:

in L4D1:
Quote:
blue
blue
grey
white
Both games - coop, fake tank bot is in team.

I remember, last year I used some colors.inc with PrintToChatAll("{red}something"); and that's worked,
but I lost that inc and can't reproduce.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 12-18-2020 at 23:17.
Dragokas is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 12-19-2020 , 00:01   Re: [L4D] Suggest me color library (red color etc)
Reply With Quote #7

When I print something in chat like "abrakadabra" I hear "tick" sound.
When I execute StartMessageOne("SayText2"... I hear the same sound.
Is there a way to prevent it?

I tried add flags USERMSG_RELIABLE|USERMSG_BLOCKHOOKS. That seems not helped.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 12-19-2020 at 00:08.
Dragokas is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 10-17-2022 , 17:11   Re: [L4D] Suggest me color library (red color etc)
Reply With Quote #8

Based on what Marttt said, I made it to work, but I had to create a fake bot then kick it



Is there an existing script now that can do the job?? I wonder

if some work around already existed please share, I would really appreciate it, thanks
__________________

Last edited by alasfourom; 10-17-2022 at 18:27.
alasfourom is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:52.


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