Raised This Month: $ Target: $400
 0% 

How to block grenade throw


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-23-2013 , 15:49   How to block grenade throw
Reply With Quote #1

How to block grenade throw? Grenade must stay on hands, not to be removed.
FromTheFuture is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-23-2013 , 16:18   Re: How to block grenade throw
Reply With Quote #2

I try with Ham_Item_Deploy, but if I have more than one grenade it's does not work.

PHP Code:
    RegisterHamHam_Item_Deploy"weapon_hegrenade""Deploy_Post", .Post true );

public 
Deploy_PostpEntity )
{
    if( !
IsValidPrivateDatapEntity ) )
    {
        return 
HAM_HANDLED;
    }

    new 
id get_pdata_cbasepEntity OFFSET_WEAPONOWNER OFFSET_LINUX_WEAPONS );
        
set_pdata_float(idm_flNextAttackget_gametime( ), OFFSET_LINUX );
    
    
    return 
HAM_IGNORED;

FromTheFuture is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-23-2013 , 16:50   Re: How to block grenade throw
Reply With Quote #3

In which context do you want to block it ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-24-2013 , 06:05   Re: How to block grenade throw
Reply With Quote #4

Blocking the next throw grenades if the previous shots in less than 15 seconds.
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <csx>
#include <hamsandwich>
#include <fakemeta>

#define PLUGIN "HeBlock"
#define VERSION "1.0"
#define AUTHOR "FromTheFuture"

 
 
#define IsValidPrivateData(%0)          ( pev_valid( %0 ) == 2 )
 
#define  m_flNextAttack                         83
 
#define OFFSET_LINUX_WEAPONS    4
#define OFFSET_LINUX                            5
#define OFFSET_WEAPONOWNER      41

new Floatg_fWaitTime[33];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHamHam_Item_Deploy"weapon_hegrenade""Deploy_Post", .Post true );
}

public 
Deploy_PostpEntity )
{
    if( !
IsValidPrivateDatapEntity ) )
    {
        return 
HAM_HANDLED;
    }

    new 
id get_pdata_cbasepEntity OFFSET_WEAPONOWNER OFFSET_LINUX_WEAPONS );
    new 
Float:Time get_gametime() - g_fWaitTime[id];
    
    if(
Time  15)
    {
        
client_print(idprint_center"Please, wait %0f seconds"15 Time);
        
set_pdata_float(idm_flNextAttackget_gametime( ), OFFSET_LINUX );
    }
    
    return 
HAM_IGNORED;
}

public 
grenade_throw(idgidwid)
{
    if(
wid != CSW_HEGRENADE)
    return;
    
    
g_fWaitTime[id] = get_gametime();
    

FromTheFuture is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-24-2013 , 12:51   Re: How to block grenade throw
Reply With Quote #5

set m_flNextPrimaryAttack on grenade entity then.
Gonna be a little animation starting to play due to client prediction.

PHP Code:
#include <amxmodx>
// #include <amxmisc>
#include <csx>
#include <hamsandwich>
#include <fakemeta>

#define PLUGIN "HeBlock"
#define VERSION "1.0"
#define AUTHOR "FromTheFuture"

#define IsValidPrivateData(%0)          ( pev_valid( %0 ) == 2 )

const XO_CBASEPLAYERITEM 4;
const 
m_pPlayer 41;

const 
XO_CBASEPLAYERWEAPON 4;
const 
m_flNextPrimaryAttack 46;

new 
Floatg_fNextThrowTime[33];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
RegisterHamHam_Item_Deploy"weapon_hegrenade""OnCHEGrenadeDeploy_Post"true );
}

public 
OnCHEGrenadeDeploy_PostpEntity )
{
    if( !
IsValidPrivateDatapEntity ) )
    {
        return;
    }

    new 
id get_pdata_cbasepEntity m_pPlayer XO_CBASEPLAYERITEM );
    new 
Float:flWaitTime g_fNextThrowTime[id] - get_gametime();

    if( 
flWaitTime 0.0 )
    {
        
client_print(idprint_center"Please, wait %.0f seconds"flWaitTime);
        
set_pdata_float(pEntitym_flNextPrimaryAttackflWaitTimeXO_CBASEPLAYERWEAPON);
    }
}

public 
grenade_throw(idgidwid)
{
    if(
wid == CSW_HEGRENADE)
    {
        
g_fNextThrowTime[id] = get_gametime() + 15.0;
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-25-2013 , 07:40   Re: How to block grenade throw
Reply With Quote #6

Plugin not work if I have two or more grenades.
Watch the video http://www.youtube.com/watch?v=HnImA...ature=youtu.be
FromTheFuture is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-25-2013 , 11:54   Re: How to block grenade throw
Reply With Quote #7

Try this :

Reference is https://raw.github.com/Arkshine/CSSD..._hegrenade.cpp
Interesting code is in function void CHEGrenade::WeaponIdle()
grenade_throw forward is sent during execution of CGrenade::ShootTimed2

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <csx>
#include <hamsandwich>
#include <fakemeta>

#define PLUGIN "HeBlock"
#define VERSION "2.0"
#define AUTHOR "FromTheFuture"

const Float:THROW_HEGREN_DELAY 15.0;

const 
XO_CBASEPLAYERITEM 4;
const 
m_pPlayer 41;

const 
XO_CBASEPLAYERWEAPON 4;
const 
m_flNextPrimaryAttack 46;

new 
Floatg_fNextThrowTime[33];

new 
HamHook:g_iHhCHEGrenadeWeaponIdlePostHamHook:g_iHhCHEGrenadeHolster;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
RegisterHamHam_Item_Deploy"weapon_hegrenade""OnCHEGrenade_Deploy_Post"true );
    
DisableHamForward
    
(
        
g_iHhCHEGrenadeWeaponIdlePost RegisterHamHam_Weapon_WeaponIdle"weapon_hegrenade""OnCHEGrenade_WeaponIdle_Post"true )
    );
    
