Raised This Month: $51 Target: $400
 12% 

How to write StatusText with green, blue, red colors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 02-16-2011 , 09:13   How to write StatusText with green, blue, red colors
Reply With Quote #1

How to write StatusText with green, blue, red colors?
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 02-16-2011 , 13:46   Re: How to write StatusText with green, blue, red colors
Reply With Quote #2

Quote:
Originally Posted by Emp` View Post
In the comments of my Player Look plugin, you can read more about StatusText and StatusValue.

tl;dr: you can only have colors in StatusText if you have a player's name in there as well (it will be that player's designated team color: red,blue,gray)
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-17-2011 , 06:50   Re: How to write StatusText with green, blue, red colors
Reply With Quote #3

This is not complete, but depending on your needs it could be enough.
Don't send the same message at few players, or change only 1 player name ;)

PHP Code:
/*    Formatright © 2010, ConnorMcLeod

    This plugin is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this plugin; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <fakemeta>

#define VERSION "0.0.1"
#define PLUGIN "StatusText Color"

enum _:mRestoreDatas {
    
m_szName[32],
    
m_szTeamName[11]
}

enum iColors {
    
GREY,
    
RED,
    
BLUE
}

new const 
g_szTeamNames[][] = {
    
"UNASSIGNED",
    
"TERRORIST",
    
"CT"
}

new 
gmsgStatusValuegmsgStatusTextgmsgTeamInfo

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")

    
register_clcmd("say""HostSay")

    
gmsgStatusValue get_user_msgid("StatusValue")
    
gmsgStatusText get_user_msgid("StatusText")
    
gmsgTeamInfo get_user_msgid("TeamInfo")
}

public 
HostSayid )
{
    new 
szSaid[192]
    
read_args(szSaidcharsmax(szSaid))
    
remove_quotes(szSaid)
    if( 
szSaid[0] == '!' )
    {
        new 
iColors:iColorbool:bColorTag true
        
switch( szSaid[1] )
        {
            case 
'g':iColor GREY
            
case 'r':iColor RED
            
case 'b':iColor BLUE
            
default:bColorTag false
        
}
        
client_print_status(idiColorszSaid[bColorTag 1])
    }
    return 
PLUGIN_CONTINUE
}

client_print_statusidiColors:iColor GREY, const fmt[], any:... )
{
    if( 
task_exists(id) )
    {
        
change_task(id0.1)
    }
    else
    {
        new 
mDatas[mRestoreDatas]
        
get_user_name(idmDatas[m_szName], charsmax(mDatas[m_szName]))
        
get_user_team(idmDatas[m_szTeamName], charsmax(mDatas[m_szTeamName]))
        
set_task(0.1"Restore_Player"idmDatasmRestoreDatas)
    }

    new 
szMessage[192], iLen
    iLen 
vformat(szMessagecharsmax(szMessage), fmt4)

    new 
szFakeName[32]
    
copy(szFakeNamecharsmax(szFakeName), szMessage)
    
set_user_info(id"name"szFakeName)
    
set_pev(idpev_netnameszFakeName// don't send SayText msg
    
TeamInfo(idg_szTeamNames[iColor])

    if( 
iLen 31 )
    {
        
format(szMessagecharsmax(szMessage), "%%p%s"szMessage[31])
    }
    else
    {
        
formatex(szMessagecharsmax(szMessage), "%%p")
    }
    
StatusText(idszMessage)
    
StatusValue(id12)
    
StatusValue(id2id)
    
Set_Timers(id)
}

public 
Restore_Player(mDatas[], id)
{
    
set_user_info(id"name"mDatas[m_szName])
    
set_pev(idpev_netnamemDatas[m_szName])
    
TeamInfo(idmDatas[m_szTeamName])
}

StatusValue(idiFlagiValue)
{
    
message_begin(MSG_ONEgmsgStatusValue, .player=id)
    {
        
write_byte(iFlag)
        
write_short(iValue)
    }
    
message_end()
}

StatusTextid , const szText[] )
{
    
message_begin(MSG_ONEgmsgStatusText, .player=id)
    {
        
write_byte(0)
        
write_string(szText)
    }
    
message_end()
}

Set_Timers(idFloat:flDelay 2.0)
{
    
#define XO_PLAYER 5
//    #define m_izSBarState_SBAR_ID_TARGETCLASS 446
//    #define m_izSBarState_SBAR_ID_TARGETNAME 447
//    #define m_izSBarState_SBAR_ID_TARGETHEALTH 448
    #define m_flNextSBarUpdateTime 449
//    #define m_flStatusBarDisappearDelay 450
    #define m_SbarString0 451

//    set_pdata_int(id, m_izSBarState_SBAR_ID_TARGETCLASS, 0, XO_PLAYER)
//    set_pdata_int(id, m_izSBarState_SBAR_ID_TARGETNAME, 0, XO_PLAYER)
//    set_pdata_int(id, m_izSBarState_SBAR_ID_TARGETHEALTH, 0, XO_PLAYER)
    
set_pdata_float(idm_flNextSBarUpdateTimeget_gametime() + flDelayXO_PLAYER)
//    set_pdata_float(id, m_flStatusBarDisappearDelay, flHoldTime, XO_PLAYER)
    
set_pdata_int(idm_SbarString00XO_PLAYER)

    
set_task(flDelay"ResetStatusText"id 32)
}

public 
ResetStatusTextid )
{
    
id -= 32
    
if( !get_pdata_int(id451) )
    {
        
StatusText(id"")
    }
}

TeamInfo(idszTeam[])
{
    
message_begin(MSG_ONEgmsgTeamInfo, .player=id)
    {
        
write_byte(id)
        
write_string(szTeam)
    }
    
message_end()

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
CHyCMyMpNk
Senior Member
Join Date: Jun 2008
Location: PTZ
Old 10-17-2012 , 12:33   Re: How to write StatusText with green, blue, red colors
Reply With Quote #4

How can I change color in this code ?

PHP Code:
public msgStatusValue(msgiddestid)
{
    new 
flagvalue;
    
flag get_msg_arg_int(1);
    
value get_msg_arg_int(2);
    
    if (!
value)
    {
        return 
PLUGIN_CONTINUE;
    }

    if (
flag == 2)
    {
        new 
text[64];

        if (!
g_GameModeStarted)
        {
            return 
PLUGIN_CONTINUE;
        }

        else
        {
            if (
is_user_connected(id))
            {
                if (
zp_core_is_zombie(id) == zp_core_is_zombie(value))
                {
                    
formatex(textcharsmax(text), "1 %%p2 [HP: %d] [Armor: %d] [%d $]"pev(valuepev_health), pev(valuepev_armorvalue), my_get_user_money(value));
                }
            }
        }

        
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("StatusText"), _id);
        
write_byte(0);
        
write_string(text);
        
message_end();
    }
    return 
PLUGIN_CONTINUE;

In this case i need blue color :
PHP Code:
        if (!g_GameModeStarted)
        {
            return 
PLUGIN_CONTINUE;
        } 
CHyCMyMpNk is offline
Send a message via ICQ to CHyCMyMpNk
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 10-19-2012 , 19:33   Re: How to write StatusText with green, blue, red colors
Reply With Quote #5

Click on connor's link in his signature. "ColorChat Module"
Read that code
Learn how that works.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz 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 21:05.


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