AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Grenades throw (https://forums.alliedmods.net/showthread.php?t=270504)

siriusmd99 08-22-2015 16:32

Grenades throw
 
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.

Depresie 08-22-2015 16:44

Re: Grenades throw
 
please, use search button, or google...

HamletEagle 08-23-2015 04:33

Re: Grenades throw
 
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.

siriusmd99 08-23-2015 05:23

Re: Grenades throw
 
Ok, thanks. But when i press g it will throw the grenade or only select it?

HamletEagle 08-23-2015 05:55

Re: Grenades throw
 
Quote:

Originally Posted by siriusmd99 (Post 2336132)
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.

siriusmd99 08-23-2015 09:07

Re: Grenades throw
 
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.

siriusmd99 08-23-2015 09:12

Re: Grenades throw
 
Anyway thanks i think i can edit myself .i will test and after reply.

HamletEagle 08-23-2015 10:31

Re: Grenades throw
 
The message is already removed...

siriusmd99 08-23-2015 14:28

Re: Grenades throw
 
Quote:

Originally Posted by HamletEagle (Post 2336198)
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.

HamletEagle 08-23-2015 14:35

Re: Grenades throw
 
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)




All times are GMT -4. The time now is 22:13.

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