Raised This Month: $ Target: $400
 0% 

Hook/Block grenade buy.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-28-2013 , 11:40   Hook/Block grenade buy.
Reply With Quote #1

Try to hook with this:
PHP Code:
    register_clcmd("hegren","hook_he")
    
register_clcmd("flash","hook_flash")
    
register_clcmd("sgren","hook_smoke"
Works only for VGUI menu.
I want make plugin which allows you to buy more than one grenade for old style menu too.
Try to use cl_buy.inc but he not work when I have more than one HE grenade, showing "You cannot carry anymore!".
FromTheFuture is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-28-2013 , 16:43   Re: Hook/Block grenade buy.
Reply With Quote #2

I remember in a request i made, i used client_buy forward, and procedeed in plugin the money and give item.
Also, if player has already 1 HE or 2 Flash, you can use this :

PHP Code:
GiveOnMoreNade(iditem)
{
    switch( 
item )
    {
        case 
CSW_HEGRENADE:
        {
            
ExecuteHamB(Ham_GiveAmmoid1"HEGrenade"get_pcvar_num(g_pMaxHeGren))
        }
        case 
CSW_FLASHBANG:
        {
            
ExecuteHamB(Ham_GiveAmmoid1"Flashbang"get_pcvar_num(g_pCvarMaxFlashGren))
        }
        case 
CSW_SMOKEGRENADE:
        {
            
ExecuteHamB(Ham_GiveAmmoid1"SmokeGrenade"get_pcvar_num(g_pCvarMaxSmokeGren))
        }
    }
    
emit_sound(idCHAN_ITEMPICKUP_SOUNDVOL_NORMATTN_NORM0PITCH_NORM)

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-28-2013 , 17:14   Re: Hook/Block grenade buy.
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
I remember in a request i made, i used client_buy forward, and procedeed in plugin the money and give item.
Also, if player has already 1 HE or 2 Flash, you can use this :
...
I can't use this (if u give this code for using with cl_buy) because client_buy forward not be called if I will have more than one grenade.
PHP Code:
public client_buy(idi_Item)
{
    if(
user_has_weapon(idi_Item)) 
    return 
0;
    
    switch(
i_Item)
{
    case 
CSW_HEGRENADE:
    {        
    new 
ammo cs_get_user_bpammo(id,CSW_HEGRENADE)
    new 
money cs_get_user_money(id)

    if (
ammo+<= MAXGRENADESExapmle 2<=3
    
{
        
        if (
money>=300)
        {
            
            if (
g_CanBuy//Check on mp_buytime
            
{
                
give_item(id,"weapon_hegrenade")
                
cs_set_user_money(id,money-300)
                if (
ammo>=1)
                
//force_pick(id,CSA_HEGRENADE)
                
cs_set_user_bpammo(id,CSW_HEGRENADE,ammo+1)
                
emit_sound(idCHAN_WEAPON "items/9mmclip1.wav" 1.0 ATTN_NORM PITCH_NORM)
            }
            else
            {
                
client_print(id,print_center"You can't buy anything now!")
            }
            
        }
        else
        {
            
client_print(id,print_center,"You have insufficient funds!")
        }
        
    }
    else
    {
        
client_print(id,print_center,"You can't carry anymore!")// When I have 1 grenade I don's see this, I see "CANNOT carry anymore". It's mean this forward not be called or I don't know..
    
}
    
    return 
PLUGIN_HANDLED
                
    
}
}
    
cs_set_user_menu(id,0);
    return 
PLUGIN_CONTINUE

FromTheFuture is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-28-2013 , 17:18   Re: Hook/Block grenade buy.
Reply With Quote #4

Oww, one moment about =D
PHP Code:
    if(user_has_weapon(idi_Item))  
    return 
0
Must remove.. I check now.
FromTheFuture is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 04-28-2013 , 17:34   Re: Hook/Block grenade buy.
Reply With Quote #5

The problem solved.
FromTheFuture 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 10:54.


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