Raised This Month: $12 Target: $400
 3% 

How to block grenade throw


Post New Thread Reply   
 
Thread Tools Display Modes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-25-2013 , 14:49   Re: How to block grenade throw
Reply With Quote #11

1. In PrimaryAttack callback, don't change pdata next primaryattack value, just supercede
2. update amxx to 1.8.2
__________________
- tired and retired -

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

Thank You very much =)
FromTheFuture is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-25-2013 , 15:16   Re: How to block grenade throw
Reply With Quote #13

Oh and remove all deploy code.
__________________
- tired and retired -

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

Quote:
Originally Posted by ConnorMcLeod View Post
Oh and remove all deploy code.
Of course.
Now code looks like:
PHP Code:
#include <amxmodx>
#include <csx>
#include <hamsandwich>
#include <fakemeta>

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


const XO_CBASEPLAYERITEM 4;
const 
m_pPlayer 41;

const 
XO_CBASEPLAYERWEAPON 4;
const 
m_flNextPrimaryAttack 46;

new 
Floatg_fNextThrowTime[33];
new 
g_CvarTime;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
g_CvarTime register_cvar("amx_he_blocktime""15.0");
    
RegisterHamHam_Weapon_PrimaryAttack"weapon_hegrenade""OnCHEGrenade_PrimaryAttack"false );
}

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 %d seconds"floatround(flWaitTime));
        return 
HAM_SUPERCEDE;
    }
    return 
HAM_IGNORED;
}

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

FromTheFuture is offline
Hamartia
Member
Join Date: Oct 2015
Old 12-08-2015 , 13:50   Re: How to block grenade throw
Reply With Quote #15

I find this plugin useful. Was searching for this at all the sub forums. When a perfect plugin is finally out of a post in scripting/request section, can't we post in the new plugin forum with credits to author ?
Hamartia is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 12-08-2015 , 22:29   Re: How to block grenade throw
Reply With Quote #16

Quote:
Originally Posted by Hamartia View Post
I find this plugin useful. Was searching for this at all the sub forums. When a perfect plugin is finally out of a post in scripting/request section, can't we post in the new plugin forum with credits to author ?
Enjoy!
FromTheFuture is offline
Hamartia
Member
Join Date: Oct 2015
Old 12-08-2015 , 22:57   Re: How to block grenade throw
Reply With Quote #17

Quote:
Originally Posted by FromTheFuture View Post
Enjoy!
Hi, thank you ! One doubt. I thought of using print_chat for client_print and found that it was called multiple times. Then understood the event was called on during fire event (OnCHEGrenade_PrimaryAttack) but still a lot of times the client_print is sent multiple times depending up on users action. My doubt is wont that send a lot of info to client or am I exaggerating it?

I tried to modify it to my use, I want to print info once in client chat and not anymore till next successful throw.

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

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


const XO_CBASEPLAYERITEM 4
const 
m_pPlayer 41

const 
XO_CBASEPLAYERWEAPON 4
const 
m_flNextPrimaryAttack 46

new 
Floatg_fNextThrowTime[33]; 
new 
g_CvarTime
new 
boolg_showBlockMsg[33]=false;

public 
plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR); 
    
g_CvarTime register_cvar("amx_he_blocktime""15.0"); 
    
RegisterHamHam_Weapon_PrimaryAttack"weapon_hegrenade""OnCHEGrenade_PrimaryAttack"false ); 


public 
OnCHEGrenade_PrimaryAttackpEntity 

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

    if( 
flWaitTime 0.0 
    { 
        if(
g_showBlockMsg[id]){
        
client_print(idprint_chat"You can nade only %d seconds once"floatround(get_pcvar_float(g_CvarTime)));
        
g_showBlockMsg[id] = false;
    }
         
        return 
HAM_SUPERCEDE
    } 
    
// not sure if this else part is required
   
else
    {
        
g_showBlockMsg[id] = false;
    }
    return 
HAM_IGNORED


public 
grenade_throw(idgidwid

    if(
wid == CSW_HEGRENADE
    { 
        
g_fNextThrowTime[id] = get_gametime() + get_pcvar_float(g_CvarTime); 
        
g_showBlockMsg[id] = true;
    } 


Also I am trying to register round end so that I can reset g_showBlockMsg and g_fNextThrowTime since it should not block nade in the first few seconds of new round because the player used nade in the last second of previous round. I ll try this later.
Hamartia is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 12-09-2015 , 00:36   Re: How to block grenade throw
Reply With Quote #18

U can try easyer:

PHP Code:
if( flWaitTime 0.0 )  
{  
        if( 
flWaitTime 1.0 == )
        
client_print(idprint_center"Please, wait %d seconds"floatround(flWaitTime)); 

        return 
HAM_SUPERCEDE


Last edited by FromTheFuture; 12-09-2015 at 00:45.
FromTheFuture is offline
Hamartia
Member
Join Date: Oct 2015
Old 12-09-2015 , 06:45   Re: How to block grenade throw
Reply With Quote #19

Quote:
Originally Posted by FromTheFuture View Post
U can try easyer:

PHP Code:
if( flWaitTime 0.0 )  
{  
        if( 
flWaitTime 1.0 == )
        
client_print(idprint_center"Please, wait %d seconds"floatround(flWaitTime)); 

        return 
HAM_SUPERCEDE

Yes this will reduce the no of client_print. What I tried was just one message. Thank you for this one.
Hamartia 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 14:10.


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