Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#include < colorchat >
#define GetTeam(%1) get_pdata_int(%1,114,5)
#define Print(%1,%2) client_print_color(%1,DontChange,%2)
new const Plugin[ ] = "Deathrun - Free Round";
new const Version[ ] = "0.0.2";
const m_ToggleState = 41;
new bool:g_bFreeRound = false;
new bool:g_bUsedTrap = false;
public plugin_init( )
{
register_plugin( Plugin , Version , "Devil" );
register_clcmd( "say /free" , "ClientCommand_FreeRound" );
RegisterHam( Ham_Use , "func_rot_button" , "fwHamUseTrap" );
RegisterHam( Ham_Use , "func_button" , "fwHamUseTrap" );
RegisterHam( Ham_Use , "button_target" , "fwHamUseTrap" );
RegisterHam( Ham_Spawn , "player" , "fwHamSpawnPost" , true );
register_event( "CurWeapon", "evCurWeapon" , "be" , "1=1" , "2!29" );
register_event( "HLTV" , "StopFreeRound" , "a" , "1=0" , "2=0" );
register_event( "TextMsg" , "StopFreeRound" , "a" , "2&#Game_C" , "2&#Game_w" );
register_logevent( "StopFreeRound" , 2 , "1=Round_End" );
}
public ClientCommand_FreeRound( id )
{
if( is_user_alive( id ) )
{
if( GetTeam( id ) == 1 )
{
if( g_bUsedTrap )
Print( id , "^3You have already actived a trap, you can't start a free round." );
else if( !g_bFreeRound )
StartFreeRound( id );
}
else
{
Print( id , "^3You have to be terrorist to start a free round." );
return PLUGIN_HANDLED;
}
}
else
{
Print( id , "^3You have to be alive to start a free round." );
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
public fwHamUseTrap( iEntity , id , iActivator , iUseType , Float:flValue )
{
if( is_user_alive( id ) && GetTeam( id ) == 1 )
{
if( g_bFreeRound )
{
if( iUseType == 2 && flValue == 1.0 && get_pdata_int( iEntity , m_ToggleState , 4 ) == 1 )
{
return HAM_SUPERCEDE;
}
}
else
{
if( !g_bUsedTrap )
g_bUsedTrap = true;
}
}
return HAM_IGNORED;
}
public fwHamSpawnPost( id )
{
if( is_user_alive( id ) && GetTeam( id ) == 1 )
set_task( 0.2 , "SayCanFree" , id );
}
public SayCanFree( id )
{
Print( id , "Type^3 /free ^1to start a ^3free round^1." );
}
public evCurWeapon( id )
{
if( g_bFreeRound )
engclient_cmd( id , "weapon_knife" );
}
StartFreeRound( id )
{
new szName[ 32 ];
get_user_name( id , szName , charsmax( szName ) );
Print( 0 , "^3%s ^1 start a ^4free round^1. ^3No weapons^1, ^3no traps^1." , szName );
g_bFreeRound = true;
}
public StopFreeRound( )
{
g_bFreeRound = false;
g_bUsedTrap = false;
}