Raised This Month: $32 Target: $400
 8% 

CS Color Chat Function Updated:[01/26/2007]


Post New Thread Reply   
 
Thread Tools Display Modes
LaineN
Veteran Member
Join Date: Mar 2008
Location: Sweden
Old 06-02-2009 , 08:37   Re: CS Color Chat Function Updated:[01/26/2007]
Reply With Quote #61

Code:
ColorChat(id, GREY, "^x04Clanname^x03 Lucky you! You got a scout with 0 bullets!");
__________________
Bollnas Team - HideNSeek

See all of Bollnas Team's HideNSeek
servers at
http://bollnasteam.se/!


Last edited by LaineN; 06-02-2009 at 08:40.
LaineN is offline
FiFiX
Senior Member
Join Date: May 2008
Location: Poland
Old 10-03-2010 , 14:33   Re: CS Color Chat Function Updated:[01/26/2007]
Reply With Quote #62

Code:
L 10/03/2010 - 19:28:52: [AMXX] Run time error 4: index out of bounds 
L 10/03/2010 - 19:28:52: [AMXX]    [0] colorchat.inc::ColorChat (line 76)
Using GREY color...

OFC message shows on server without problems

Using that as include:
Code:
/* Fun functions
*
* by Numb
*
* This file is provided as is (no warranties).
*/

#if defined _colorchat_included
  #endinput
#endif
#define _colorchat_included

enum Color
{
    NORMAL = 1, // clients scr_concolor cvar color
    GREEN, // Green Color
    TEAM_COLOR, // Red, grey, blue
    GREY, // grey
    RED, // Red
    BLUE, // Blue
}

new const TeamName[][] = 
{
    "",
    "TERRORIST",
    "CT",
    "SPECTATOR"
}

ColorChat(id, Color:type, const msg[], any:...)
{
    new message[256];

    switch(type)
    {
        case NORMAL: // clients scr_concolor cvar color
        {
            message[0] = 0x01;
        }
        case GREEN: // Green
        {
            message[0] = 0x04;
        }
        default: // White, Red, Blue
        {
            message[0] = 0x03;
        }
    }

    vformat(message[1], 251, msg, 4);

    // Make sure message is not longer than 192 character. Will crash the server.
    message[192] = '^0';

    new team, ColorChange, index, MSG_Type;
    
    if(id)
    {
        MSG_Type = MSG_ONE_UNRELIABLE;
        index = id;
    } else {
        index = FindPlayer();
        MSG_Type = MSG_BROADCAST;
    }
    
    team = get_user_team(index);
    ColorChange = ColorSelection(index, MSG_Type, type);
    
    replace_colors(message, 191);

    ShowColorMessage(index, MSG_Type, message);
        
    if(ColorChange)
    {
        Team_Info(index, MSG_Type, TeamName[team]);
    }
}

replace_colors(message[], len)
{
    replace_all(message, len, "!g", "^x04");
    replace_all(message, len, "!t", "^x03");
    replace_all(message, len, "!y", "^x01");
}

ShowColorMessage(id, type, message[])
{
    static msgSayText;
    if(!msgSayText)
    {
        msgSayText = get_user_msgid("SayText");
    }
    message_begin(type, msgSayText, _, id);
    write_byte(id)        
    write_string(message);
    message_end();    
}

Team_Info(id, type, team[])
{
    static msgTeamInfo;
    if(!msgTeamInfo)
    {
        msgTeamInfo = get_user_msgid("TeamInfo");
    }
    message_begin(type, msgTeamInfo, _, id);
    write_byte(id);
    write_string(team);
    message_end();

    return 1;
}

ColorSelection(index, type, Color:Type)
{
    switch(Type)
    {
        case RED:
        {
            return Team_Info(index, type, TeamName[1]);
        }
        case BLUE:
        {
            return Team_Info(index, type, TeamName[2]);
        }
        case GREY:
        {
            return Team_Info(index, type, TeamName[0]);
        }
    }

    return 0;
}

FindPlayer()
{
    new i = -1;

    while(i <= get_maxplayers())
    {
        if(is_user_connected(++i))
            return i;
    }

    return -1;
}
Sloved... Just checked if user was connected ;]

Last edited by FiFiX; 10-04-2010 at 09:27.
FiFiX is offline
Send a message via Skype™ to FiFiX
bibu
Veteran Member
Join Date: Sep 2010
Old 12-26-2010 , 18:12   Re: CS Color Chat Function Updated:[01/26/2007]
Reply With Quote #63

ColorChat(0, RED, "^x03HI");

How can I print this only to the team of the caller? ( id )
bibu is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-26-2010 , 18:21   Re: CS Color Chat Function Updated:[01/26/2007]
Reply With Quote #64

Not possible, you have to loop through all teamates.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 12-26-2010 , 19:14   Re: CS Color Chat Function Updated:[01/26/2007]
Reply With Quote #65

Lol, didn't think of loop.
How can I check then if the callers (id) team is the same as other teammates in a loop?
bibu is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 12-27-2010 , 06:42   Re: CS Color Chat Function Updated:[01/26/2007]
Reply With Quote #66

Ah, I didn't think very well I think, got it now..
If anyone needs it:

PHP Code:
        if(cs_get_user_team(id) == CS_TEAM_T)
    {
        new 
iPlayers[MAXSLOTS], iNumid 
        get_players
(iPlayersiNum)
    
        for(new 
ii<iNumi++) 
        { 
            
id iPlayers[i]
            
            if(
cs_get_user_team(id) == CS_TEAM_T)
            {
                
ColorChat(idRED"^x03This message should be shown only to terrorists.");
            }
        }
    } 
bibu is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-27-2010 , 07:51   Re: CS Color Chat Function Updated:[01/26/2007]
Reply With Quote #67

This is not related to colorchat anymore, would better to post in scripting/help forum.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
rx1983
Senior Member
Join Date: Jan 2009
Location: BRASIL
Old 12-19-2011 , 18:03   Re: CS Color Chat Function Updated:[01/26/2007]
Reply With Quote #68

I can not understand why not work for me.

__________________
rx1983 is offline
Send a message via MSN to rx1983
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 10-19-2014 , 20:58   Re: CS Color Chat Function Updated:[01/26/2007]
Reply With Quote #69

when its shows the message its logging this Error. this happens and to other plugins when i include ColorChat

[AMXX] Displaying debug trace (plugin "zp_aps_leader.amxx")
L 10/19/2014 - 00:22:40: [AMXX] Run time error 4: index out of bounds
L 10/19/2014 - 00:22:40: [AMXX] [0] ColorChat.inc::ColorChat (line 70)
L 10/19/2014 - 00:22:40: [AMXX] [1] zp_aps_leader.sma::Leader (line 67)

PHP Code:
public Leader()
{
    if ( 
get_pcvar_num(leader_msj) == || get_pcvar_num(leader_msj) == )
    {
        new 
iAmmoPacks
        
new iLeader GetLeader_Ammo(iAmmoPacks)
        new 
Players UsersGetPlaying()
        new 
iPlayers[32], iNumOthers
        
new szName[32]
        
get_user_nameiLeaderszName31 )
        
get_playersiPlayersiNum"ch" )
       
        if ( 
Players == )
            
ColorChat0GREY"^x04[StreetZM]^x01 There are not players connected." )
        else if ( 
iAmmoPacks == Others )
            
ColorChat0GREY"^x04[StreetZM]^x01 There is no leader." )
        else
            
ColorChat0GREY"^x04[StreetZM]^x01 The packs leader is^x03 %s^x01 @^x04 %d Packs."szNameiAmmoPacks )
    }
    
set_task(0.1"Leader_Frags")

line 67

PHP Code:
ColorChat0GREY"^x04[StreetZM]^x01 The packs leader is^x03 %s^x01 @^x04 %d Packs."szNameiAmmoPacks 
ColorChat.INC

PHP Code:
/* Fun functions
*
* by Numb
*
* This file is provided as is (no warranties).
*/


enum Color
{
    
NORMAL 1// clients scr_concolor cvar color
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

new 
TeamName[][] = 
{
    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}

ColorChat(idColor:type, const msg[], {Float,Sql,Result,_}:...)
{
    static 
message[256];

    switch(
type)
    {
        case 
NORMAL// clients scr_concolor cvar color
        
{
            
message[0] = 0x01;
        }
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        default: 
// White, Red, Blue
        
{
            
message[0] = 0x03;
        }
    }

    
vformat(message[1], 251msg4);

    
// Make sure message is not longer than 192 character. Will crash the server.
    
message[192] = '^0';

    static 
teamColorChangeindexMSG_Type;
    
    if(
id)
    {
        
MSG_Type MSG_ONE;
        
index id;
    } else {
        
index FindPlayer();
        
MSG_Type MSG_ALL;
    }
    
    
team get_user_team(index);
    
ColorChange ColorSelection(indexMSG_Typetype);

    
ShowColorMessage(indexMSG_Typemessage);
        
    if(
ColorChange)
    {
        
Team_Info(indexMSG_TypeTeamName[team]);
    }
}

ShowColorMessage(idtypemessage[])
{
    
message_begin(typeget_user_msgid("SayText"), _id);
    
write_byte(id)        
    
write_string(message);
    
message_end();    
}

Team_Info(idtypeteam[])
{
    
message_begin(typeget_user_msgid("TeamInfo"), _id);
    
write_byte(id);
    
write_string(team);
    
message_end();

    return 
1;
}

ColorSelection(indextypeColor:Type)
{
    switch(
Type)
    {
        case 
RED:
        {
            return 
Team_Info(indextypeTeamName[1]);
        }
        case 
BLUE:
        {
            return 
Team_Info(indextypeTeamName[2]);
        }
        case 
GREY:
        {
            return 
Team_Info(indextypeTeamName[0]);
        }
    }

    return 
0;
}

FindPlayer()
{
    static 
i;
    
= -1;

    while(
<= get_maxplayers())
    {
        if(
is_user_connected(++i))
        {
            return 
i;
        }
    }

    return -
1;

line 70 , exactly Team_info(....

PHP Code:
if(ColorChange)
    {
        
Team_Info(indexMSG_TypeTeamName[team]);
    } 
__________________
ghost95v is offline
Send a message via Skype™ to ghost95v
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 07:12.


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