Магазин

Сообщения
36
Реакции
1
Всем привет, пытаюсь сделать магазин для зомби и людей, все вроде получилось но есть одна проблема, за людей можно все купить, а вот за зомби открывает магазин и ничего нельзя купить

Код:
#include <amxmodx>
#include <cstrike>
#include <amxmisc>
#include <fun>
#include <hamsandwich>
#include <fakemeta_util>
#include <WPMGPrintChatColor>
#include <biohazard>

#define PLUGIN    "Shop"
#define VERSION    "1.0"
#define AUTHOR    "StudenT"

#define ACCESS    ADMIN_LEVEL_H

#define Flag(%1)        get_user_flags(%1) & ACCESS
#define SetMoney(%1)    cs_set_user_money(%1)
#define GetMoney(%1)    cs_get_user_money(%1)

#define COST_ARMOR        get_pcvar_num(g_Cvar[2])
#define COST_HEGREN    get_pcvar_num(g_Cvar[3])
#define COST_FLASHGREN        get_pcvar_num(g_Cvar[4])
#define COST_SMOKEGREN    get_pcvar_num(g_Cvar[5])
#define COST_INVIS        get_pcvar_num(g_Cvar[6])
#define COST_NAPLAM        get_pcvar_num(g_Cvar[7])
#define COST_NIGHT        get_pcvar_num(g_Cvar[8])
#define COST_SNARK    get_pcvar_num(g_Cvar[9])
#define COST_HP        get_pcvar_num(g_Cvar[10])
#define COST_SHOK    get_pcvar_num(g_Cvar[11])
#define COST_RAGE    get_pcvar_num(g_Cvar[12])

native bio_buy_snark(id) //Натив покупки Снарка

new g_Discount[33]
new g_Cvar[13]

new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)


public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    g_Cvar[0] = register_cvar("shop_enabled", "")
    g_Cvar[1] = register_cvar("shop_admdiscount", "")
    
    g_Cvar[2] = register_cvar("shop_costarmor", "")
    g_Cvar[3] = register_cvar("shop_costhegren", "")
    g_Cvar[4] = register_cvar("shop_costflashgren", "")
    g_Cvar[5] = register_cvar("shop_costsmokegren", "")
    g_Cvar[6] = register_cvar("shop_costinvis", "")
    g_Cvar[7] = register_cvar("shop_costnapalm", "")
    g_Cvar[8] = register_cvar("shop_costnight", "")
    g_Cvar[9] = register_cvar("shop_costsnark", "")
    g_Cvar[10] = register_cvar("shop_costhp", "")
    g_Cvar[11] = register_cvar("shop_costshokgren", "")
    g_Cvar[12] = register_cvar("shop_costrage", "")
    
    register_menu("ShopMenu", keys, "ActionShop")
    register_menu("VIPShopMenu", keys, "VIPActionShop")
    
    register_clcmd("shop", "vshop")
    register_clcmd("say /shop", "vshop")
    
    register_dictionary("shop.txt")
}

public vshop(id)
{   
    if(get_pcvar_num(g_Cvar[0]) == 0)
    {
        PrintChatColor(id, _, "%L %L", LANG_PLAYER, "SHOP_CHATPREFIX", LANG_PLAYER, "SHOP_DISABLED")
        return PLUGIN_HANDLED
    }

    if(Flag(id))    g_Discount[id] = get_pcvar_num(g_Cvar[1])
    else    g_Discount[id] = 0
    
    if(is_user_zombie(id))
        VIPShowShopMenu(id)
    else
    if(!is_user_zombie(id))
    ShowShopMenu(id)
    return PLUGIN_HANDLED
}

public plugin_cfg()
{
    new g_Cfg[128]
    get_localinfo("amxx_configsdir", g_Cfg, charsmax(g_Cfg))
    return server_cmd("exec %s/shop.cfg", g_Cfg)
}

