Senior Member
Join Date: Feb 2012
Location: California
|
05-09-2017
, 20:41
Glow on CT that has bomb.
|
#1
|
I am trying to make the CT with bomb have glow so that people can know who in the CT team has the bomb but the problem is that if the CT drops the bomb, then the glow doesn't disappear and even if the CT dies and has the bomb, the glow doesn't disappear. Please help me.
PHP Code:
#include <amxmodx>
#include <orpheu_memory>
#include <orpheu_stocks>
#include <engine>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#pragma tabsize 0
#define get_mp_pdata(%1) ( OrpheuMemoryGetAtAddress ( g_pGameRules, %1 ) )
#define set_mp_pdata(%1,%2) ( OrpheuMemorySetAtAddress ( g_pGameRules, %1, 1, %2 ) )
#define m_pActiveItem 373
#define m_pNext 42
#define CSW_C4_SLOT 5
#define XO_CWEAPONBOX 4
#define XO_CBASEPLAYERITEM 4
#define MAX_DELAY 60
#define MAX_TIMER 540
#define MAX_MULTIPLIER 5.0
new const m_rgpPlayerItems_CBasePlayer[6] = { 367 , 368 , ... };
new const m_rgpPlayerItems_CWeaponBox[6] = { 34 , 35 , ... };
new bool: toggle_PreThink, bool: type_value, bool: MODE_NOSTEAL;
new bt_msgid, rt_msgid, sc_msgid, si_msgid, sinfo_msgid, g_pGameRules;
new delaytimer_cvar, type_cvar, countdown_cvar, multiplier_cvar, delaytimer_value, countdown_value, round_timeleft, update_timer, has_Delay, has_C4;
new Float: round_timestart, Float: DelayStore, Float: LastDelay, Float: multiplier_value;
new thief[64];
new HamHook: handle_PreThink;
public plugin_init ( )
{
register_plugin ( "Steal C4", "1.2", "Souvik" );
register_cvar ( "sc4_version", "1.2", FCVAR_SERVER );
if ( find_ent_by_class ( -1, "func_bomb_target" ) || find_ent_by_class ( -1, "info_bomb_target" ) )
{
handle_PreThink = RegisterHam ( Ham_Player_PreThink, "player", "Ham_PreThink", false );
DisableHamForward ( handle_PreThink );
register_touch ( "weaponbox", "player", "C4_Touch" );
register_event ( "DeathMsg", "DeathMsg" , "a" );
register_message ( get_user_msgid ( "TextMsg" ), "TextMsg" );
register_logevent ( "Round_End", 2, "1=Round_End" );
register_logevent ( "Round_Start", 2, "1=Round_Start" );
register_logevent ( "Dropped_The_Bomb", 3, "2=Dropped_The_Bomb" );
delaytimer_cvar = register_cvar ( "steal_delaytimer", "1" );
type_cvar = register_cvar ( "steal_type", "1" )
countdown_cvar = register_cvar ( "steal_timer", "35" );
multiplier_cvar = register_cvar ( "steal_multiplier", "1.5" );
bt_msgid = get_user_msgid ( "BarTime" );
rt_msgid = get_user_msgid ( "RoundTime" );
sc_msgid = get_user_msgid ( "Scenario" );
si_msgid = get_user_msgid ( "StatusIcon" );
sinfo_msgid = get_user_msgid ( "ScoreInfo" );
}
else
{
server_print ( "[StealC4] Invalid Map Objective" );
pause ( "ad" );
}
}
public plugin_precache ( )
{
OrpheuRegisterHook ( OrpheuGetFunction ( "InstallGameRules" ), "OnInstallGameRules", OrpheuHookPost );
precache_generic ( "sound/radio/bombst.wav" );
}
public OnInstallGameRules ( )
g_pGameRules = OrpheuGetReturn ( );
public client_disconnect ( id )
{
if ( has_Delay == id )
{
StopDelay ( );
return;
}
if ( has_C4 == id )
{
has_C4 = 0;
if ( !countdown_value )
return;
RestoreRoundTimer ( );
}
}
public Round_End ( )
{
MODE_NOSTEAL = true;
if ( !has_C4 )
return;
static tempID, frags;
tempID = has_C4;
has_C4 = 0;
Execute_user_C4 ( tempID, true );
frags = get_user_frags ( tempID ) + 3;
set_user_frags ( tempID, frags );
message_begin ( MSG_BROADCAST, sinfo_msgid );
write_byte ( tempID );
write_short ( frags );
write_short ( cs_get_user_deaths ( tempID ) );
write_short ( 0 );
write_short ( 2 );
message_end ( );
set_user_frags ( tempID, frags );
}
public Round_Start ( )
{
MODE_NOSTEAL = false;
delaytimer_value = get_pcvar_num ( delaytimer_cvar );
clamp ( delaytimer_value, 0, MAX_DELAY );
type_value = get_pcvar_num ( type_cvar ) ? true : false;
countdown_value = get_pcvar_num ( countdown_cvar );
clamp ( countdown_value, 0, MAX_TIMER );
multiplier_value = get_pcvar_float ( multiplier_cvar );
floatclamp ( multiplier_value, 1.0, MAX_MULTIPLIER );
if ( !countdown_value )
return;
round_timestart = get_gametime ( );
if ( task_exists ( 80085 ) )
remove_task ( 80085 );
}
public DeathMsg ( )
{
static id;
id = read_data ( 2 );
if ( has_C4 == id )
{
has_C4 = 0;
engclient_cmd ( id, "drop", "weapon_c4" );
message_begin ( MSG_ONE_UNRELIABLE, si_msgid, _, id );
write_byte ( 0 );
write_string ( "c4" );
message_end ( );
get_user_name ( id, thief, charsmax ( thief ) );
client_print ( id, print_center, "%s dropped the bomb", thief );
if ( !countdown_value )
return;
RestoreRoundTimer ( );
}
}
public Dropped_The_Bomb ( )
{
static id, loguser[128];
read_logargv( 0, loguser, charsmax ( loguser ) );
parse_loguser ( loguser, thief, charsmax ( thief ) );
id = get_user_index ( thief );
if ( has_C4 != id )
return;
has_C4 = 0;
if ( !countdown_value )
return;
if ( task_exists ( 80085 ) )
remove_task ( 80085 );
RestoreRoundTimer ( );
client_print ( id, print_center, "%s dropped the bomb", thief );
}
public Ham_PreThink ( id )
{
if ( has_Delay != id )
return HAM_IGNORED
if ( ( get_gametime() - LastDelay > 0.1 ) || ( type_value && !( get_user_button ( id ) & IN_USE ) ) )
StopDelay ( );
return HAM_IGNORED
}
public C4_Touch ( ent, id )
{
// Primary Handle
if ( GetWeaponBoxType ( ent ) != CSW_C4
|| get_user_team ( id ) != 2
|| !( get_entity_flags ( ent ) & FL_ONGROUND )
|| MODE_NOSTEAL
|| has_C4 )
return PLUGIN_CONTINUE
// Pre Save GameTime
static Float: GameTime;
GameTime = get_gametime();
// Bar Time ( Delay )
if ( delaytimer_value )
{
if ( !has_Delay )
{
if ( type_value && !( get_user_button ( id ) & IN_USE ) )
return PLUGIN_CONTINUE
DelayStore = 0.0;
LastDelay = GameTime;
has_Delay = id;
if ( !toggle_PreThink )
{
EnableHamForward ( handle_PreThink );
toggle_PreThink = true;
}
message_begin ( MSG_ONE_UNRELIABLE, bt_msgid, _, id );
write_short ( delaytimer_value );
message_end ( );
get_user_name ( id, thief, charsmax ( thief ) );
client_print ( 0, print_center, "%s is stealing the bomb!", thief );
return PLUGIN_CONTINUE
}
if ( has_Delay != id )
return PLUGIN_CONTINUE
if ( DelayStore < delaytimer_value + 0.01 )
{
DelayStore += GameTime - LastDelay;
LastDelay = GameTime;
return PLUGIN_CONTINUE
}
StopDelay ( );
}
else if ( type_value && !( get_user_button ( id ) & IN_USE ) )
return PLUGIN_CONTINUE
// Turn On Steal Mode
entity_set_int ( ent, EV_INT_flags, entity_get_int ( ent, EV_INT_flags ) | FL_KILLME );
ExecuteHam ( Ham_Think, ent );
Execute_user_C4 ( id, false );
has_C4 = id;
client_print ( 0, print_center, "The bomb has been stolen!" );
client_cmd ( 0, "spk sound/radio/bombst.wav" );
new r = random_num(0,255)
new g = random_num(0,255)
new b = random_num(0,255)
set_user_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 150)
// Secondary Handle
if ( !countdown_value )
return PLUGIN_CONTINUE
// Give Bomb StatusIcon to Player
message_begin ( MSG_ONE_UNRELIABLE, si_msgid, _, id );
write_byte ( 1 );
write_string ( "c4" );
write_byte ( 225 );
write_byte ( 225 );
write_byte ( 0 );
message_end ( );
// Steal Scenario
message_begin ( MSG_BROADCAST, sc_msgid );
write_byte ( 1 );
write_string ( "defuser" );
write_byte ( 255 );
write_short ( 100 );
write_short ( 0 );
message_end ( );
// Time Control
static time_elapsed, countdown_filter_value;
countdown_filter_value = floatround ( countdown_value * ( cs_get_user_defuse ( id ) ? 1.0 : multiplier_value ) );
time_elapsed = floatround ( GameTime - round_timestart );
round_timeleft = get_mp_pdata ( "m_iRoundTimeSecs" ) - time_elapsed;
set_mp_pdata ( "m_iRoundTimeSecs" , countdown_filter_value + time_elapsed );
message_begin ( MSG_BROADCAST, rt_msgid );
write_short ( countdown_filter_value + 1 );
message_end ( );
if ( countdown_filter_value < 10 )
{
update_timer = countdown_filter_value;
CountDownTimer ( 80085 );
}
else
{
update_timer = 10;
set_task ( float ( countdown_filter_value ) - 10.0, "CountDownTimer", 80085 );
}
return PLUGIN_CONTINUE
}
public CountDownTimer ( fid )
{
if ( !has_C4 )
{
if ( task_exists ( fid ) )
remove_task ( fid );
return;
}
static numstr[8];
num_to_word ( update_timer--, numstr, charsmax ( numstr ) );
client_cmd ( 0, "spk %s", numstr );
if ( update_timer )
set_task ( 1.0, "CountDownTimer", 80085 );
}
public TextMsg ( msgId, msgDest, id )
{
if ( get_msg_args ( ) < 2 )
return PLUGIN_CONTINUE
static buffer[32];
get_msg_arg_string ( 2, buffer, charsmax ( buffer ) );
if ( equal ( buffer, "#Bomb_Planted" ) )
{
MODE_NOSTEAL = true;
return PLUGIN_CONTINUE
}
if ( equal ( buffer, "#Game_will_restart_in" ) || equal ( buffer, "#Game_Commencing" ) )
{
MODE_NOSTEAL = true;
if ( has_Delay )
StopDelay ( );
else if ( has_C4 )
{
has_C4 = 0;
if ( !countdown_value )
return PLUGIN_CONTINUE
RestoreRoundTimer ( );
}
return PLUGIN_CONTINUE
}
if ( has_C4 == id && equal ( buffer, "#C4", 3 ) )
return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
GetWeaponBoxType ( ent )
{
static weapon;
for ( new i=1; i<=5; i++ )
{
weapon = get_pdata_cbase ( ent, m_rgpPlayerItems_CWeaponBox[i], XO_CWEAPONBOX );
if( weapon > 0 )
return cs_get_weapon_id ( weapon );
}
return 0;
}
Execute_user_C4 ( id, bool: action )
{
static weapon;
weapon = get_pdata_cbase ( id, m_rgpPlayerItems_CBasePlayer[CSW_C4_SLOT] );
while ( weapon > 0 )
{
if ( cs_get_weapon_id ( weapon ) == CSW_C4 )
break;
weapon = get_pdata_cbase ( weapon, m_pNext, XO_CBASEPLAYERITEM );
}
if ( action )
{
if ( weapon < 1 )
return 0;
if( get_pdata_cbase ( id, m_pActiveItem ) == weapon )
ExecuteHamB( Ham_Weapon_RetireWeapon, weapon );
if( ExecuteHamB ( Ham_RemovePlayerItem, id, weapon ) )
{
user_has_weapon ( id, CSW_C4, 0 );
ExecuteHamB ( Ham_Item_Kill, weapon );
return 1;
}
}
else
{
if ( weapon > 0 )
return 0;
weapon = create_entity ( "weapon_c4" );
if ( !is_valid_ent ( weapon ) )
return 0;
entity_set_int ( weapon, EV_INT_spawnflags, SF_NORESPAWN );
ExecuteHam ( Ham_Spawn, weapon );
if ( !ExecuteHamB ( Ham_AddPlayerItem, id, weapon ) )
{
if ( is_valid_ent ( weapon ) )
entity_set_int ( weapon, EV_INT_flags, entity_get_int ( weapon, EV_INT_flags ) | FL_KILLME );
return 0;
}
ExecuteHamB ( Ham_Item_AttachToPlayer, weapon, id );
return 1;
}
return 0;
}
StopDelay ( )
{
message_begin ( MSG_ONE_UNRELIABLE, bt_msgid, _, has_Delay );
write_short ( 0 );
message_end ( );
if ( toggle_PreThink )
{
DisableHamForward ( handle_PreThink );
toggle_PreThink = false;
}
has_Delay = 0;
}
RestoreRoundTimer ( )
{
if ( task_exists ( 80085 ) )
remove_task ( 80085 );
set_mp_pdata ( "m_iRoundTimeSecs", round_timeleft + floatround ( get_gametime() - round_timestart ) );
message_begin ( MSG_BROADCAST, rt_msgid );
write_short ( round_timeleft );
message_end ( );
message_begin ( MSG_BROADCAST, sc_msgid );
write_byte ( 0 );
message_end ( );
}
PHP Code:
// Turn On Steal Mode
entity_set_int ( ent, EV_INT_flags, entity_get_int ( ent, EV_INT_flags ) | FL_KILLME );
ExecuteHam ( Ham_Think, ent );
Execute_user_C4 ( id, false );
has_C4 = id;
client_print ( 0, print_center, "The bomb has been stolen!" );
client_cmd ( 0, "spk sound/radio/bombst.wav" );
new r = random_num(0,255)
new g = random_num(0,255)
new b = random_num(0,255)
set_user_rendering(id, kRenderFxGlowShell, r, g, b, kRenderNormal, 150)
Last edited by Copper; 05-09-2017 at 22:55.
|
|