Raised This Month: $ Target: $400
 0% 

Colorchat simple bug


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Apb hq
Senior Member
Join Date: Apr 2014
Old 05-05-2016 , 08:40   Colorchat simple bug
Reply With Quote #1

Hi everyone i have a problem with colorchat in fact team colors are bugging sometime is grey sometime red sometime blue no matter in which team you are here is the code where i used colorchat i will send you also my colorchat.inc when i come home (this ^x03 doesn't work well idk why )
PHP Code:
ColorChat0GREEN"[AMXX]^x01 Admin^x03%s^x01 Has Gagged ^x03%s^x01 from speaking ^x04%s! (say / team_say)" szAdmin,szName,szInfo
PHP Code:
ColorChat0GREEN"[AMXX]^x01 Admin^x03%s^x01 Has Ungagged ^x03%s^" ,szAdmin,szName
Apb hq is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-05-2016 , 12:03   Re: Colorchat simple bug
Reply With Quote #2

Because ^x03 is the color of the index (player), which is the first argument of the function. When you send the message to all players at once, you use the index "0" and the plugin is trying to get the team for player "0", which is invalid. When you use "id", instead of "0", there's no problem because it gets the team from "id". You should send the message to every player sepparately, by using "id" or fix the .inc file.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Apb hq
Senior Member
Join Date: Apr 2014
Old 05-05-2016 , 12:46   Re: Colorchat simple bug
Reply With Quote #3

Thanks for the answer i was thinking about that but i wasn't sure 100% i want to show this message to all players i have no idea how to fix this in colorchat.inc
Here is the code
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;

Apb hq is offline
Old 05-05-2016, 19:12
safetymoose
This message has been deleted by safetymoose. Reason: nvm
Apb hq
Senior Member
Join Date: Apr 2014
Old 05-06-2016 , 08:23   Re: Colorchat simple bug
Reply With Quote #4

Didn't work man i have the same issue here's the code with your edit help pls it's urgent in few days i won't be able to manage my server
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;
        
team get_user_team(index);
    } else {
        
index FindPlayer();
        
MSG_Type MSG_ALL;
        
team get_user_team(index);
    }
    
    
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;


Last edited by Apb hq; 05-06-2016 at 08:25.
Apb hq is offline
Old 05-06-2016, 17:44
safetymoose
This message has been deleted by safetymoose.
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 18:33.


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