public ShowShopMenu(id)
{
    if(is_user_zombie(id))
    {
        return PLUGIN_HANDLED;
    }
    
    static g_Menu[512], iLen = 0
    iLen = 0
    
    if(g_Discount[id] > 0) iLen = formatex(g_Menu, 511, "%L^n^n", LANG_PLAYER, "SHOP_TITLEDISC", GetMoney(id), g_Discount[id])
    else iLen = formatex(g_Menu, 511, "%L^n^n", LANG_PLAYER, "SHOP_TITLENODISC", GetMoney(id))
    
    if(GetMoney(id) >= GetItemCost(id, COST_ARMOR))
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM1", GetItemCost(id, COST_ARMOR))
    else
    {
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM1_1", GetItemCost(id, COST_ARMOR))
    }
    
    if(GetMoney(id) >= GetItemCost(id, COST_HEGREN))
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM2", GetItemCost(id, COST_HEGREN))
    else
    {
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM2_1", GetItemCost(id, COST_HEGREN))
    }
    
    if(GetMoney(id) >= GetItemCost(id, COST_FLASHGREN))
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM3", GetItemCost(id, COST_FLASHGREN))
    else
    {
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM3_1", GetItemCost(id, COST_FLASHGREN))
    }
    
    if(GetMoney(id) >= GetItemCost(id, COST_SMOKEGREN))
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM4", GetItemCost(id, COST_SMOKEGREN))
    else
    {
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM4_1", GetItemCost(id, COST_SMOKEGREN))
    }
    
    if(GetMoney(id) >= GetItemCost(id, COST_INVIS))
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM5", GetItemCost(id, COST_INVIS))
    else
    {
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM5_1", GetItemCost(id, COST_INVIS))
    }
    
    if(GetMoney(id) >= GetItemCost(id, COST_NAPLAM))
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM6", GetItemCost(id, COST_NAPLAM))
    else
    {
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM6_1", GetItemCost(id, COST_NAPLAM))
    }
    
    iLen += formatex(g_Menu[iLen], 511 - iLen, "^n%L", LANG_PLAYER, "SHOP_ITEMEXIT")
    
    show_menu(id, keys, g_Menu, -1, "ShopMenu")

    return PLUGIN_HANDLED
}

public ActionShop(id, iKey)
{
    if(is_user_zombie(id))
    {
                return PLUGIN_HANDLED;
    }             
        
    switch(iKey)
    {
        case 0:
        {
            if(GetMoney(id) < GetItemCost(id, COST_ARMOR))
            
            PrintChatColor(id, _, "%L %L", LANG_PLAYER, "SHOP_CHATPREFIX", LANG_PLAYER, "SHOP_COSTARMOR")
            SetMoney(id, GetMoney(id) - GetItemCost(id, COST_ARMOR))
            cs_set_user_armor(id, 100, CS_ARMOR_VESTHELM)
        }
        
        case 1:
        {
            if(GetMoney(id) < GetItemCost(id, COST_HEGREN))
            
            PrintChatColor(id, _, "%L %L", LANG_PLAYER, "SHOP_CHATPREFIX", LANG_PLAYER, "SHOP_COSTHEGREN")
            SetMoney(id, GetMoney(id) - GetItemCost(id, COST_HEGREN))
            fm_give_item(id, "weapon_hegrenade")
        }
        
        case 2:
        {
            if(GetMoney(id) < GetItemCost(id, COST_FLASHGREN))
            
            PrintChatColor(id, _, "%L %L", LANG_PLAYER, "SHOP_CHATPREFIX", LANG_PLAYER, "SHOP_COSTFLASHGREN")
            SetMoney(id, GetMoney(id) - GetItemCost(id, COST_FLASHGREN))
            fm_give_item(id, "weapon_flashbang")
        }
        
        case 3:
        {
            if(GetMoney(id) < GetItemCost(id, COST_SMOKEGREN))
            
            PrintChatColor(id, _, "%L %L", LANG_PLAYER, "SHOP_CHATPREFIX", LANG_PLAYER, "SHOP_COSTSMOKEGREN")
            SetMoney(id, GetMoney(id) - GetItemCost(id, COST_SMOKEGREN))
            fm_give_item(id, "weapon_smokegrenade")
        }
        
        case 4:
        {
            if(GetMoney(id) < GetItemCost(id, COST_INVIS))
            
            PrintChatColor(id, _, "%L %L", LANG_PLAYER, "SHOP_CHATPREFIX", LANG_PLAYER, "SHOP_COSTINVIS")
            SetMoney(id, GetMoney(id) - GetItemCost(id, COST_INVIS))
            cs_set_user_nvg(id)
        }
        
        case 5:
        {
            if(GetMoney(id) < GetItemCost(id, COST_NAPLAM))
            
            PrintChatColor(id, _, "%L %L", LANG_PLAYER, "SHOP_CHATPREFIX", LANG_PLAYER, "SHOP_COSTNAPLAM")
            SetMoney(id, GetMoney(id) - GetItemCost(id, COST_NAPLAM))
            client_cmd(id, "napalm")
        }
    }
    return PLUGIN_HANDLED
}

