
/* AMX Mod script. 
* 
* (c) Copyright 2002, OLO 
* This file is provided as is (no warranties). 
* 
*/ 

#include <amxmod> /* read this file to learn the functions */ 

#define MAX_CLR 7 

new ncolors[MAX_CLR][] = {"white","red","green","blue","yellow","magenta","cyan"} 
new vcolors[MAX_CLR][3] = {{255,255,255},{255,0,0},{0,255,0},{0,0,255},{255,255,0},{255,0,255},{0,255,255}} 

new msgchannel = 0 

public admin_chat(id) 
{ 
    if (!(get_user_flags(id)&ADMIN_CHAT)){ 
        client_print(id,print_console,"[AMX] You have no access to that command") 
        return PLUGIN_HANDLED 
    } 
    if (read_argc() < 2){  
        client_print(id,print_console,"[AMX] Usage: amx_chat < message >") 
        return PLUGIN_HANDLED 
    } 
    new message[192] 
    read_args(message,192) 
    new name[32] 
    get_user_name(id,name,32) 
    new players[32], inum 
    get_players(players,inum)
    
    new authid[16] 
    get_user_authid(id,authid,16) 
    log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" chat ^"%s^"", 
        name,get_user_userid(id),authid,message)     
    
    format(message,192,"(ADMINS) %s :   %s",name,message)
    
    for(new i = 0; i < inum; ++i)
        if (get_user_flags(players[i]))
            client_print(players[i],print_chat,message)

    return PLUGIN_HANDLED 
} 

public admin_say(id) 
{ 
    if (!(get_user_flags(id)&ADMIN_CHAT)){ 
        client_print(id,print_console,"[AMX] You have no access to that command") 
        return PLUGIN_HANDLED 
    } 
    if (read_argc() < 2){ 
        client_print(id,print_console,"[AMX] Usage: amx_say < message >") 
        return PLUGIN_HANDLED 
    } 
    new message[192] 
    read_args(message,192) 
    new name[32] 
    get_user_name(id,name,32) 
    client_print(0,print_chat,"(ALL) %s :   %s",name,message) 

    new authid[16] 
    get_user_authid(id,authid,16) 
    log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" say ^"%s^"", 
        name,get_user_userid(id),authid,message) 

    return PLUGIN_HANDLED 
} 

public admin_psay(id) 
{ 
    if (!(get_user_flags(id)&ADMIN_CHAT)){ 
        client_print(id,print_console,"[AMX] You have no access to that command") 
        return PLUGIN_HANDLED 
    } 
    if (read_argc() < 3) { 
        client_print(id,print_console,"[AMX] Usage: amx_psay < part of nick > < message in quotes >") 
        return PLUGIN_HANDLED 
    } 
    new text[32],name[32] 
    read_args(text,32) 
    parse(text,name,32) 
    new priv = find_player("b",name) 

    if (priv == 0){ 
        client_print(id,print_console,"[AMX] Client with that part of nick not found") 
        return PLUGIN_HANDLED 
    } 
     
    new length = strlen(name) 
    get_user_name(priv,name,32) 
    new message[192] 
    read_args(message,192) 
    new name2[32] 
    get_user_name(id,name2,32) 
    if (id != priv) 
        client_print(id,print_chat,"(%s) %s :   %s",name,name2,message[length]) 
    client_print(priv,print_chat,"(%s) %s :   %s",name,name2,message[length]) 

    new authid[16],authid2[16] 
    get_user_authid(id,authid,16) 
    get_user_authid(priv,authid2,16) 
    log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" psay ^"%s<%d><%s><>^" ^"%s^"", 
        name2,get_user_userid(id),authid,name,get_user_userid(priv),authid2,message) 

    return PLUGIN_HANDLED 
} 

public admin_tsay(id) 
{ 
    if (!(get_user_flags(id)&ADMIN_CHAT)){ 
        client_print(id,print_console,"[AMX] You have no access to that command") 
        return PLUGIN_HANDLED 
    } 
    if (read_argc() < 3){ 
        client_print(id,print_console,"[AMX] Usage: amx_tsay < color > < message in quotes >") 
        return PLUGIN_HANDLED 
    } 
    new color[10], message[192] 
    read_args(message,192) 
    parse(message,color,10) 
    new found = 0,a = 0,length
    for(new i=0;i<MAX_CLR;++i) 
        if (equal(color,ncolors[i])) { 
            a = i
            found = 1
            break 
        } 
    length = found ? strlen(color) : 0
    if (++msgchannel>6||msgchannel<3) 
        msgchannel = 3 
    new Float:verpos = 0.70 + float(msgchannel) / 35.0 
    new name[32] 
    get_user_name(id,name,32) 
    set_hudmessage(vcolors[a][0], vcolors[a][1], vcolors[a][2], 0.05, verpos, 0, 6.0, 6.0, 0.5, 0.15, msgchannel) 
    show_hudmessage(0,"%s :   %s",name,message[length]) 

    new authid[16] 
    get_user_authid(id,authid,16) 
    log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" tsay ^"%s^"", 
        name,get_user_userid(id),authid,message) 

    return PLUGIN_HANDLED 
} 

public plugin_init() 
{ 
		register_plugin("Admin Chat","0.5","default") 
		register_clcmd("amx_say","admin_say",ADMIN_CHAT,"amx_say < message >") 
		register_clcmd("amx_chat","admin_chat",ADMIN_CHAT,"amx_chat < message >") 
		register_clcmd("amx_psay","admin_psay",ADMIN_CHAT,"amx_psay < part of nick > < message >") 
		register_clcmd("amx_tsay","admin_tsay",ADMIN_CHAT,"amx_tsay < color > < message >") 
		return PLUGIN_CONTINUE 
} 

