AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   how to change the text color (https://forums.alliedmods.net/showthread.php?t=239445)

PresidentEvil 04-27-2014 14:59

how to change the text color
 
[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;
    }



yatchi 04-27-2014 23:38

Re: how to change the text color
 
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 :3

MasterOfTheXP 04-28-2014 07:17

Re: how to change the text color
 
Coloured text works on CS:GO now...?

Mitchell 04-28-2014 07:40

Re: how to change the text color
 
Quote:

Originally Posted by MasterOfTheXP (Post 2130655)
Coloured text works on CS:GO now...?

To an extent that is very hacky.

PresidentEvil 04-28-2014 16:55

Re: how to change the text color
 
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

Mitchell 04-28-2014 17:02

Re: how to change the text color
 
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

xf117 04-28-2014 17:07

Re: how to change the text color
 
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.

Powerlord 04-28-2014 18:27

Re: how to change the text color
 
Remind me again... which games does morecolors say it supports?

Hint: CS:GO isn't one of them.

blaacky 04-29-2014 05:34

Re: how to change the text color
 
For CS:GO I believe you have to use \x01 - \x07.

PresidentEvil 04-29-2014 12:28

Re: how to change the text color
 
where do i put \x01 in the code?


All times are GMT -4. The time now is 13:41.

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