AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Colorchat not working properly (https://forums.alliedmods.net/showthread.php?t=229694)

Backstabnoob 11-12-2013 17:11

Colorchat not working properly
 
Okay so I'm using Connor's API for colorchat and I'm getting a weird problem:
http://i.imgur.com/SMnJpim.jpg

Never encountered this before, no idea what's wrong. HLDS build hs the latest one, using windows 7 x64.

The code:

PHP Code:

#include < amxmodx >
#include < geoip >
#include < cstrike >
#include < chatcolor >


enum _:SteamIdData
{
    
_szName32 ],
    
_szSteamId34 ]
}

enum _:AdminRightsData
{
    
_szName32 ],
    
_iBitFlags
}

// CONFIG START

new const g_SteamIdPrefixes[ ][ SteamIdData ] = 
{
    { 
"Majitel",        "STEAM_0:0:00000000" },
    { 
"Globalny Admin",    "STEAM_0:0:00000000" }
}


new const 
g_AdminRightsPrefixes[ ][ AdminRightsData ] = 
{
    { 
"Hl. Admin",        ADMIN_IMMUNITY },
    { 
"Admin",        ADMIN_BAN },
    { 
"Apprentice",        ADMIN_KICK },
    { 
"VIP",        ADMIN_LEVEL_H },
    { 
"ExtraVIP",        ADMIN_LEVEL_G }
}

new const 
g_NormalPlayerPrefix[ ] = "Player"

// CONFIG END


/* COLORCHAT 
enum { 
    Grey = 33, 
    Red, 
    Blue 
}
*/    
new const g_szTeamNamesCsTeams ][ ] = 

    
"Spectator",
    
"Terrorist"
    
"Counter-Terrorist"
    
"Spectator" 
}


public 
plugin_init( )
{
    
register_plugin"Prefix pred jmenem""1.0""IdiotStrike" )
    
    
register_clcmd"say""_cSay" 
    
register_clcmd"say_team""_cSayTeam" )
    
    
register_clcmd"say /test""client_putinserver" )
}

public 
_cSayid )
{
    new 
szMessage192 ]
    
    
read_argsszMessagecharsmaxszMessage ) )
    
remove_quotesszMessage )
    
    if( !
UTIL_IsMessageValidszMessage ) )
        return 
PLUGIN_HANDLED
    
    
new szName32 ]
    
get_user_nameidszNamecharsmaxszName ) )
    
    new 
boolbAlive boolis_user_aliveid )
    
    new 
szTag]
    
    if( 
cs_get_user_teamid ) == CS_TEAM_SPECTATOR )
    {
        
copyszTagcharsmaxszTag ), "*SPEC* " )
    }
    else if( !
bAlive )
    {
        
copyszTagcharsmaxszTag ), "*DEAD* " )
    }
    
    new 
szPrefix32 ], szSteamId34 ]
    
get_user_authididszSteamIdcharsmaxszSteamId ) )
    
    new 
iSteamIdPrefixId = -1iAdminRightsPrefixId = -1
    
    
for( new isizeof g_SteamIdPrefixes++ )
    {
        if( 
equalszSteamIdg_SteamIdPrefixes][ _szSteamId ] ) )
        {
            
iSteamIdPrefixId i
            
break
        }
    }
    
    if( 
iSteamIdPrefixId == -)
    {
        new 
iBitFlags get_user_flagsid )
        
        for( new 
isizeof g_AdminRightsPrefixes++ )
        {
            if( 
iBitFlags g_AdminRightsPrefixes][ _iBitFlags ] )
            {
                
iAdminRightsPrefixId i
            
}
        }
    }
    
    if( 
iSteamIdPrefixId != -)
    {
        
copyszPrefixcharsmaxszPrefix ), g_SteamIdPrefixesiSteamIdPrefixId ][ _szName ] )
    }
    else if( 
iAdminRightsPrefixId != -)
    {
        
copyszPrefixcharsmaxszPrefix ), g_AdminRightsPrefixesiAdminRightsPrefixId ][ _szName ] )
    }
    else
    {
        
copyszPrefixcharsmaxszPrefix ), g_NormalPlayerPrefix )
    }
    
    new 
szMessage2192 ]
    
formatexszMessage2charsmaxszMessage2 ), "[^4%s^1] %s^3%s^1 :  %s"szPrefixszTagszNameszMessage )
    
    
    new 
aPlayers32 ], iNumidPlayer
    get_players
aPlayersiNum )
    
    new 
boolbAlive2
    
    
for( new iiNum++ )
    {
        
idPlayer aPlayers]
        
        
bAlive2 boolis_user_aliveidPlayer )
        
        if( 
bAlive != bAlive2 )
            continue
        
        
