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

how to change the text color


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PresidentEvil
AlliedModders Donor
Join Date: Jun 2012
Old 04-27-2014 , 14:59   how to change the text color
Reply With Quote #1

[img]http://s8.************/6ogdfx48l/2014_04_27_00003.png[/img]

the part in the red box

how do I change the [Warden] to orange and the text to like purple?



warden.sp
PHP Code:

#include <sourcemod>
#include <sdktools>
#include <morecolors>

#define Commander_VERSION   "1.8.0"
#define TEAM_CTS 3

new Warden = -1;
new 
Handle:g_cVar_mnotes INVALID_HANDLE;

public 
Plugin:myinfo = {
    
name "JailBreak Warden",
    
author "ecca",
    
description "Jailbreak Warden script",
    
version Commander_VERSION,
    
url "ffac.eu"
};

public 
OnPluginStart() 
{
    
// Initialize our phrases
    
LoadTranslations("warden.phrases");
    
    
// Register our public commands
    
RegConsoleCmd("sm_w"BecomeWarden);
    
RegConsoleCmd("sm_warden"BecomeWarden);
    
RegConsoleCmd("sm_uw"ExitWarden);
    
RegConsoleCmd("sm_unwarden"ExitWarden);
    
RegConsoleCmd("sm_c"BecomeWarden);
    
RegConsoleCmd("sm_commander"BecomeWarden);
    
RegConsoleCmd("sm_uc"ExitWarden);
    
RegConsoleCmd("sm_uncommander"ExitWarden);
    
    
// Register our admin commands
    
RegAdminCmd("sm_rw"RemoveWardenADMFLAG_GENERIC);
    
RegAdminCmd("sm_rc"RemoveWardenADMFLAG_GENERIC);
    
    
// Hooking the events
    
HookEvent("round_start"roundStart); // For the round start
    
HookEvent("player_death"playerDeath); // To check when our warden dies :)
    
    // For our warden to look some extra cool
    
AddCommandListener(HookPlayerChat"say");
    
    
// May not touch this line
    
CreateConVar("sm_warden_version"Commander_VERSION,  "The version of the SourceMod plugin JailBreak Warden, by ecca"FCVAR_REPLICATED|FCVAR_SPONLY|FCVAR_PLUGIN);
    
g_cVar_mnotes CreateConVar("sm_warden_better_notifications""0""0 - disabled, 1 - Will use hint and center text"FCVAR_PLUGINtrue0.0true1.0);
}

public 
APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
    
CreateNative("warden_iswarden"Native_IsWarden);
    
CreateNative("warden_remove"Native_Remove);

    
RegPluginLibrary("warden");
    
    return 
APLRes_Success;
}