DisableHamForward
    
(
        
g_iHhCHEGrenadeHolster RegisterHamHam_Item_Holster"weapon_hegrenade""OnCHEGrenade_Holster"false )
    );
}

public 
OnCHEGrenade_Deploy_PostpEntity )
{
    new 
id get_pdata_cbasepEntity m_pPlayer XO_CBASEPLAYERITEM );
    new 
Float:flWaitTime g_fNextThrowTime[id] - get_gametime();

    if( 
flWaitTime 0.0 )
    {
        
client_print(idprint_center"Please, wait %.0f seconds"flWaitTime);
        
set_pdata_float(pEntitym_flNextPrimaryAttackflWaitTimeXO_CBASEPLAYERWEAPON);
    }
}

public 
OnCHEGrenade_HolsterpEntity )
{
    
DisableHamForwardg_iHhCHEGrenadeWeaponIdlePost );
    
DisableHamForwardg_iHhCHEGrenadeHolster );
}

public 
OnCHEGrenade_WeaponIdle_PostpEntity )
{
    
set_pdata_float(pEntitym_flNextPrimaryAttackTHROW_HEGREN_DELAY 0.5XO_CBASEPLAYERWEAPON);
}

public 
grenade_throw(idgidwid)
{
    if(
wid == CSW_HEGRENADE)
    {
        
g_fNextThrowTime[id] = get_gametime() + THROW_HEGREN_DELAY;
        if( 
cs_get_user_bpammo(idCSW_HEGRENADE) > )
        {
            
EnableHamForwardg_iHhCHEGrenadeWeaponIdlePost );
            
EnableHamForwardg_iHhCHEGrenadeHolster );
        }
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 04-25-2013 at 11:58.
ConnorMcLeod is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-25-2013 , 12:52   Re: How to block grenade throw
Reply With Quote #8

Thank You, work, but with errors.
It's work if I throw first grenade, change active weapon, then set weapon to grenade again. But if I'm not change active weapon, try to throw second grenade at once - grenade will not be thrown, never.

May be block throw with CurWeapon?
PHP Code:
public evCurWeapon(id)
{

    new 
Float:Time get_gametime() - g_fWaitTime[id];
    
    if(
Time  15)
    {
        
client_print(idprint_center"Please, wait %0.0f seconds"15 Time);
        
engclient_cmd(id"weapon_knife");
    }
    

This code work, but how I can set active weapon from 1 slot (if have) or 2?
FromTheFuture is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-25-2013 , 13:59   Re: How to block grenade throw
Reply With Quote #9

Try this

PHP Code:
#include <amxmodx>
#include <csx>
#include <hamsandwich>
#include <fakemeta>

#define PLUGIN "HeBlock"
#define VERSION "2.1"
#define AUTHOR "FromTheFuture"

const Float:THROW_HEGREN_DELAY 15.0;

const 
XO_CBASEPLAYERITEM 4;
const 
m_pPlayer 41;

const 
XO_CBASEPLAYERWEAPON 4;
const 
m_flNextPrimaryAttack 46;

new 
Floatg_fNextThrowTime[33];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
RegisterHamHam_Item_Deploy"weapon_hegrenade""OnCHEGrenade_Deploy_Post"true );
    
RegisterHamHam_Weapon_PrimaryAttack"weapon_hegrenade""OnCHEGrenade_PrimaryAttack"false );
}

public 
OnCHEGrenade_Deploy_PostpEntity )
{
    new 
id get_pdata_cbasepEntity m_pPlayer XO_CBASEPLAYERITEM );
    new 
Float:flWaitTime g_fNextThrowTime[id] - get_gametime();

    if( 
flWaitTime 0.0 )
    {
        
client_print(idprint_center"Please, wait %.0f seconds"flWaitTime);
        
set_pdata_float(pEntitym_flNextPrimaryAttackflWaitTimeXO_CBASEPLAYERWEAPON);
    }
}

public 
OnCHEGrenade_PrimaryAttackpEntity )
{
    new 
id get_pdata_cbasepEntity m_pPlayer XO_CBASEPLAYERITEM );
    new 
Float:flWaitTime g_fNextThrowTime[id] - get_gametime();

    if( 
flWaitTime 0.0 )
    {
        
client_print(idprint_center"Please, wait %.0f seconds"flWaitTime);
        
set_pdata_float(pEntitym_flNextPrimaryAttackflWaitTimeXO_CBASEPLAYERWEAPON);
        return 
HAM_SUPERCEDE;
    }
    return 
HAM_IGNORED;
}

public 
grenade_throw(idgidwid)
{
    if(
wid == CSW_HEGRENADE)
    {
        
g_fNextThrowTime[id] = get_gametime() + THROW_HEGREN_DELAY;
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 04-25-2013 at 13:59.
ConnorMcLeod is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-25-2013 , 14:18   Re: How to block grenade throw
Reply With Quote #10

Work =)
Lilltle question, how can do to show left time whenever click on +attack, now I see time when change weapon to grenade.
And how to remove dot on message after number? Now I see "Please, wait 2. seconds"

Last edited by FromTheFuture; 04-25-2013 at 14:19.
FromTheFuture is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:46.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode