AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]Again a Colorchat Problem (https://forums.alliedmods.net/showthread.php?t=144453)

One 12-04-2010 07:09

Again a Colorchat Problem
 
1 Attachment(s)
hi,

i tried to print Users name in Colorchat but idk why this not works.

PHP Code:

public startround()
{
    for ( new 
id0id g_maxPlayers;id++)
    {
        new 
users_frags get_user_frags(id)
        new 
users_deaths get_user_deaths(id
        new 
gerechnet users_frags users_deaths
        
        
new name[33]
        
get_user_name(id,name,32)
        if(
is_user_connected(id) && gerechnet >= 10 )
        {
            
ColorChat(id,RED,"\YELDu hast \GRN+%d Frags \YELund musst jetzt mit \GRNFunWaffen \YELSpielen!Schreibe \GRN/fungun \YELfuer mehr Info.",gerechnet)
            
ColorChat(0,NORMAL,"\TEM%s \YELhat +%d Frags \YELund muss jetzt mit \GRNFunWaffen \YELSpielen!",name,gerechnet)
            
ColorChat(0,NORMAL,"\TEM Das ist TEAMFARBE%s",name)
            
ColorChat(0,GREEN,"\TEM Das ist TEAMFARBE%s",name)
            
ColorChat(0,RED,"\TEM Das ist TEAMFARBE%s",name)
            
ColorChat(0,BLUE,"\TEM Das ist TEAMFARBE %s",name)
            
user_is_warned[id] = true
        
}
        else
        {
            
user_is_warned[id] = false
        
}
    }


colorchat code :

PHP Code:

ColorChatidColor:type, const szMessage[], {Float,Sql,Result,_}:... ) {
    if( !
get_playersnum( ) ) return;
    
    new 
message256 ];
    
    switch( 
type ) {
        case 
NORMALmessage[0] = 0x01;
        case 
GREENmessage[0] = 0x04;
        default: 
message[0] = 0x03;
    }
    
    
vformatmessage], 251szMessage);
    
    
message192 ] = '^0';
    
    
replace_allmessage191"\YEL""^1" );
    
replace_allmessage191"\GRN""^4" );
    
replace_allmessage191"\TEM""^3" );
    
    new 
iTeamColorChangeindexMSG_Type;
    
    if( 
id ) {
        
MSG_Type MSG_ONE_UNRELIABLE;
        
index id;
    } else {
        
index CC_FindPlayer();
        
MSG_Type MSG_BROADCAST;
    }
    
    
iTeam get_user_teamindex );
    
ColorChange CC_ColorSelection(indexMSG_Typetype);

    
CC_ShowColorMessage(indexMSG_Typemessage);
    
    if( 
ColorChange )
        
CC_Team_Info(indexMSG_TypeTeamName[iTeam]);
}

CC_ShowColorMessageidtypemessage[] ) {
    
message_begintypeg_iMsgSayText_id );
    
write_byteid );    
    
write_stringmessage );
    
message_end( );    
}

CC_FindPlayer( ) {
    for( new 
1<= g_maxPlayersi++ )
        if( 
is_user_alive(i) )
            return 
i;
    
    return -
1;
}
CC_ColorSelectionindextypeColor:Type ) {
    switch( 
Type ) {
        case 
RED: return CC_Team_InfoindextypeTeamName] );
        case 
BLUE: return CC_Team_InfoindextypeTeamName] );
    }
    
    return 
0;
}
CC_Team_Infoidtypeteam[] ) {
    
message_begintypeg_iMsgTeamInfo_id );
    
write_byteid );
    
write_stringteam );
    
message_end( );
    
    return 
1;


this should print something like this :

if is user T :

One blabla bla bla

if is user CT :

One bla bla bla bla


but what i get is just that what you can see in attached pic.

