bh_awardmoney - Default award money if no value is specified when bounty is started.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
new const Version[] = "0.1";
new g_iBountyPlayer;
new g_iBountyMoney , g_pHSBonus;
new g_pBountyFlags , g_pBountyAward;
public plugin_precache()
{
precache_sound( "/sound/events/task_complete.wav" );
}
public plugin_init()
{
register_plugin( "Bounty Hunter" , Version , "bugsy" );
register_logevent( "RoundEnd" , 2 , "1=Round_End" );
register_event( "DeathMsg" , "DeathMsgEvent" , "a" );
g_pBountyFlags = register_cvar( "bh_adminflags" , "e" );
g_pBountyAward = register_cvar( "bh_awardmoney" , "3000" );
g_pHSBonus = register_cvar( "bh_hsbonus" , "2000" );
register_concmd( "amx_bounty" , "BountyCmd" );
}
public BountyCmd( id )
{
if ( g_iBountyPlayer )
{
console_print( id , "There is already an active bounty, please wait until the next round or the current bounty ends." );
}
else
{
new szBountyName[ 33 ] , szBountyAmount[ 6 ] , szFlags[ 26 ] , iFlagsNeeded;
read_argv( 1 , szBountyName , charsmax( szBountyName ) );
read_argv( 2 , szBountyAmount , charsmax( szBountyAmount ) );
get_pcvar_string( g_pBountyFlags , szFlags , charsmax( szFlags ) );
iFlagsNeeded = read_flags( szFlags );
if ( ( get_user_flags( id ) & iFlagsNeeded ) == iFlagsNeeded )
{
new iPlayer = cmd_target( id , szBountyName , 0 );
if ( iPlayer )
{
new szAdminName[ 33 ];
get_user_name( id , szAdminName , charsmax( szAdminName ) );
get_user_name( iPlayer , szBountyName , charsmax( szBountyName ) );
g_iBountyPlayer = iPlayer;
g_iBountyMoney = ( szBountyAmount[ 0 ] != EOS && isdigit( szBountyAmount[ 0 ] ) ) ? str_to_num( szBountyAmount ) : get_pcvar_num( g_pBountyAward );
client_cmd( 0 ,"spk events/task_complete.wav" );
client_print( 0 , print_chat , "* %s PUT A BOUNTY ON %s's HEAD FOR $%d!" , szAdminName , szBountyName , g_iBountyMoney );
console_print( id , "Bounty created for %s for $%d" , szBountyName , g_iBountyMoney );
}
}
}
return PLUGIN_HANDLED;
}
public DeathMsgEvent()
{
if( g_iBountyPlayer )
{
new iVictim = read_data( 2 );
if ( iVictim == g_iBountyPlayer )
{
new szKiller[ 33 ] , szBountyName[ 33 ];
new iKiller = read_data( 1 );
new bool:bIsHeadshot = bool:!!read_data( 3 );
new iTotalAwardMoney = g_iBountyMoney + ( bIsHeadshot ? get_pcvar_num( g_pHSBonus ) : 0 );
client_cmd( 0 ,"spk events/task_complete.wav" );
get_user_name( iKiller , szKiller , charsmax( szKiller ) );
get_user_name( g_iBountyPlayer , szBountyName , charsmax( szBountyName ) );
cs_set_user_money( iKiller , clamp( cs_get_user_money( iKiller ) + iTotalAwardMoney , iTotalAwardMoney , 16000 ) , true );
if ( bIsHeadshot )
{
give_item( iKiller , "weapon_hegrenade" );
cs_set_user_armor( iKiller , clamp( cs_get_user_armor( iKiller ) + 100 , 0 , 100 ) , CS_ARMOR_KEVLAR );
}
client_print( 0 , print_chat , "* %s HAS EXECUTED THE BOUNTY ON %s AND WAS AWARDED $%d!" , szKiller , szBountyName , iTotalAwardMoney );
g_iBountyPlayer = 0;
}
}
}
public RoundEnd()
{
if ( g_iBountyPlayer )
{
if ( is_user_connected( g_iBountyPlayer ) )
{
new szName[ 33 ];
get_user_name( g_iBountyPlayer , szName , charsmax( szName ) );
cs_set_user_money( g_iBountyPlayer , clamp( cs_get_user_money( g_iBountyPlayer ) + g_iBountyMoney , g_iBountyMoney , 16000 ), true );
give_item( g_iBountyPlayer , "weapon_hegrenade" );
cs_set_user_armor( g_iBountyPlayer , clamp( cs_get_user_armor( g_iBountyPlayer ) + 100 , 0 , 100 ) , CS_ARMOR_KEVLAR );
client_print( 0 , print_chat , "* %s SURVIVED THE BOUNTY AND WAS AWARDED $%d!" , szName , g_iBountyMoney );
}
}
g_iBountyPlayer = 0;
}