client_print_coloridPlayeridszMessage2 )
    }
    
    return 
PLUGIN_HANDLED_MAIN
}

public 
_cSayTeamid )
{
    new 
szMessage192 ]
    
    
read_argsszMessagecharsmaxszMessage ) )
    
remove_quotesszMessage )
    
    if( !
UTIL_IsMessageValidszMessage ) )
        return 
PLUGIN_HANDLED
    
    
new szName32 ]
    
get_user_nameidszNamecharsmaxszName ) )
    
    new 
boolbAlive boolis_user_aliveid )
    new 
CsTeamsiTeam cs_get_user_teamid )
    
    new 
szPrefix32 ], szSteamId34 ]
    
get_user_authididszSteamIdcharsmaxszSteamId ) )
    
    new 
iSteamIdPrefixId = -1iAdminRightsPrefixId = -1
    
    
for( new isizeof g_SteamIdPrefixes++ )
    {
        if( 
equalszSteamIdg_SteamIdPrefixes][ _szSteamId ] ) )
        {
            
iSteamIdPrefixId i
            
break
        }
    }
    
    if( 
iSteamIdPrefixId == -)
    {
        new 
iBitFlags get_user_flagsid )
        
        for( new 
isizeof g_AdminRightsPrefixes++ )
        {
            if( 
iBitFlags g_AdminRightsPrefixes][ _iBitFlags ] )
            {
                
iAdminRightsPrefixId i
            
}
        }
    }
    
    if( 
iSteamIdPrefixId != -)
    {
        
copyszPrefixcharsmaxszPrefix ), g_SteamIdPrefixesiSteamIdPrefixId ][ _szName ] )
    }
    else if( 
iAdminRightsPrefixId != -)
    {
        
copyszPrefixcharsmaxszPrefix ), g_AdminRightsPrefixesiAdminRightsPrefixId ][ _szName ] )
    }
    else
    {
        
copyszPrefixcharsmaxszPrefix ), g_NormalPlayerPrefix )
    }
    
    new 
szMessage2192 ]
    
formatexszMessage2charsmaxszMessage2 ), "[^4%s^1] %s(%s) ^3%s^1 :  %s"szPrefixbAlive "" "*DEAD* "g_szTeamNamesiTeam ], szNameszMessage )
    
    new 
aPlayers32 ], iNumidPlayer
    get_players
aPlayersiNum )
    
    new 
boolbAlive2CsTeamsiTeam2
    
    
for( new iiNum++ )
    {
        
idPlayer aPlayers]
        
        
bAlive2 boolis_user_aliveidPlayer )
        
iTeam2 cs_get_user_teamidPlayer )
        
        if( 
bAlive != bAlive2 || iTeam != iTeam2 )
            continue
        
        
client_print_coloridPlayeridszMessage2 )
    }
    
    return 
PLUGIN_HANDLED_MAIN
}

    
public 
client_putinserverid )
{
    
    new 
szName32 ], szIp15 ], szSteamId34 ], szCountry45 ]
    
    
get_user_nameidszNamecharsmaxszName ) )
    
get_user_ipidszIpcharsmaxszIp ), )
    
get_user_authididszSteamIdcharsmaxszSteamId ) )
    
geoip_countryszIpszCountrycharsmaxszCountry ) )
    
    new 
iSteamIdPrefixId = -1iAdminRightsPrefixId = -1
    
    
for( new isizeof g_SteamIdPrefixes++ )
    {
        if( 
equalszSteamIdg_SteamIdPrefixes][ _szSteamId ] ) )
        {
            
iSteamIdPrefixId i
            
break
        }
    }
    
    if( 
iSteamIdPrefixId == -)
    {
        new 
iBitFlags get_user_flagsid )
        
        for( new 
isizeof g_AdminRightsPrefixes++ )
        {
            if( 
iBitFlags g_AdminRightsPrefixes][ _iBitFlags ] )
            {
                
iAdminRightsPrefixId i
            
}
        }
    }
    
    new 
szPrefix32 ]
    
    if( 
iSteamIdPrefixId != -)
    {
        
copyszPrefixcharsmaxszPrefix ), g_SteamIdPrefixesiSteamIdPrefixId ][ _szName ] )
    }
    else if( 
iAdminRightsPrefixId != -)
    {
        
copyszPrefixcharsmaxszPrefix ), g_AdminRightsPrefixesiAdminRightsPrefixId ][ _szName ] )
    }
    else
    {
        
copyszPrefixcharsmaxszPrefix ), g_NormalPlayerPrefix )
    }
    
    
