Raised This Month: $90 Target: $400
 22% 

Replace the color code with cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alphaearth
Senior Member
Join Date: Feb 2018
Location: Turkey
Old 03-15-2019 , 17:45   Replace the color code with cvar
Reply With Quote #1

PrintCenterText(i, "<font size='24' color='#FF0000'>%s</font>", text);

I want to replace the color code with cvar. How can I do it?
__________________
alphaearth is offline
Cruze
Senior Member
Join Date: May 2017
Old 03-15-2019 , 20:19   Re: Replace the color code with cvar
Reply With Quote #2

PHP Code:
#pragma semicolon 1
#pragma newdecls required

ConVar g_sFontColor;

public 
void OnPluginStart ()
{
    
g_sFontColor CreateConVar ("sm_plugin_fontcolor""ff0000",  "font color lol");
}

public 
void OnClientPostAdminCheck (int i)
{
    
char color[16];
    
char text[16] = "Hello lol";
    
g_sFontColor.GetString(colorsizeof(color));
    
PrintCenterText(i"<font size='24' color='%s'>%s</font>"colortext);

__________________
Taking paid private requests! Add me on steam!

AlliedModders Releases | Github | Steam | PayPal
Cruze is offline
alphaearth
Senior Member
Join Date: Feb 2018
Location: Turkey
Old 03-16-2019 , 05:21   Re: Replace the color code with cvar
Reply With Quote #3

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_AUTHOR "Mithat Guner" //Thanks To shanapu https://forums.alliedmods.net/member.php?u=259929
#define PLUGIN_VERSION "1.2.1"

#include <sourcemod>
#include <sdktools>

ConVar hud_red;
ConVar hud_green;
ConVar hud_blue;
ConVar hud_xpos;
ConVar hud_ypos;
ConVar csay_FontColor;

public 
Plugin myinfo 
{
    
name "HUD Write",
    
author PLUGIN_AUTHOR,
    
description "HUD Write",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart()
{
    
hud_red CreateConVar("sm_hud_red""255""RGB RED Color");
    
hud_green CreateConVar("sm_hud_blue""0""RGB BLUE Color");
    
hud_blue CreateConVar("sm_hud_green""0""RGB GREEN Color");
    
hud_xpos CreateConVar("sm_hud_x""0.45""HUD X POS");
    
hud_ypos CreateConVar("sm_hud_y""0.350""HUD Y POS");
    
csay_FontColor CreateConVar("sm_csay_color""FF0000""CSAY Color");
    
AutoExecConfig(true"sm_hudwrite");
    
RegAdminCmd("sm_hwrite"writeADMFLAG_GENERIC"HUD Write");
    
RegAdminCmd("sm_renklihud"writeADMFLAG_GENERIC"HUD Write");
    
RegAdminCmd("sm_cwrite"hsayyazdirADMFLAG_GENERIC"CSAY Write");
    
RegAdminCmd("sm_renklicsay"hsayyazdirADMFLAG_GENERIC"CSAY Write");

}
public 
Action write(int clientint args)
{
    if (
args 1)
    {
        
ReplyToCommand(client"Use: sm_hwrite <text>");
        return 
Plugin_Handled;
    }
    
char text[192];
    
GetCmdArgString(textsizeof(text));
    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i))
        {
            
SetHudTextParams(GetConVarFloat(hud_xpos), GetConVarFloat(hud_ypos), 3.0GetConVarInt(hud_red), GetConVarInt(hud_blue), GetConVarInt(hud_green), 25500.250.50.3);
            
            if (
StrContains(text[0], "@r"false) == 0)
            {
                
ReplaceString(textsizeof(text), "@r""");
                
SetHudTextParams(GetConVarFloat(hud_xpos), GetConVarFloat(hud_ypos), 3.02550025500.250.50.3);
                
ShowHudText(i1text);
            }
            
            if (
StrContains(text[0], "@g"false) == 0)
            {
                
ReplaceString(textsizeof(text), "@g""");
                
SetHudTextParams(GetConVarFloat(hud_xpos), GetConVarFloat(hud_ypos), 3.00255025500.250.50.3);
                
ShowHudText(i1text);
            }
            
            if (
StrContains(text[0], "@b"false) == 0)
            {
                
ReplaceString(textsizeof(text), "@b""");
                
SetHudTextParams(GetConVarFloat(hud_xpos), GetConVarFloat(hud_ypos), 3.00025525500.250.50.3);
                
ShowHudText(i1text);
            }
            
            if (
StrContains(text[0], "@w"false) == 0)
            {
                
ReplaceString(textsizeof(text), "@w""");
                
SetHudTextParams(GetConVarFloat(hud_xpos), GetConVarFloat(hud_ypos), 3.025525525525500.250.50.3);
                
ShowHudText(i1text);
            }
            
            if (
StrContains(text[0], "@y"false) == 0)
            {
                
ReplaceString(textsizeof(text), "@y""");
                
SetHudTextParams(GetConVarFloat(hud_xpos), GetConVarFloat(hud_ypos), 3.02552555125500.250.50.3);
                
ShowHudText(i1text);
            }
            
            if (
StrContains(text[0], "@bl"false) == 0)
            {
                
ReplaceString(textsizeof(text), "@bl""");
                
SetHudTextParams(GetConVarFloat(hud_xpos), GetConVarFloat(hud_ypos), 3.000025500.250.50.3);
                
ShowHudText(i1text);
            }
            
            
ShowHudText(i1text);
        }
    }
    return 
Plugin_Handled;
}

public 
Action hsayyazdir(int clientint args)
{
    if (
args 1)
    {
        
ReplyToCommand(client"Use: sm_cwrite <text>");
        return 
Plugin_Handled;
    }
    
char color[16];
    
csay_FontColor.GetString(colorsizeof(color));
    
char text[192];
    
GetCmdArgString(textsizeof(text));
    for(
int i 1<= MaxClientsi++)
    {
    if(
IsClientInGame(i) && !IsFakeClient(i))
    {
        
PrintCenterText(i"<font size='24' color='#%s'>%s</font>"colortext);
        if (
StrContains(text[0], "@r"false) == 0)
        {
            
ReplaceString(textsizeof(text), "@r""");
            
PrintCenterText(i"<font size='24' color='#FF0000'>%s</font>"text);
        }
        if (
StrContains(text[0], "@b"false) == 0)
        {
            
ReplaceString(textsizeof(text), "@b""");
            
PrintCenterText(i"<font size='24' color='#0000FF'>%s</font>"text);
        }
        if (
StrContains(text[0], "@g"false) == 0)
        {
            
ReplaceString(textsizeof(text), "@g""");
            
PrintCenterText(i"<font size='24' color='#008000'>%s</font>"text);
        }
    }
    }
    return 
Plugin_Handled;

__________________
alphaearth is offline
Reply


Thread Tools
Display Modes

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 20:00.


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