Raised This Month: $ Target: $400
 0% 

Grenades throw


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 08-22-2015 , 16:32   Grenades throw
Reply With Quote #1

I have seen this topic :https://forums.alliedmods.net/showthread.php?t=270408
And i have an ideea.
Can i throw he grenade pressing g (drop).i tried to register drop clcmd on another plugin and it worked and i think to throw hegren pressing g.
siriusmd99 is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 08-22-2015 , 16:44   Re: Grenades throw
Reply With Quote #2

please, use search button, or google...
Depresie is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-23-2015 , 04:33   Re: Grenades throw
Reply With Quote #3

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
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 08-23-2015 , 05:23   Re: Grenades throw
Reply With Quote #4

Ok, thanks. But when i press g it will throw the grenade or only select it?
siriusmd99 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-23-2015 , 05:55   Re: Grenades throw
Reply With Quote #5

Quote:
Originally Posted by siriusmd99 View Post
Ok, thanks. But when i press g it will throw the grenade or only select it?
You must have the grenade in hand, and it will throw it.
__________________
HamletEagle is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 08-23-2015 , 09:07   Re: Grenades throw
Reply With Quote #6

I want to throw it even if i have a gun in my hand. It throws it only if i have grenade selected in my hand?
And please remove message with items cannot be throwed because i made a plugin like that and when i pressed g message doesnt appear.

Last edited by siriusmd99; 08-23-2015 at 09:09.
siriusmd99 is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 08-23-2015 , 09:12   Re: Grenades throw
Reply With Quote #7

Anyway thanks i think i can edit myself .i will test and after reply.
siriusmd99 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-23-2015 , 10:31   Re: Grenades throw
Reply With Quote #8

The message is already removed...
__________________
HamletEagle is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 08-23-2015 , 14:28   Re: Grenades throw
Reply With Quote #9

Quote:
Originally Posted by HamletEagle View Post
The message is already removed...
Hamlet, i tried to change drop to another xommand throwhe and binded it to a button and if i have i gun in the hand and after that i press button then it just fires a bullet with that gun , stucks(cannot fire anymore until i change weapon) and does not throw he. I want just to bind the a command to a not used button and select he automaticaly hegren and throw it.is it possible?
I mean you know instead of pressing 4 and selecting he with click 1 and press another one time clicl 1 to throw , i want that command do it automatticaly.
siriusmd99 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-23-2015 , 14:35   Re: Grenades throw
Reply With Quote #10

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] = {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("throwhe""ClientCommand_ThrowHE")
    
    
gmsgTextMsg get_user_msgid("TextMsg")
}

public 
ClientCommand_ThrowHE(id)
{
    if(
is_user_alive(id))
    {
        new 
WeaponEnt get_pdata_cbase(idm_rgpPlayerItems_CBasePlayer[4])    
        while(
pev_valid(WeaponEnt))
        {
            if(
get_pdata_int(WeaponEntm_iIdXoCBasePlayerItem) == CSW_HEGRENADE)
            {
                break
            }    
            
WeaponEnt get_pdata_cbase(WeaponEntm_pNextXoCBasePlayerItem)
        }
        
        if(
pev_valid(WeaponEnt))
        {
            
engclient_cmd(id"weapon_hegrenade")
            
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)

__________________

Last edited by HamletEagle; 08-23-2015 at 14:35.
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