I hate when someone request X and after you do it he wants Y. You said you want when you drop the he, now you want a custom command. The command is "throwhe".
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define MAX_ITEM_TYPES 6
#define PluginName "Throw HE on g"
#define PluginVersion "0.1"
#define PluginAuthor "HamletEagle"
new const m_rgpPlayerItems_CBasePlayer[MAX_ITEM_TYPES] = {367, 368, ...}
new const MessageToBlock[] = "#Weapon_Cannot_Be_Dropped"
const m_pNext = 42
const m_iId = 43
const XoCBasePlayerItem = 4
const Param_DestionationType = 1
const Param_Message = 2
new gmsgTextMsg
new TextMsgRegIndex
public plugin_init()
{
register_plugin
(
.plugin_name = PluginName,
.version = PluginVersion,
.author = PluginAuthor
)
register_clcmd("throwhe", "ClientCommand_ThrowHE")
gmsgTextMsg = get_user_msgid("TextMsg")
}
public ClientCommand_ThrowHE(id)
{
if(is_user_alive(id))
{
new WeaponEnt = get_pdata_cbase(id, m_rgpPlayerItems_CBasePlayer[4])
while(pev_valid(WeaponEnt))
{
if(get_pdata_int(WeaponEnt, m_iId, XoCBasePlayerItem) == CSW_HEGRENADE)
{
break
}
WeaponEnt = get_pdata_cbase(WeaponEnt, m_pNext, XoCBasePlayerItem)
}
if(pev_valid(WeaponEnt))
{
engclient_cmd(id, "weapon_hegrenade")
TextMsgRegIndex = register_message(gmsgTextMsg, "OnTextMsg_Message")
ExecuteHamB(Ham_Weapon_PrimaryAttack, WeaponEnt)
}
}
}
public OnTextMsg_Message()
{
if(get_msg_arg_int(Param_DestionationType) == print_center)
{
new Message[sizeof MessageToBlock + 1]
get_msg_arg_string(Param_Message, Message, charsmax(Message))
if(equal(Message, MessageToBlock))
{
UnregisterMessage()
return PLUGIN_HANDLED
}
}
return PLUGIN_CONTINUE
}
//It seems that unregistering the message directly into the hook produce a crash.
public UnregisterMessage()
{
unregister_message(gmsgTextMsg, TextMsgRegIndex)
}
__________________