AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Color Chat problem (https://forums.alliedmods.net/showthread.php?t=228744)

Jhob94 10-26-2013 07:46

Color Chat problem
 
Hi, iam using color chat by connormcleod.
The message isnt displayed, can someone fix it?

PHP Code:

public Hook_Say(id)
{
    if(!
is_user_connected(id))
        return 
PLUGIN_CONTINUE
        
    
static said[190]
    
read_args(saidcharsmax(said))
    
remove_quotes(said)
    
    if(
equal(said"") || containi(said"%s%s%s") != 1)
        return 
PLUGIN_HANDLED
        
    
new name[34], msg[190], prefix[10]
    
get_user_name(idnamecharsmax(name))
    
    if(
Zombie[id])
        
formatex(prefixcharsmax(prefix), "[ZOMBIE]")
    
    else
    {
        if(
Hero[id])
            
formatex(prefixcharsmax(prefix), "[HERO]")
            
        else
            
formatex(prefixcharsmax(prefix), "[HUMAN]")
    }
    
    
formatex(msgcharsmax(msg), "^4%s ^3%s^1: %s"prefixnamesaid)
        
    if(!
is_user_alive(id))
        
formatex(msgcharsmax(msg), "^1*DEAD* %s"msg)
    
    if(
Zombie[id])
        
client_print_color(0RED"%s"msg)
        
    else
        
client_print_color(0BLUE"%s"msg)
    
    return 
PLUGIN_HANDLED



ConnorMcLeod 10-26-2013 08:09

Re: Color Chat problem
 
Code is correct excepted that line :

PHP Code:

formatex(msgcharsmax(msg), "^1*DEAD* %s"msg

You should use format there instead of formatex.


Anyway, why don't you try amxx 1.8.3 ?

Jhob94 10-26-2013 09:03

Re: Color Chat problem
 
Quote:

Originally Posted by ConnorMcLeod (Post 2053105)
Code is correct excepted that line :

PHP Code:

formatex(msgcharsmax(msg), "^1*DEAD* %s"msg

You should use format there instead of formatex.

Will try, thanks :)

Quote:

Originally Posted by ConnorMcLeod (Post 2053105)
Anyway, why don't you try amxx 1.8.3 ?

Isnt oficial version. I only use it in my test server.

EDIT:
It still not showing :3

ConnorMcLeod 10-26-2013 09:22

Re: Color Chat problem
 
You could shorten code like this though :

PHP Code:

public Hook_Say(id)
{
    static 
said[190];
    
read_args(saidcharsmax(said));
    
remove_quotes(said);

    if( !
said[0] || containi(said"%s%s") != 1)
    {
        return 
PLUGIN_HANDLED;
    }

    new 
name[32];
    
get_user_name(idnamecharsmax(name));

    
client_print_color(0Zombie[id] ? Red Blue"%s^4[%s] ^3%s^1: %s"
                                                    
is_user_alive(id) ? "" "^1*DEAD* "
                                                        
Zombie[id] ? "ZOMBIE" Hero[id] ? "HERO" "HUMAN",
                                                                
name,
                                                                        
said);

    return 
PLUGIN_HANDLED_MAIN// so chat cmds gonna work.



Jhob94 10-26-2013 09:39

Re: Color Chat problem
 
Doesnt works too :3

Edit:
Maybe because iam not really doing as i showed before:
PHP Code:

#define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
#define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
#define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))

public plugin_init() 
{
    
register_clcmd("say""Hook_Say");
    
register_clcmd("say_team""Hook_Say");
}

public 
Hook_Say(id)
{
    static 
said[190];
    
read_args(saidcharsmax(said));
    
remove_quotes(said);
    
    if(!
said[0] || containi(said"%s%s") != 1)
        return 
PLUGIN_HANDLED;
    
    new 
name[32];
    
get_user_name(idnamecharsmax(name));
    
    
client_print_color(0Get_BitVar(g_IsZombieid) ? Red Blue"%s^4[%s] ^3%s^1: %s"
                                                    
is_user_alive(id) ? "" "^1*DEAD* "
                                                        
Get_BitVar(g_IsZombieid) ? "ZOMBIE" Get_BitVar(g_BecomeHeroid) ? "HERO" "HUMAN",
                                                                
name,
                                                                        
said);
    
    return 
PLUGIN_HANDLED_MAIN// so chat cmds gonna work.



tonykaram1993 10-26-2013 10:19

Re: Color Chat problem
 
We need more information. What is not working? The message is not shown at all? Do you get error logs? Are you using version 1.8.3? We can't simply guess what the problem is whithout you giving us some information.

ConnorMcLeod 10-26-2013 11:05

Re: Color Chat problem
 
Your error, from the begining you are checking containi against 1 instead of -1

Following code works fine for me :

Note that you can use player index as color.

PHP Code:

#include < amxmodx >

#pragma semicolon 1

#define PLUGIN ""
#define VERSION "0.0.1"

#define cm(%0)    ( sizeof(%0) - 1 )

public plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" );

    
register_clcmd("say""Host_Say"0);
    
register_clcmd("say_team""Host_Say"1);
}

public 
Host_Say(id)
{
    static 
said[190];
    
read_args(saidcharsmax(said));
    
remove_quotes(said);

    if( !
said[0] || containi(said"%s%s") != -)
    {
        return 
PLUGIN_HANDLED;
    }

    new 
name[32];
    
get_user_name(idnamecharsmax(name));
    new 
team get_user_team(id);

    
client_print_color(0id"%s^4[%s] ^3%s^1: %s"
                                                    
is_user_alive(id) ? "" "^1*DEAD* "
                                                        
team == "ZOMBIE" random(2) ? "HERO" "HUMAN",
                                                                
name,
                                                                        
said);

    return 
PLUGIN_HANDLED_MAIN// so chat cmds gonna work.



Jhob94 10-26-2013 11:30

Re: Color Chat problem
 
Quote:

Originally Posted by tonykaram1993 (Post 2053145)
We need more information. What is not working? The message is not shown at all? Do you get error logs? Are you using version 1.8.3? We can't simply guess what the problem is whithout you giving us some information.

my error files has ~500mb and i cant open it for check out what are the errors. The mod isnt mine and since i got it, it has all that errors that i have no idea wich are...

Quote:

Originally Posted by ConnorMcLeod (Post 2053158)
Your error, from the begining you are checking containi against 1 instead of -1

How i didnt saw that :shock:

Quote:

Originally Posted by ConnorMcLeod (Post 2053158)
Note that you can use player index as color.

I know, but on round start teams are balanced and Humans can be in terro team, thats the why i am doing this way :wink:

Thanks both :up:


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

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