Hey guys, I recently made this plugin for my server, and everything looked and worked well.
Today I entered a server and for everyone else it worked perfectly, but for me, I had the default say ( Like it returned continue ). Then my brother joined and he had the default say and everything was working fine for me.
Im loosing my mind and have no clue whats happening, please help.
Also please dont answer me something on the lines of "There is a plugin for this already" We had some problems with those so i made this one which does exactly what i need, no reason to use anything more. But if there are any code errors please be sure to point them out!
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include < colorchat >
#pragma semicolon 1
new const plugin[] = "chat",
version[] = "1.4",
author[] = "maqi";
#define ADMIN_FLAGS ADMIN_BAN
#define VIP_FLAGS ADMIN_LEVEL_C
new const ADMIN_PREFIX[] = "[Admin]",
VIP_PREFIX[] = "[Vip]";
new bool:hasPrefix[32] = true;
new Color:iColor;
public plugin_init()
{
register_plugin( plugin, version, author );
register_clcmd( "say", "SayRegistered" );
register_clcmd( "say_team", "SayRegistered" );
}
public client_authorized( id )
hasPrefix[ id ] = true;
public SayRegistered( id )
{
new said[192],
player[32],
team[20],
cmd[9],
arg1[9],
prefix[8],
dead[8];
read_argv( 0, cmd, charsmax(cmd) );
read_argv( 1, arg1, charsmax(arg1) );
read_args( said, charsmax(said) );
remove_quotes( said );
get_user_name( id, player, charsmax(player) );
if( equali( arg1, "/prefix" ) )
PrefixToggle( id );
if( said[0] == '/' || equali( said, "" ) )
return PLUGIN_HANDLED;
if( get_user_flags( id ) & ADMIN_FLAGS && hasPrefix[ id ] )
copy( prefix, charsmax(prefix), ADMIN_PREFIX );
else if ( get_user_flags( id ) & VIP_FLAGS && hasPrefix[ id ] )
copy( prefix, charsmax(prefix), VIP_PREFIX );
else
copy( prefix, charsmax(prefix), "" );
if( get_user_team( id ) == 3 )
copy( dead, charsmax(dead), " SPEC " );
else if( !is_user_alive( id ) )
copy( dead, charsmax(dead), " DEAD " );
else
copy( dead, charsmax(dead), "" );
switch ( get_user_team( id ) )
{
case 1:
{
if( equal( cmd, "say_team") )
copy( team, charsmax(team), "(Terrorist)" );
iColor = RED;
}
case 2:
{
if( equal( cmd, "say_team") )
copy( team, charsmax(team), "(Counter-Terrorist)" );
iColor = BLUE;
}
case 3:
{
if( equal( cmd, "say_team") )
copy( team, charsmax(team), "(Spectator)" );
iColor = GREEN;
}
default:
return PLUGIN_CONTINUE;
}
new sFormat[192];
if( !is_user_alive( id ) )
format( sFormat, charsmax(sFormat), "^x04%s^x01%s%s^x03%s: ^x01%s", prefix, dead, team, player, said );
else if( ( get_user_flags( id ) & ADMIN_FLAGS || get_user_flags( id ) & VIP_FLAGS || equal( cmd, "say_team") ) && hasPrefix[ id ] )
format( sFormat, charsmax(sFormat), "^x04%s^x01%s%s^x03 %s: ^x01%s", prefix, dead, team, player, said );
else
format( sFormat, charsmax(sFormat), "^x04%s^x01%s%s^x03%s: ^x01%s", prefix, dead, team, player, said );
if( equal( cmd, "say_team") )
{
new pnum,
players[32];
get_players( players,pnum );
for( new i;i < pnum;i++ )
{
if( get_user_team( id ) == get_user_team( player[i] ) || get_user_flags( player[i] ) & ADMIN_FLAGS )
ColorChat( players[i] , iColor, sFormat );
}
}
ColorChat( 0, iColor, sFormat );
return PLUGIN_HANDLED;
}
public PrefixToggle( id )
{
if( get_user_flags( id ) & ADMIN_FLAGS || get_user_flags( id ) & VIP_FLAGS )
{
if( hasPrefix[ id ] )
{
hasPrefix[ id ] = false;
ColorChat( id, GREEN, "^x04[chat]^x01 Admin Prefix Disabled." );
} else {
hasPrefix[ id ] = true;
ColorChat( id, GREEN, "^x04[chat]^x01 Admin Prefix Enabled." );
}
}
}
Thanks in advance