i have no idea why its so. :(
how you can see in pic. 3 of prints are in blue & only 1 is red.
user SNIPER is a T & all texts must be in RED

vato loco [GE-S] 12-04-2010 08:02

Re: Again a Colorchat Problem
 
try this
PHP Code:

public startround()
{
    new 
name[32], users_fragsusers_deathsgerechnet 
    
    
for(new id id <= g_maxPlayers id++) 
    {
        if(
is_user_connected(id))
        {
            
users_frags get_user_frags(id)
            
users_deaths get_user_deaths(id
            
gerechnet users_frags users_death
            
            
if(gerechnet >= 10)
            {
                
get_user_name(idname31)
                
                
ColorChat(id,RED,"\YELDu hast \GRN+%d Frags \YELund musst jetzt mit \GRNFunWaffen \YELSpielen!Schreibe \GRN/fungun \YELfuer mehr Info.",gerechnet)
                
ColorChat(0,NORMAL,"\TEM%s \YELhat +%d Frags \YELund muss jetzt mit \GRNFunWaffen \YELSpielen!",name,gerechnet)
                
ColorChat(0,NORMAL,"\TEM Das ist TEAMFARBE%s",name)
                
ColorChat(0,GREEN,"\TEM Das ist TEAMFARBE%s",name)
                
ColorChat(0,RED,"\TEM Das ist TEAMFARBE%s",name)
                
ColorChat(0,BLUE,"\TEM Das ist TEAMFARBE %s",name)
                
user_is_warned[id] = true
            
}
        }
        else
        {
            
user_is_warned[id] = false
        
}
    }



One 12-04-2010 11:04

Re: Again a Colorchat Problem
 
1 Attachment(s)
nope...

check the attached pic. how you can see i'm T & my nickname is BLUE :(
& your code is like mine. its the same just you check if is user alive before checking frags...its for sure better but this cant solve the print problem :(

http://i51.tinypic.com/mto7bn.jpg

i think i have to get users team by print. something like :

if(cs_get_user_team(id) == cs_team_ct)
{
colorchat(0,BLUE,.............
}
else if(cs_get_user_team(id) == cs_team_t)
{
colorchat(0,RED,.........


i hope anyone has a better idea or colorchat native :(

PHP Code:

public startround()
{
    new 
name[32], users_fragsusers_deathsgerechnet 
    
    
for(new id id <= g_maxPlayers id++) 
    {
        if(
is_user_connected(id))
        {
            
users_frags get_user_frags(id)
            
users_deaths get_user_deaths(id
            
gerechnet users_frags users_deaths
            
            
if(gerechnet >= 10)
            {
                
get_user_name(idname31)
                
                
ColorChat(id,RED,"\YELDu hast \GRN+%d Frags \YELund musst jetzt mit \GRNFunWaffen \YELSpielen!Schreibe \GRN/fungun \YELfuer mehr Info.",gerechnet)
                
//ColorChat(0,NORMAL,"\TEM%s \YELhat +%d Frags \YELund muss jetzt mit \GRNFunWaffen \YELSpielen!",name,gerechnet)
                
if(cs_get_user_team(id) == CS_TEAM_CT)
                {
                    
ColorChat(0,NORMAL,"\TEM%s \YELhat +%d Frags \YELund muss jetzt mit \GRNFunWaffen \YELSpielen!",name,gerechnet)
                }
                else if(
cs_get_user_team(id) == CS_TEAM_T)
                {
                    
ColorChat(0,RED,"\TEM%s \YELhat +%d Frags \YELund muss jetzt mit \GRNFunWaffen \YELSpielen!",name,gerechnet)
                }
                
user_is_warned[id] = true
            
}
        }
        else
        {
            
user_is_warned[id] = false
        
}
    }



abdul-rehman 12-04-2010 12:30

Re: Again a Colorchat Problem
 
Quote:

Originally Posted by One (Post 1362891)
nope...

check the attached pic. how you can see i'm T & my nickname is BLUE :(
& your code is like mine. its the same just you check if is user alive before checking frags...its for sure better but this cant solve the print problem :(

http://i51.tinypic.com/mto7bn.jpg

i think i have to get users team by print. something like :

if(cs_get_user_team(id) == cs_team_ct)
{
colorchat(0,BLUE,.............
}
else if(cs_get_user_team(id) == cs_team_t)
{
colorchat(0,RED,.........


i hope anyone has a better idea or colorchat native :(

PHP Code:

public startround()
{
    new 
name[32], users_fragsusers_deathsgerechnet 
    
    
for(new id id <= g_maxPlayers id++) 
    {
        if(
is_user_connected(id))
        {
            
users_frags get_user_frags(id)
            
users_deaths get_user_deaths(id
            
gerechnet users_frags users_deaths
            
            
if(gerechnet >= 10)
            {
                
get_user_name(idname31)
                
                
ColorChat(id,RED,"\YELDu hast \GRN+%d Frags \YELund musst jetzt mit \GRNFunWaffen \YELSpielen!Schreibe \GRN/fungun \YELfuer mehr Info.",gerechnet)
                
//ColorChat(0,NORMAL,"\TEM%s \YELhat +%d Frags \YELund muss jetzt mit \GRNFunWaffen \YELSpielen!",name,gerechnet)
                
if(cs_get_user_team(id) == CS_TEAM_CT)
                {
                    
ColorChat(0,NORMAL,"\TEM%s \YELhat +%d Frags \YELund muss jetzt mit \GRNFunWaffen \YELSpielen!",name,gerechnet)
                }
                else if(
cs_get_user_team(id) == CS_TEAM_T)
                {
                    
ColorChat(0,RED,"\TEM%s \YELhat +%d Frags \YELund muss jetzt mit \GRNFunWaffen \YELSpielen!",name,gerechnet)
                }
                
user_is_warned[id] = true
            
}
        }
        else
        {
            
user_is_warned[id] = false
        
}
    }



I think color chat uses get_user_team to retrieve user's team and then mess it for the color message and according to Conner, get_user_team can return some false results some times so it would be better to replace that part in the include file with cs_get_user_team or it would be much better to use some other color chat function to achieve what u want

vato loco [GE-S] 12-04-2010 13:22

Re: Again a Colorchat Problem
 
why don't you use simply colorchat.inc

abdul-rehman 12-04-2010 13:36

Re: Again a Colorchat Problem
 
Quote:

Originally Posted by vato loco [GE-S] (Post 1363010)
why don't you use simply colorchat.inc

It is the same thing ..
colorchat.inc also uses get_user_team which is buggy !

xPaw 12-04-2010 13:44

Re: Again a Colorchat Problem
 
Why not just put that guy as sender, simple.

One 12-04-2010 15:40

Re: Again a Colorchat Problem
 
1 Attachment(s)
ok ty for posts.
i got it but there a problem again :

Code:

ColorChat(0,TEAM_COLOR,"%s ^x01hat ^x04+%d Frags ^x01und muss jetzt mit ^x04FunWaffen ^x01Spielen!",name,gerechnet)
Printed text = User hat XX Frags und muss jetzt mit Ounwaffen spielen!

should be = user hat XX Frags und muss jetzt mit Funwaffen spielen!

idk why F willbe replaced to O ????!!

xPaw 12-04-2010 16:27

Re: Again a Colorchat Problem
 
mit^x04 F

One 12-04-2010 16:29

Re: Again a Colorchat Problem
 
yop. ty Xpaw. its now done :D


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

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