///////////////////
//C4 PICKUP HELP //
///////////////////
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <hamsandwich>
#include <hlsdk_const>
#include <fakemeta>
#include <cstrike>
new const plugin[] = "C4 Pickup by USE key";
new const author[] = "Karaulov";
new const version[] = "1.00";
public plugin_init()
{
register_plugin(plugin, version, author);
register_forward( FM_CmdStart , "GiveMeBombPlease" );
}
public GiveMeBombPlease( id , Handle )
{
static iButtons , iOldButtons;
iButtons = get_uc( Handle , UC_Buttons );
iOldButtons = pev( id , pev_oldbuttons );
// if Terrorist and press use key do...
if( cs_get_user_team(id) == CS_TEAM_T && ( iButtons & IN_USE ) && !( iOldButtons & IN_USE ) )
{
new orig[ 3 ];
new Float:targetAim[ 3 ];
get_user_origin( id, orig, 3 );
IVecFVec( orig, targetAim );
new mybomb = find_ent_by_class( -1, "weapon_c4" );
if (is_valid_ent(mybomb ))
{
new ent_Weaponbox=find_ent_in_sphere (-1, targetAim, 0.5 );
while (ent_Weaponbox != 0){
if ( is_valid_ent(ent_Weaponbox ) )
{
new className[26];
entity_get_string ( ent_Weaponbox, EV_SZ_classname, className, 25 );
if (equali(className,"weaponbox"))
{
if (pev(mybomb, pev_owner) > get_maxplayers())
{
if (get_entity_distance(id,ent_Weaponbox) < 150
&& cs_weaponbox_weapon_type(ent_Weaponbox) == CSW_C4)
{
remove_entity(ent_Weaponbox);
remove_entity(mybomb);
give_item(id, "weapon_c4");
}
}
}
}
ent_Weaponbox=find_ent_in_sphere (ent_Weaponbox, targetAim, 0.7 );
}
}
}
}
stock const CWeaponBox_offset[ 6 ] = { 34 , 35 , ... };
cs_weaponbox_weapon_type( wbox )
{
new wboxinside;
for( new i = 1; i < 6; i++ )
{
wboxinside = get_pdata_cbase( wbox, CWeaponBox_offset[ i ], 4 );
if( wboxinside > 0 )
return cs_get_weapon_id( wboxinside );
}
return 0
}