public 
Action:BecomeWarden(clientargs
{
    if (
Warden == -1// There is no warden , so lets proceed
    
{
        if (
GetClientTeam(client) == TEAM_CTS// The requested player is on the Counter-Terrorist side
        
{
            if (
IsPlayerAlive(client)) // A dead warden would be worthless >_<
            
{
                
CPrintToChatAll("{springgreen}Warden ~ {white}%t""warden_new"client);
                if(
GetConVarBool(g_cVar_mnotes))
                {
                    
PrintCenterTextAll("Warden ~ %t""warden_new"client);
                    
PrintHintTextToAll("Warden ~ %t""warden_new"client);
                }
                
Warden client// Set the client to warden
                
SetEntityRenderColor(client00255255); // Lets give him some special blue color
                
SetClientListeningFlags(clientVOICE_NORMAL); // Will unmute the player if he is muted
            
}
            else 
// Grr he is not alive -.-
            
{
                
CPrintToChat(client"{springgreen}Warden ~ {white}%t""warden_playerdead");
            }
        }
        else 
// Would be wierd if an terrorist would run the prison wouldn't it :p
        
{
            
CPrintToChat(client"{springgreen}Warden ~ {white}%t""warden_ctsonly");
        }
    }
    else 
// The warden already exist so there is no point setting a new one
    
{
        
CPrintToChat(client"{springgreen}Warden ~ {white}%t""warden_exist"Warden);
    }
}

public 
Action:ExitWarden(clientargs
{
    if(
client == Warden// The client is actually the current warden so lets proceed
    
{
        
CPrintToChatAll("{springgreen}Warden ~ {white}%t""warden_retire"client);
        if(
GetConVarBool(g_cVar_mnotes))
        {
            
PrintCenterTextAll("Warden ~ %t""warden_retire"client);
            
PrintHintTextToAll("Warden ~ %t""warden_retire"client);
        }
        
Warden = -1// Open for a new warden
        
SetEntityRenderColor(client255255255255); // Lets remove the awesome color
    
}
    else 
// Fake dude!
    
{
        
CPrintToChat(client"{springgreen}Warden ~ {white}%t""warden_notwarden");
    }
}

public 
Action:roundStart(Handle:event, const String:name[], bool:dontBroadcast
{
    
Warden = -1// Lets remove the current warden if he exist
}

public 
Action:playerDeath(Handle:event, const String:name[], bool:dontBroadcast
{
    new 
client GetClientOfUserId(GetEventInt(event"userid")); // Get the dead clients id
    
    
if(client == Warden// Aww damn , he is the warden
    
{
        
CPrintToChatAll("{springgreen}Warden ~ {white}%t""warden_dead"client);
        if(
GetConVarBool(g_cVar_mnotes))
        {
            
PrintCenterTextAll("Warden ~ %t""warden_dead"client);
            
PrintHintTextToAll("Warden ~ %t""warden_dead"client);
        }
        
SetEntityRenderColor(client255255255255); // Lets give him the standard color back
        
Warden = -1// Lets open for a new warden
    
}
}

public 
OnClientDisconnect(client)
{
    if(
client == Warden// The warden disconnected, action!
    
{
        
CPrintToChatAll("{springgreen}Warden ~ {white}%t""warden_disconnected");
        if(
GetConVarBool(g_cVar_mnotes))
        {
            
PrintCenterTextAll("Warden ~ %t""warden_disconnected"client);
            
PrintHintTextToAll("Warden ~ %t""warden_disconnected"client);
        }
        
Warden = -1// Lets open for a new warden
    
}
}

public 
Action:RemoveWarden(clientargs)
{
    if(
Warden != -1// Is there an warden at the moment ?
    
{
        
CPrintToChatAll("{springgreen}Warden ~ {white}%t""warden_removed"clientWarden);
        if(
GetConVarBool(g_cVar_mnotes))
        {
            
PrintCenterTextAll("Warden ~ %t""warden_removed"client);
            
PrintHintTextToAll("Warden ~ %t""warden_removed"client);
        }
        
SetEntityRenderColor(Warden255255255255); // Give his normal color back
        
Warden = -1// Lets open for a new warden
    
}
    else
    {
        
CPrintToChatAll("{springgreen}Warden ~ {white}%t""warden_noexist");
    }

    return 
Plugin_Handled// Prevent sourcemod from typing "unknown command" in console
}

public 
Action:HookPlayerChat(client, const String:command[], args)
{
    if(
Warden == client && client != 0// Check so the player typing is warden and also checking so the client isn't console!
    
{
        new 
String:szText[256];
        
GetCmdArg(1szTextsizeof(szText));
        
        if(
szText[0] == '/' || szText[0] == '@' || IsChatTrigger()) // Prevent unwanted text to be displayed.
        
{
            return 
Plugin_Handled;
        }
        
        if(
IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client) == TEAM_CTS// Typing warden is alive and his team is Counter-Terrorist
        
{
            
CPrintToChatAll("{springgreen}[Warden] {blue}%N: {white}%s"clientszText);
            return 
Plugin_Handled;
        }
    }
    return 
Plugin_Continue;
}

public 
Native_IsWarden(Handle:pluginnumParams)
{
    new 
client GetNativeCell(1);
    
    if (!
IsClientInGame(client) && !IsClientConnected(client))
    {
        
ThrowNativeError(SP_ERROR_INDEX"Client index %i is invalid"client);
    }
    
    if(
client == Warden)
    {
        return 
true;
    }
    
    return 
false;
}

public 
Native_Remove(Handle:pluginnumParams)
{
    new 
client GetNativeCell(1);
    
    if (!
IsClientInGame(client) && !IsClientConnected(client))
    {
        
ThrowNativeError(SP_ERROR_INDEX"Client index %i is invalid"client);
    }
    
    if(
client == Warden)
    {
        
CPrintToChatAll("{springgreen}Warden ~ {white}%t""warden_removed"clientWarden);
        
SetEntityRenderColor(Warden255255255255);
        
Warden = -1;
    }

__________________

Last edited by PresidentEvil; 04-27-2014 at 15:00.
PresidentEvil is offline
yatchi
Member
Join Date: Feb 2011
Location: Brazil
Old 04-27-2014 , 23:38   Re: how to change the text color
Reply With Quote #2

Search

https://forums.alliedmods.net/showthread.php?t=187746

I just didn't know that colors don't work on CS:GO since I don't have it

Last edited by yatchi; 04-29-2014 at 04:16.
yatchi is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 04-28-2014 , 07:17   Re: how to change the text color
Reply With Quote #3

Coloured text works on CS:GO now...?
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-28-2014 , 07:40   Re: how to change the text color
Reply With Quote #4

Quote:
Originally Posted by MasterOfTheXP View Post
Coloured text works on CS:GO now...?
To an extent that is very hacky.
Mitchell is offline
PresidentEvil
AlliedModders Donor
Join Date: Jun 2012
Old 04-28-2014 , 16:55   Re: how to change the text color
Reply With Quote #5

can someone actually help?

this line obviously doesn't work:

CPrintToChatAll("{springgreen}[Warden] {blue}%N: {white}%s", client, szText);

in the screenshot everything is in white
__________________
PresidentEvil is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-28-2014 , 17:02   Re: how to change the text color
Reply With Quote #6

Let me see if i can find all the topics asking the questions like this, something to do with like \x0B or some weird character
Found it: https://forums.alliedmods.net/showpo...1&postcount=17

Last edited by Mitchell; 04-28-2014 at 17:08.
Mitchell is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 04-28-2014 , 17:07   Re: how to change the text color
Reply With Quote #7

Hacky characters doesn't work in CS:GO for a quite a while now.
Just put a space at the beginning and it will be fine.
And ofc you have to use CS:Go compatible color library. Or just plain old \x02 will do.

Last edited by xf117; 04-28-2014 at 17:07.
xf117 is offline
Send a message via ICQ to xf117
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-28-2014 , 18:27   Re: how to change the text color
Reply With Quote #8

Remind me again... which games does morecolors say it supports?

Hint: CS:GO isn't one of them.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 04-29-2014 , 05:34   Re: how to change the text color
Reply With Quote #9

For CS:GO I believe you have to use \x01 - \x07.
blaacky is offline
PresidentEvil
AlliedModders Donor
Join Date: Jun 2012
Old 04-29-2014 , 12:28   Re: how to change the text color
Reply With Quote #10

where do i put \x01 in the code?
__________________
PresidentEvil 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 23:57.


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