Raised This Month: $ Target: $400
 0% 

Grenades throw


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-23-2015 , 04:33   Re: Grenades throw
Reply With Quote #1

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] = {367368, ...}
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("drop""ClientCommand_Drop")
    
    
gmsgTextMsg get_user_msgid("TextMsg")
}

public 
ClientCommand_Drop(id)
{
    if(
is_user_alive(id))
    {
        new 
WeaponIndex get_user_weapon(id)
        if(
WeaponIndex == CSW_HEGRENADE)
        {
            new 
WeaponEnt get_pdata_cbase(idm_rgpPlayerItems_CBasePlayer[4])    
            while(
pev_valid(WeaponEnt))
            {
                if(
get_pdata_int(WeaponEntm_iIdXoCBasePlayerItem) == WeaponIndex)
                {
                    break
                }    
                
WeaponEnt get_pdata_cbase(WeaponEntm_pNextXoCBasePlayerItem)
            }
            
            if(
pev_valid(WeaponEnt))
            {
                
TextMsgRegIndex register_message(gmsgTextMsg"OnTextMsg_Message")
                
ExecuteHamB(Ham_Weapon_PrimaryAttackWeaponEnt)
            }
        }
    }
}

public 
OnTextMsg_Message()
{
    if(
get_msg_arg_int(Param_DestionationType) == print_center)
    {
        new 
Message[sizeof MessageToBlock 1]
        
get_msg_arg_string(Param_MessageMessagecharsmax(Message))
    
        if(
equal(MessageMessageToBlock))
        {
            
UnregisterMessage()
            return 
PLUGIN_HANDLED
        
}
    }
    
    return 
PLUGIN_CONTINUE
}

//It seems that unregistering the message directly into the hook produce a crash.
public UnregisterMessage()
{
    
unregister_message(gmsgTextMsgTextMsgRegIndex)

This should work fine.
__________________

Last edited by HamletEagle; 08-23-2015 at 04:37.
HamletEagle 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 22:13.


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