AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hook/Block grenade buy. (https://forums.alliedmods.net/showthread.php?t=214549)

FromTheFuture 04-28-2013 11:40

Hook/Block grenade buy.
 
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!".

ConnorMcLeod 04-28-2013 16:43

Re: Hook/Block grenade buy.
 
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)



FromTheFuture 04-28-2013 17:14

Re: Hook/Block grenade buy.
 
Quote:

Originally Posted by ConnorMcLeod (Post 1941787)
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 04-28-2013 17:18

Re: Hook/Block grenade buy.
 
Oww, one moment about =D
PHP Code:

    if(user_has_weapon(idi_Item))  
    return 
0

Must remove.. I check now.

FromTheFuture 04-28-2013 17:34

Re: Hook/Block grenade buy.
 
The problem solved.


All times are GMT -4. The time now is 10:54.

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