/* Plugin generated by AMXX-Studio */
#include < amxmodx >
#include < cstrike >
#include < fakemeta >
#pragma semicolon 1
#define RADAR_DELAY 1.0
#define is_player(%1) (1 <= %1 <= 32)
new const
PLUGIN_NAME[ ] = "AntiFurien Radar",
PLUGIN_VERSION[ ] = "0.2.0";
new const
PLUGIN_TAG[ ] = "|AMXX:",
RADAR_SOUND[ ] = "misc/motion.wav";
new g_iCvarMinFurienSpeed;
new g_iCvarRadarRange;
new g_iCvarCost;
new g_iCvarCostTwo;
new g_iMaxPlayers;
new Float:g_fCurrentTime;
new Float:g_fNextRadarTime[ 33 ];
new bool:g_bUserHasRadar[ 33 ];
new bool:g_bUserHasProtection[ 33 ];
new bool:g_bDrawFurienOnRadar[ 33 ];
new g_iMsgIdHostageK;
new g_iMsgIdHostagePos;
public plugin_precache( )
{
precache_sound( RADAR_SOUND );
}
public plugin_init( )
{
register_plugin( PLUGIN_NAME, PLUGIN_VERSION, "Askhanar" );
g_iCvarMinFurienSpeed = register_cvar( "afr_minspeed", "100" );
g_iCvarRadarRange = register_cvar( "afr_range", "850" );
g_iCvarCost = register_cvar( "afr_radar_cost", "14000" );
g_iCvarCostTwo = register_cvar( "afr_protection_cost", "16000" );
register_clcmd( "say /afradar", "ClCmdSayRadar" );
register_clcmd( "say /afr", "ClCmdSayRadar" );
register_clcmd( "say /afrprotection", "ClCmdSayProtection" );
register_clcmd( "say /afrp", "ClCmdSayProtection" );
register_event( "DeathMsg", "EventDeathMsg", "a" );
register_forward( FM_PlayerPreThink, "fw_PlayerPreThinkPre", false );
g_iMsgIdHostageK = get_user_msgid( "HostageK" );
g_iMsgIdHostagePos = get_user_msgid( "HostagePos" );
g_iMaxPlayers = get_maxplayers( );
// Add your code here...
}
public ClCmdSayRadar( id )
{
if( cs_get_user_team( id ) != CS_TEAM_CT )
{
client_print( id, print_chat, "%s Only AntiFuriens are allowed to buy this!", PLUGIN_TAG );
return PLUGIN_CONTINUE;
}
if( !is_user_alive( id ) )
{
client_print( id, print_chat, "%s You need to be alive!", PLUGIN_TAG );
return PLUGIN_CONTINUE;
}
if( g_bUserHasRadar[ id ] )
{
client_print( id, print_chat, "%s You already have one!", PLUGIN_TAG );
return PLUGIN_CONTINUE;
}
new iCost = get_pcvar_num( g_iCvarCost );
new iMoney = cs_get_user_money( id );
if( iMoney < iCost )
{
client_print( id, print_chat, "%s You have not enough money, you need $%i more!", PLUGIN_TAG, iCost - iMoney );
return PLUGIN_CONTINUE;
}
g_bUserHasRadar[ id ] = true;
cs_set_user_money( id, iMoney - iCost );
client_print( id, print_chat, "%s You are now detecting near furiens, watch your radar!", PLUGIN_TAG );
return PLUGIN_CONTINUE;
}
public ClCmdSayProtection( id )
{
if( cs_get_user_team( id ) != CS_TEAM_T )
{
client_print( id, print_chat, "%s Only Furiens are allowed to buy this!", PLUGIN_TAG );
return PLUGIN_CONTINUE;
}
if( !is_user_alive( id ) )
{
client_print( id, print_chat, "%s You need to be alive!", PLUGIN_TAG );
return PLUGIN_CONTINUE;
}
if( g_bUserHasProtection[ id ] )
{
client_print( id, print_chat, "%s You already have one!", PLUGIN_TAG );
return PLUGIN_CONTINUE;
}
new iCost = get_pcvar_num( g_iCvarCostTwo );
new iMoney = cs_get_user_money( id );
if( iMoney < iCost )
{
client_print( id, print_chat, "%s You have not enough money, you need $%i more!", PLUGIN_TAG, iCost - iMoney );
return PLUGIN_CONTINUE;
}
g_bUserHasProtection[ id ] = true;
cs_set_user_money( id, iMoney - iCost );
client_print( id, print_chat, "%s You are now protected against AntiFurien's radar!", PLUGIN_TAG );
return PLUGIN_CONTINUE;
}
public client_putinserver( id )
{
g_bUserHasRadar[ id ] = false;
g_bUserHasProtection[ id ] = false;
g_bDrawFurienOnRadar[ id ] = false;
}
public client_disconnect( id )
{
g_bUserHasRadar[ id ] = false;
g_bUserHasProtection[ id ] = false;
g_bDrawFurienOnRadar[ id ] = false;
}
public EventDeathMsg( )
{
static id;
id = read_data( 2 );
g_bUserHasRadar[ id ] = false;
g_bUserHasProtection[ id ] = false;
g_bDrawFurienOnRadar[ id ] = false;
}
public fw_PlayerPreThinkPre( id )
{
if( !is_user_alive( id ) )
return FMRES_IGNORED;
g_fCurrentTime = get_gametime( );
if( cs_get_user_team( id ) == CS_TEAM_CT && g_bUserHasRadar[ id ] )
{
if( g_fNextRadarTime[ id ] <= g_fCurrentTime )
{
g_fNextRadarTime[ id ] = g_fCurrentTime + RADAR_DELAY;
static bool:bBeep;
bBeep = false;
for( new iFurien = 1; iFurien <= g_iMaxPlayers; iFurien++ )
{
if( g_bDrawFurienOnRadar[ iFurien ] )
{
if( !g_bUserHasProtection[ iFurien ] )
{
static Float:fOrigin[ 3 ];
pev( iFurien, pev_origin, fOrigin );
UTIL_ShowOnRadar( id, iFurien, fOrigin );
}
bBeep = true;
}
}
if( bBeep )
client_cmd( id, "spk %s", RADAR_SOUND );
}
}
else if( cs_get_user_team( id ) == CS_TEAM_T )
{
static Float:fFurienOrigin[ 3 ];
pev( id, pev_origin, fFurienOrigin );
static Float:fVelocity[ 3 ];
pev( id, pev_velocity, fVelocity );
static Float:fCurSpeed;
fCurSpeed = vector_length( fVelocity );
if( fCurSpeed > float( get_pcvar_num( g_iCvarMinFurienSpeed ) ) )
{
static iAnti;
for( iAnti = 1; iAnti <= g_iMaxPlayers; iAnti++ )
{
if( cs_get_user_team( iAnti ) == CS_TEAM_CT && is_user_alive( iAnti ) && is_player(iAnti))
{
static Float:fAntiOrigin[ 3 ];
pev( iAnti, pev_origin, fAntiOrigin );
if( get_distance_f( fFurienOrigin, fAntiOrigin ) <= float( get_pcvar_num( g_iCvarRadarRange ) ) )
{
g_bDrawFurienOnRadar[ id ] = true;
break;
}
}
}
}
else
{
g_bDrawFurienOnRadar[ id ] = false;
}
}
return FMRES_IGNORED;
}
UTIL_ShowOnRadar( id, iTarget, Float:fOrigin[ 3 ] )
{
//Make a dot on players radar.
message_begin( MSG_ONE_UNRELIABLE, g_iMsgIdHostagePos, .player = id );
write_byte( id );
write_byte( iTarget );
engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] );
message_end( );
//Make the dot red.
message_begin( MSG_ONE_UNRELIABLE, g_iMsgIdHostageK, .player = id );
write_byte( iTarget );
message_end( );
}