public VIPShowShopMenu(id)
{
    
    static g_Menu[512], iLen = 0
    iLen = 0
    
    if(g_Discount[id] > 0) iLen = formatex(g_Menu, 511, "%L^n^n", LANG_PLAYER, "SHOP_TITLEDISC", GetMoney(id), g_Discount[id])
    else iLen = formatex(g_Menu, 511, "%L^n^n", LANG_PLAYER, "SHOP_TITLENODISC", GetMoney(id))
    
    if(GetMoney(id) >= GetItemCost(id, COST_NIGHT))
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM7", GetItemCost(id, COST_NIGHT))
    else
    {
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM7_1", GetItemCost(id, COST_NIGHT))
    }
    
    if(GetMoney(id) >= GetItemCost(id, COST_SNARK))
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM8", GetItemCost(id, COST_SNARK))
    else
    {
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM8_1", GetItemCost(id, COST_SNARK))
    }
    
    if(GetMoney(id) >= GetItemCost(id, COST_HP))
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM9", GetItemCost(id, COST_HP))
    else
    {
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM9_1", GetItemCost(id, COST_HP))
    }
    
    if(GetMoney(id) >= GetItemCost(id, COST_SHOK))
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM10", GetItemCost(id, COST_SHOK))
    else
    {
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM10_1", GetItemCost(id, COST_SHOK))
    }
    
    if(GetMoney(id) >= GetItemCost(id, COST_RAGE))
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM11", GetItemCost(id, COST_RAGE))
    else
    {
        iLen += formatex(g_Menu[iLen], 511 - iLen, "%L^n", LANG_PLAYER, "SHOP_ITEM11_1", GetItemCost(id, COST_RAGE))
    }
    
    iLen += formatex(g_Menu[iLen], 511 - iLen, "^n%L", LANG_PLAYER, "SHOP_ITEMEXIT")
    
    show_menu(id, keys, g_Menu, -1, "VIPShopMenu")

    return PLUGIN_HANDLED;
}

public VIPActionShop(id, iKey)
{
    switch(iKey)
    {
        case 0:
        {
            if(GetMoney(id) < GetItemCost(id, COST_NIGHT))
            
            PrintChatColor(id, _, "%L %L", LANG_PLAYER, "SHOP_CHATPREFIX", LANG_PLAYER, "SHOP_COSTNIGHT")
            SetMoney(id, GetMoney(id) - GetItemCost(id, COST_NIGHT))
            client_cmd(id, "night")
        }
        
        case 1:
        {
            if(GetMoney(id) < GetItemCost(id, COST_SNARK))
            
            PrintChatColor(id, _, "%L %L", LANG_PLAYER, "SHOP_CHATPREFIX", LANG_PLAYER, "SHOP_COSTSNARK")
            SetMoney(id, GetMoney(id) - GetItemCost(id, COST_SNARK))
            bio_buy_snark(id)
        }
        
        case 2:
        {
            if(GetMoney(id) < GetItemCost(id, COST_HP))
            
            PrintChatColor(id, _, "%L %L", LANG_PLAYER, "SHOP_CHATPREFIX", LANG_PLAYER, "SHOP_COSTHP")
            SetMoney(id, GetMoney(id) - GetItemCost(id, COST_HP))
            set_user_health(id,get_user_health(id) + 70)
        }
        
        case 3:
        {
            if(GetMoney(id) < GetItemCost(id, COST_SHOK))
            
            PrintChatColor(id, _, "%L %L", LANG_PLAYER, "SHOP_CHATPREFIX", LANG_PLAYER, "SHOP_COSTSHOK")
            SetMoney(id, GetMoney(id) - GetItemCost(id, COST_SHOK))
            client_cmd(id, "flare")
        }
        case 4:
        {
            if(GetMoney(id) < GetItemCost(id, COST_RAGE))
            
            PrintChatColor(id, _, "%L %L", LANG_PLAYER, "SHOP_CHATPREFIX", LANG_PLAYER, "SHOP_COSTRAGE")
            SetMoney(id, GetMoney(id) - GetItemCost(id, COST_RAGE))
            client_cmd(id, "rage")
        }
    }
    return PLUGIN_HANDLED
}

GetItemCost(id, iCost)
{
    iCost -= floatround(iCost / 100.0 * g_Discount[id])
    return iCost
}
 
Сообщения
3,593
Реакции
1,576
Помог
141 раз(а)
В каком плане "нельзя"? Не работают пункты меню, или что?
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу