Raised This Month: $ Target: $400
 0% 

Limit of buy item but he take ammo


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
zollymaN
Junior Member
Join Date: Aug 2021
Location: Romania
Old 08-18-2021 , 12:33   Limit of buy item but he take ammo
Reply With Quote #1

I put a limit on an item so I can't abuse it but when I want to buy the same item I keep deducting from ammo packs why?


Code:
#include <amxmodx>
#include <fun>
#include <zp_apocalypse>

new const item_name[] = "Buy 1000 HP!"
new g_itemid_buyhp
new hpamount
new g_bComprado[ 33 ];
new cvar_limit

public plugin_init() 
{
    register_plugin("[ZP] Buy Health Points", "1.0", "T[h]E Dis[as]teR")
    
    hpamount = register_cvar("zp_buyhp_amount", "1000")
    cvar_limit = register_cvar("zp_buyhp_limit", "1")
    
    g_itemid_buyhp = zp_register_extra_item(item_name, 5, ZP_TEAM_ZOMBIE & ZP_TEAM_HUMAN)
    
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
}
public event_round_start()
{
    arrayset( g_bComprado, 33, 0 );
}
public zp_extra_item_selected(id,itemid)
{
    if(!is_user_alive(id))
        
    return PLUGIN_HANDLED;
    
    if(itemid==g_itemid_buyhp)
    {
        if(zp_get_user_ammo_packs(id) < 20)
        {
            client_print(id, print_chat,"[ZP] Not enough Ammopacks!");
            return PLUGIN_HANDLED;
        }
        else
        {
            if( g_bComprado[ id ] < get_pcvar_num(cvar_limit))
            {
                g_bComprado[ id ] ++;
                set_user_health(id,get_user_health(id)+get_pcvar_num(hpamount));
                zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) - 5);
                client_print(id, print_chat,"[ZP] You Bought HP!");
            }
            else
            {
                client_print(id, print_chat,"[ZP] poti cumpara acest item daar odata pe runda");
            }
        }
    }
    return PLUGIN_CONTINUE;
}
zollymaN is offline
 



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 02:33.


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