Raised This Month: $ Target: $400
 0% 

[solved]catch smoke grenade bought


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Owyn
Veteran Member
Join Date: Nov 2007
Old 11-10-2009 , 14:00   [solved]catch smoke grenade bought
Reply With Quote #1

code to catch HE nade bought, but i'd like to do the same for the smoke greneade, i'm not very familar with "<<" things + is there a cl_cmd like hegren for smoke one?
PHP Code:
// HE nade
        // Old Style
        
register_menucmdregister_menuid"BuyItem" )    , (1<<3)    , "cmd_hegren"    );

        
// VGUI
        
register_menucmd( -34    , (1<<3)    , "cmd_hegren"    );

        
// Steam
        
register_clcmd"hegren"    "cmd_hegren"    ); 
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-10-2009 , 14:02   Re: catch smoke grenade bought
Reply With Quote #2

cstrike/autobuy.txt
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-10-2009 , 14:02   Re: catch smoke grenade bought
Reply With Quote #3

With this code you only catch the attempt to buy a HE.
And i'm not sure the VGUI thing works.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Jon
Veteran Member
Join Date: Dec 2007
Old 11-10-2009 , 14:12   Re: catch smoke grenade bought
Reply With Quote #4

Probably catches if you have smoke grenade in game_player_equip. Not sure if this catches picking up from the ground too.

PHP Code:
#include <amxmodx>
#include <engine>
#include <hamsandwich>

public plugin_init( )
{
    
RegisterHamHam_AddPlayerItem"player""ReceiveGrenade" )
}

public 
ReceiveGrenadeidEnt )
{
    new Class[ 
32 ]
    
entity_get_stringEntEV_SZ_classname, Class, 31 )
    
    if( 
equal( Class, "weapon_smokegrenade" ) )
    {
        
// .. 
    
}


Last edited by Jon; 11-10-2009 at 14:19.
Jon is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-10-2009 , 14:29   Re: catch smoke grenade bought
Reply With Quote #5

PHP Code:
#include <amxmodx>
#include <cstrike>

#define VERSION "0.0.1"

public plugin_init()
{
    
register_plugin("Hook Buy SmokeGrenade"VERSION"Author")

    
register_menucmd(register_menuid("T_BuyItem"1), (1<<4), "BuySmokeGrenade")

}

public 
BuySmokeGrenadeid )
{
    
// attempt to buy a smoke grenade
}

public 
client_command(id)
{
    static 
szCommand[7// sgren

    
if( read_argv(0szCommandcharsmax(szCommand)) == && equal(szCommand"sgren") )
    {
        
// attempt to buy a smoke grenade
    
}
}

public 
CS_InternalCommand(id, const szCommand[])
{
    if( 
equal(szCommand"sgren") )
    {
        
// attempt to buy a smoke grenade
    
}

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-10-2009 , 14:43   Re: catch smoke grenade bought
Reply With Quote #6

DO NOT USE THE CODE IN THIS POST

/win

PHP Code:
#include < amxmodx >
#include < cstrike >
#include < engine >

public client_PreThinkiPlayer ) {
    if( 
is_user_aliveiPlayer ) ) {
        static 
iOldMoney33 ], bool:bHadSmoke33 ];
        static 
Float:fLastMoneyChange33 ], Float:fLastSmokeChange33 ];
        
        new 
iMoney cs_get_user_moneyiPlayer );
        new 
iSmoke cs_get_user_bpammoiPlayerCSW_SMOKEGRENADE );
        
        if( 
iMoney iOldMoneyiPlayer ] ) {
            
fLastMoneyChangeiPlayer ] = get_gametime( );
        }
        
        if( 
iSmoke && !bHadSmokeiPlayer ] ) {
            
fLastSmokeChangeiPlayer ] = get_gametime( );
        }
        
        if( 
floatabsfLastMoneyChangeiPlayer ] - fLastSmokeChangeiPlayer ] ) < 0.3 ) {
            
// player bought smoke
        
}
        
        
iOldMoneyiPlayer ] = iMoney;
        
bHadSmokeiPlayer ] = ( iSmoke );
    }

lol
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 11-10-2009 at 18:29.
Exolent[jNr] is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 11-10-2009 , 15:13   Re: [solved]catch smoke grenade bought
Reply With Quote #7

lol exolent wtf
__________________
xPaw is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 11-10-2009 , 15:22   Re: [solved]catch smoke grenade bought
Reply With Quote #8

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

const m_pPlayer 41

public plugin_init()
    
RegisterHam(Ham_Item_AddToPlayer"weapon_smokegrenade""fw_SmokeGren_AddToPlayer")
    
public 
fw_SmokeGren_AddToPlayer(sg)
{
    static 
iOwner
    iOwner 
get_pdata_cbase(sgm_pPlayer4)
    
    if(
is_user_connected(iOwner))
    {
        
// A player has received an Smoke grenade
    
}

?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-10-2009 , 18:17   Re: [solved]catch smoke grenade bought
Reply With Quote #9

@xolent
VEN's method with client command hook should be better than hooking client prethink.

PHP Code:
#include <amxmodx>

#define MAX_CLIENTS 32
new g_weapons[MAX_CLIENTS 1]

public 
plugin_init() {
        
register_event("Money""event_money""be")
}

public 
client_command(id) {
        
g_weapons[id] = get_user_weapons(iddummydummy2)
}

public 
event_money(id) {
        new 
old_weapons g_weapons[id]
        
client_command(id)

        new 
new_weapon g_weapons[id] & ~old_weapons
        
if (new_weapon) {
                new 
= -1
                
do ++x; while ((new_weapon /= 2) >= 1)
                static 
wname[32]
                
get_weaponname(xwnamesizeof wname 1)
                
server_print("Player [ClientIndex=%d] has bought ^"%s^" [WeaponIndex=%d]"idwnamex)
        }

Should work for smokegrenade, not sure if the money check is required :
PHP Code:
#include <amxmodx>

#define MAX_CLIENTS 32
new g_bHasSmokeGren[MAX_CLIENTS 1]
new 
g_bUserMoney[MAX_CLIENTS 1]

public 
plugin_init() {
        
register_event("Money""event_money""be")
}

public 
client_command(id)
{
        
g_bHasSmokeGren[id] = user_has_weapon(idCSW_SMOKEGRENADE)
}

public 
event_money(id)
{
    new 
iNewMoney read_data(1)
    if(    !
g_bHasSmokeGren[id]
    &&    (
g_bHasSmokeGren[id] = user_has_weapon(idCSW_SMOKEGRENADE))    )
    {
        if( 
g_bUserMoney[id] - iNewMoney == 300 )
        {
            
client_print(idprint_chat"Enjoy the smoke.")
        }
    }

    
g_bUserMoney[id] = iNewMoney

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 11-10-2009 at 18:26.
ConnorMcLeod is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-10-2009 , 18:24   Re: [solved]catch smoke grenade bought
Reply With Quote #10

My way was just a joke, not to be taken seriously.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply


Thread Tools
Display Modes

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 17:41.


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