Quote:
Originally Posted by FromTheFuture
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 Float: g_fNextThrowTime[33];
new g_CvarTime;
new bool: g_showBlockMsg[33]=false;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
g_CvarTime = register_cvar("amx_he_blocktime", "15.0");
RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_hegrenade", "OnCHEGrenade_PrimaryAttack", false );
}
public OnCHEGrenade_PrimaryAttack( pEntity )
{
new id = get_pdata_cbase( pEntity , m_pPlayer , XO_CBASEPLAYERITEM );
new Float:flWaitTime = g_fNextThrowTime[id] - get_gametime();
if( flWaitTime > 0.0 )
{
if(g_showBlockMsg[id]){
client_print(id, print_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(id, gid, wid)
{
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.