client_print_color0Grey"*^4[^3%s^4]^1* ^4%s^1 s IP ^3%s ^1 sa pripojil (^3%s^1)^1"szPrefixszNameszIpszCountry )
    
}

public 
client_disconnectid )
{
    new 
szName32 ], szSteamId34 ]
    
    
get_user_nameidszNamecharsmaxszName ) )
    
get_user_authididszSteamIdcharsmaxszSteamId ) )
    
    new 
iSteamIdPrefixId = -1iAdminRightsPrefixId = -1
    
    
for( new isizeof g_SteamIdPrefixes++ )
    {
        if( 
equalszSteamIdg_SteamIdPrefixes][ _szSteamId ] ) )
        {
            
iSteamIdPrefixId i
            
break
        }
    }
    
    if( 
iSteamIdPrefixId == -)
    {
        new 
iBitFlags get_user_flagsid )
        
        for( new 
isizeof g_AdminRightsPrefixes++ )
        {
            if( 
iBitFlags g_AdminRightsPrefixes][ _iBitFlags ] )
            {
                
iAdminRightsPrefixId i
            
}
        }
    }
    
    new 
szPrefix32 ]
    
    if( 
iSteamIdPrefixId != -)
    {
        
copyszPrefixcharsmaxszPrefix ), g_SteamIdPrefixesiSteamIdPrefixId ][ _szName ] )
    }
    else if( 
iAdminRightsPrefixId != -)
    {
        
copyszPrefixcharsmaxszPrefix ), g_AdminRightsPrefixesiAdminRightsPrefixId ][ _szName ] )
    }
    else
    {
        
copyszPrefixcharsmaxszPrefix ), g_NormalPlayerPrefix )
    }
    
    
client_print_color0Red"*^4[^3%s^4]^1* ^4%s^1 sa odpojil (^3%d^1 min.)^1"szPrefixszNameget_user_timeid ) / 60 )
    
}
    
boolUTIL_IsMessageValid( const said[ ] ) 

    for( new 
0said]; i++ )
    { 
        if( 
said] != ' ' 
        { 
            return 
true
        

    } 
     
    return 
false


Any ideas?

^SmileY 11-12-2013 19:42

Re: Colorchat not working properly
 
Simple, you are using what build of amxmodx?

because the client_print_color command it is a same from last dev build.

Backstabnoob 11-13-2013 03:06

Re: Colorchat not working properly
 
that's not the problem since other plugins work fine. I use the latest stable 1.8.2 and I'd rather not use a dev build.

kHRYSTER 11-13-2013 06:38

Re: Colorchat not working properly
 
1 Attachment(s)
Use chatcolor.inc and this lines ur sources:

PHP Code:

stock print_color(const id, const input[], any:...)
{
new 
count 1players[32]
static 
msg[191]
vformat(msg190input3)

replace_all(msg190"!g""^4")
replace_all(msg190"!y""^1")
replace_all(msg190"!t""^3")
replace_all(msg190"""á")
replace_all(msg190"""Ă")
replace_all(msg190"""Ă")
replace_all(msg190"""Ăł")
replace_all(msg190"""Ă")
replace_all(msg190"ő""Ĺ")
replace_all(msg190"""Ăş")
replace_all(msg190"""ĂĽ")
replace_all(msg190"ű""Ĺ")
replace_all(msg190"""Ă")
replace_all(msg190"""Ă")
replace_all(msg190"""ĂŤ")
replace_all(msg190"""Ă")
replace_all(msg190"""Ă")
replace_all(msg190"Ő""Ĺ")
replace_all(msg190"""Ă")
replace_all(msg190"""Ăś")
replace_all(msg190"Ű""Ĺ")
 
if (
idplayers[0] = id; else get_players(playerscount"ch")
{
for (new 
0counti++)
{
if (
is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i])
write_byte(players[i])
write_string(msg)
message_end()
}
}
}
return 
PLUGIN_HANDLED



pokemonmaster 11-13-2013 07:00

Re: Colorchat not working properly
 
Happened to me before, can't remmeber how did I fix it......
Try starting your chat message with ^4 or anything ...

Backstabnoob 11-13-2013 09:59

Re: Colorchat not working properly
 
Quote:

Originally Posted by pokemonmaster (Post 2060272)
Happened to me before, can't remmeber how did I fix it......
Try starting your chat message with ^4 or anything ...

Weird, but it seems to have solved it.

Many thanks, I feel like this should be visible somewhere though.

ConnorMcLeod 11-13-2013 10:54

Re: Colorchat not working properly
 
Message HAS to start with ^1, ^2, ^3 or ^4


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

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