Raised This Month: $ Target: $400
 0% 

ColorChat Problem..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DWIGHTpN
Senior Member
Join Date: Jan 2013
Location: Romania.
Old 05-18-2013 , 12:54   ColorChat Problem..
Reply With Quote #1

Hey.
I created this plugin:
PHP Code:
#include<amxmodx>
#include<colorchat>

#pragma semicolon 1
#define TASK_COUNT 0
new g_Message[64][129];
new 
g_ColorMS[64][5];

new 
enabled,freq;
new 
MESSAGE_COUNT 0;

public 
plugin_init()
{
    
register_plugin("ChatMessage","0.0.1","Dwight");
    
    
    
enabled register_cvar("chatm_enable","1");
    
freq register_cvar("chatm_freq","180.0");
    
register_srvcmd("amx_chatmessage","fwRegisterMessage");
    
    new 
Float:times 30.0;
    if( 
get_pcvar_float(freq) > times )
        
set_cvar_float("chatm_freq",30.0);
    
    
set_task(times"fwShowMessages",TASK_COUNT,_,_,"b");
}

public 
fwRegisterMessage()
{
    if(!
get_pcvar_num(enabled))
        return 
PLUGIN_HANDLED;
    
    new 
mesaj[129],colorm[5];
    
read_argv(1,mesaj,charsmax(mesaj));
    
read_argv(2,colorm,charsmax(colorm));
    
    
copy(g_ColorMS[MESSAGE_COUNT],4,colorm);
    
copy(g_Message[MESSAGE_COUNT],128,mesaj);
    
    
MESSAGE_COUNT++;
    
    return 
PLUGIN_HANDLED;
}

public 
fwShowMessages(task)
{
    if(!
get_pcvar_num(enabled))
    {
        
remove_task(task);
        return 
PLUGIN_HANDLED;
    }
    
    new 
x_task task;    
        
    new 
MAIN_COLOR;
    
    if( 
equali(g_ColorMS[task] ,"GREY")) MAIN_COLOR GREY;
    if( 
equali(g_ColorMS[task] ,"RED"))     MAIN_COLOR RED;
    if( 
equali(g_ColorMS[task] ,"BLUE"))     MAIN_COLOR BLUE;
    if( 
equali(g_ColorMS[task] ,"NORM"))    MAIN_COLOR DontChange;
    if( 
equali(g_ColorMS[task] ,""))     MAIN_COLOR DontChange;
    
    new 
to_chat[200];
    
format(to_chat,129,g_Message[task]);
    
    
client_print_color(0MAIN_COLORto_chat);
    
    
remove_task(x_task);
    
    new 
Float:freq_message get_pcvar_float(freq);
    
    if( 
x_task == MESSAGE_COUNT )
    {
        
x_task 0;
        
set_task(freq_message,"fwShowMessages"x_task,_,_,"b");
    }
    else
        
set_task(freq_message,"fwShowMessages"x_task+1,_,_,"b");
    
    return 
PLUGIN_CONTINUE;

This plugin show messages every freq_cvar seconds (float).
Syntax: amx_chatmessage "Try ^4test^3" "GREY"
On screen appear "Try test" , but "test" isn't green. Why?

Fine.. I solved ..
PHP Code:
#include<amxmodx>
#include<colorchat>

#pragma semicolon 1
#define TASK_COUNT 0
new g_Message[64][129];
new 
g_ColorMS[64][5];

new 
enabled,freq;
new 
MESSAGE_COUNT 0;

public 
plugin_init()
{
    
register_plugin("ChatMessage","0.0.1","Dwight");
    
    
    
enabled register_cvar("chatm_enable","1");
    
freq register_cvar("chatm_freq","180.0");
    
register_srvcmd("amx_chatmessage","fwRegisterMessage");
    
    new 
Float:times 20.0;
    if( 
get_pcvar_float(freq) > times )
        
set_cvar_float("chatm_freq",30.0);
    
    
set_task(times"fwShowMessages",TASK_COUNT,_,_,"b");
}

public 
fwRegisterMessage()
{
    if(!
get_pcvar_num(enabled))
        return 
PLUGIN_HANDLED;
    
    new 
mesaj[129],colorm[5];
    
read_argv(1,mesaj,charsmax(mesaj));
    
read_argv(2,colorm,charsmax(colorm));
    
    
replace_all(mesaj,128"&g","^4");
    
replace_all(mesaj,128"&t","^3");
    
replace_all(mesaj,128"&d","^1");
    
    
copy(g_ColorMS[MESSAGE_COUNT],4,colorm);
    
copy(g_Message[MESSAGE_COUNT],128,mesaj);
    
    
MESSAGE_COUNT++;
    
    return 
PLUGIN_HANDLED;
}

public 
fwShowMessages(task)
{
    if(!
get_pcvar_num(enabled))
    {
        
remove_task(task);
        return 
PLUGIN_HANDLED;
    }
    
    new 
x_task task;    
        
    new 
MAIN_COLOR;
    
    if( 
equali(g_ColorMS[task] ,"GREY")) MAIN_COLOR GREY;
    if( 
equali(g_ColorMS[task] ,"RED"))     MAIN_COLOR RED;
    if( 
equali(g_ColorMS[task] ,"BLUE"))     MAIN_COLOR BLUE;
    if( 
equali(g_ColorMS[task] ,"NORM"))    MAIN_COLOR DontChange;
    if( 
equali(g_ColorMS[task] ,""))     MAIN_COLOR DontChange;
    
    
    
client_print_color(0MAIN_COLOR"%s",g_Message[task]);
    
    
remove_task(x_task);
    
    new 
Float:freq_message get_pcvar_float(freq);
    
    if( 
x_task == MESSAGE_COUNT )
    {
        
x_task 0;
        
set_task(freq_message,"fwShowMessages"x_task,_,_,"b");
    }
    else
        
set_task(freq_message,"fwShowMessages"x_task+1,_,_,"b");
    
    return 
PLUGIN_CONTINUE;

Please T/C.

Last edited by DWIGHTpN; 05-18-2013 at 17:12. Reason: &solved
DWIGHTpN is offline
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 16:26.


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