round count in menu

Сообщения
271
Реакции
43
Помог
5 раз(а)
Hello, can somebody help make make in this code round count in menu [1/4] [2/4] [3/4]

Код:
#include <amxmodx>
#include <reapi>
#include <vip_system>

#define ADMIN_LOADER    //    Compatible with Admin Loader from neugomon (https://www.neugomon.ru/threads/486/)

#pragma semicolon 1
new const MenuKey = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<9);

enum _:cvars {
    AUTO_MENU,
    GIVE_ITEMS,
    WEAPONSRND,
    AWPM249RND,
    SHOP,
    SHOP_RND
};

new iPistol[MAX_CLIENTS+1], bool:g_bUsePistol, bool:g_bUseWeapon[MAX_CLIENTS+1];

static sItems[10];
new pCvar[cvars], pCvarCfg[cvars];
new g_iRound;

public plugin_init() {
    register_plugin("[ReVIP] Menu", VIP_SYSTEM_VERSION, "pUzzlik");
    register_dictionary("vip_system.txt");

    //    auto open vip menu 1 - on, 0 - off
    pCvar[AUTO_MENU] = register_cvar("open_menu_spawn", "0");
    /*
        flags items
        a - armor
        d - defuse
        f - flashbang
        h - hegranade
        p - pistol
        s - smoke
    */
    pCvar[GIVE_ITEMS] = register_cvar("give_items", "adfhps");
    //    which is available with a round primary weapons
    pCvar[WEAPONSRND] = register_cvar("primary_weapons_rnd", "2");
    //    which is available with a round primary weapons
    pCvar[AWPM249RND] = register_cvar("heavy_weapons_rnd", "4");
    //    if you want to use a custom shop, (1 - enable)
    pCvar[SHOP] = register_cvar("use_custom_shop", "1");
    //    with round displayed shop menu
    pCvar[SHOP_RND] = register_cvar("custom_shop_block_rnd", "2");

    register_clcmd("vipmenu", "ShowMenu");
    register_clcmd("say /vipmenu", "ShowMenu");
    register_clcmd("say_team /vipmenu", "ShowMenu");

    register_clcmd("say", "hook_say");
    register_clcmd("say_team", "hook_say");

    register_menucmd(register_menuid("Vip Menu"), MenuKey, "MenuHandler");
}

public plugin_cfg() {
    get_pcvar_string(pCvar[GIVE_ITEMS],sItems,charsmax(sItems)); trim(sItems);
    pCvarCfg[WEAPONSRND] = get_pcvar_num(pCvar[WEAPONSRND]);
    pCvarCfg[AWPM249RND] = get_pcvar_num(pCvar[AWPM249RND]);
    pCvarCfg[AUTO_MENU] = get_pcvar_num(pCvar[AUTO_MENU]);
    pCvarCfg[SHOP] = get_pcvar_num(pCvar[SHOP]);
    pCvarCfg[SHOP_RND] = get_pcvar_num(pCvar[SHOP_RND]);
}

public vip_core_restart_round(round) {
    arrayset(g_bUseWeapon, false, sizeof(g_bUseWeapon));
    g_iRound = round;
}

public vip_core_player_spawn(const id) {
    if(core_is_bonus_spawn(id)) {
        for(new i, str_len = strlen(sItems); i < str_len ; i++) {
            switch(sItems[i]){
                case 'a': rg_set_user_armor(id, 100, ARMOR_VESTHELM);
                case 'd': {
                    new TeamName:team = get_member(id, m_iTeam);
                    if(team == TEAM_CT) rg_give_defusekit (id, true);
                }
                case 'f': {
                    rg_give_item(id, "weapon_flashbang", GT_APPEND);
                    rg_give_item(id, "weapon_flashbang", GT_APPEND);
                }
                case 'h': rg_give_item(id, "weapon_hegrenade", GT_APPEND);
                case 'p': {
                    switch(iPistol[id]) {
                        case 0: { rg_give_item(id, "weapon_deagle", GT_REPLACE); rg_set_user_bpammo(id, WEAPON_DEAGLE, 35); }
                        case 1: { rg_give_item(id, "weapon_usp", GT_REPLACE); rg_set_user_bpammo(id, WEAPON_USP, 100); }
                        case 2: { rg_give_item(id, "weapon_glock18", GT_REPLACE); rg_set_user_bpammo(id, WEAPON_GLOCK18, 120); }
                    }
                    g_bUsePistol = true;
                }
                case 's': rg_give_item(id, "weapon_smokegrenade", GT_APPEND);
            }
        }

        if(pCvarCfg[AUTO_MENU] && g_iRound >= pCvarCfg[WEAPONSRND]) ShowMenu(id);
    }
}

public hook_say(id) {
    static szMsg[32]; read_args(szMsg, charsmax(szMsg)); remove_quotes(szMsg);
    static const szChoosedWP[][] = { "/ak47", "/m4a1", "/famas", "/awp", "/b51" };

    for(new a; a < sizeof szChoosedWP; a++) {
        if(!strcmp(szMsg, szChoosedWP[a])) {
            if(!core_is_allow_use(id)) break;
            return MenuHandler(id, a);
        }
    }
    return PLUGIN_CONTINUE;
}

public ShowMenu(id) {
    if(!core_is_allow_use(id)) return PLUGIN_HANDLED;

    new szMenu[512], key; key = MENU_KEY_0;
    new iLen, szName[16]; get_entvar(id, var_netname, szName, charsmax(szName));
   
    iLen = formatex(szMenu, charsmax(szMenu), "\r%L \w[\d%L\w]^n\w%L^n", LANG_SERVER, "MENU_NAME", LANG_SERVER, "NAME_SERVER", LANG_SERVER, "WELCOME", szName);

    #if defined ADMIN_LOADER
        new exp = admin_expired(id);
        if(exp > 0) {
            new sys = get_systime();
            if((exp - sys) / 86400 > 0)    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\ywill expired: \w%d d.!^n^n", (exp - sys) / 86400);
        } else if(exp == 0) iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "%L^n^n", LANG_SERVER, "VIP_EXPIRED_PRMANENT");
    #else
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n");
    #endif

    new szUseWpn[2]; formatex(szUseWpn, charsmax(szUseWpn), "%s", g_bUseWeapon[id] ? "d" : "w");

    if(g_iRound < pCvarCfg[WEAPONSRND])
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r1. \d%L \r%L^n\r2. \d%L \r%L^n\r3. \d%L \r%L^n", LANG_SERVER, "AK47", LANG_SERVER, "ROUND", pCvarCfg[WEAPONSRND], LANG_SERVER, "M4A1", LANG_SERVER, "ROUND", pCvarCfg[WEAPONSRND], LANG_SERVER, "FAMAS", LANG_SERVER, "ROUND", pCvarCfg[WEAPONSRND]);
    else {
        key |= MENU_KEY_1|MENU_KEY_2|MENU_KEY_3;
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r1. \%s%L^n\r2. \%s%L^n\r3. \%s%L^n", szUseWpn, LANG_SERVER, "AK47", szUseWpn, LANG_SERVER, "M4A1", szUseWpn, LANG_SERVER, "FAMAS");
    }

    if(g_iRound < pCvarCfg[AWPM249RND])
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r4. \d%L \r%L^n\r5. \d%L \r%L^n^n", LANG_SERVER, "AWP", LANG_SERVER, "ROUND", pCvarCfg[AWPM249RND], LANG_SERVER, "GALIL", LANG_SERVER, "ROUND", pCvarCfg[AWPM249RND]);
    else {
        key |= MENU_KEY_4|MENU_KEY_5;
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r4. \%s%L^n\r5. \%s%L^n^n", szUseWpn, LANG_SERVER, "AWP", szUseWpn, LANG_SERVER, "GALIL");
    }

    if(g_bUsePistol) {
        key |= MENU_KEY_6;
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r6. %L \r[\w%s\r]^n", LANG_SERVER, "PISTOL", iPistol[id] == 0 ? "Deagle" : iPistol[id] == 1 ? "USP" : "Glock");
    }
    formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r0. %L", LANG_SERVER, "EXIT");

    set_member(id, m_iMenu, Menu_OFF);
    return show_menu(id, key, szMenu, -1, "Vip Menu");
}

public MenuHandler(id, key) {
    if(key <= 4) {
        /***    Защита от дурака    ***/
        if(g_iRound < pCvarCfg[WEAPONSRND]) return client_print_color(id, 0, "%L %L", LANG_SERVER, "CHAT_TAG", LANG_SERVER, "PISTOLS_ROUND");
        /***    End        ***/
        if(g_bUseWeapon[id]) return client_print_color(id, 0, "%L %L", LANG_SERVER, "CHAT_TAG", LANG_SERVER, "ALREDY_WEAPON_RND");
        g_bUseWeapon[id] = true;
       
        static const szChoosedBP[] = { 90, 90, 90, 30, 90 };
        static const szChoosedWP[][] = { "weapon_ak47", "weapon_m4a1", "weapon_famas", "weapon_awp", "weapon_galil" };
       
        return rg_give_items(id, szChoosedWP[key], szChoosedBP[key]);
    }
    else if (key == 5) GivePistol(id);
    return PLUGIN_HANDLED;
}

public GivePistol(id) {
    iPistol[id] >= 2 ? (iPistol[id] = 0) : iPistol[id]++;
    ShowMenu(id);
    return PLUGIN_HANDLED;
}

stock rg_give_items(id, currWeaponName[], ammoAmount) {
    rg_drop_items_by_slot(id, PRIMARY_WEAPON_SLOT);

    rg_give_item(id, currWeaponName, GT_APPEND);
    rg_set_user_bpammo(id, rg_get_weapon_info(currWeaponName, WI_ID), ammoAmount);

    engclient_cmd(id, currWeaponName);
    return PLUGIN_HANDLED;
}

ROUND = [%d raund]
 

Вложения

Последнее редактирование:
Сообщения
1,304
Реакции
2,303
Помог
57 раз(а)
Скриншот 204.jpg

This section contains topics that require assistance with the revision or explanation of the material.
The topic should be published attempts (diff code or sequence of actions) self-search solutions.
If you have no experience and attempts to understand the problem yourself, then you should go to the "Purchase" section.
 
  • Нравится
Реакции: Murz
Сообщения
48
Реакции
151
line 138 change to
Код:
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r1. \d%L \r%L^n\r2. \d%L \r%L^n\r3. \d%L \r%L^n", LANG_SERVER, "AK47", LANG_SERVER, "ROUND", g_iRound, pCvarCfg[WEAPONSRND], LANG_SERVER, "M4A1", LANG_SERVER, "ROUND", g_iRound, pCvarCfg[WEAPONSRND], LANG_SERVER, "FAMAS", LANG_SERVER, "ROUND", g_iRound, pCvarCfg[WEAPONSRND]);
and 145 change to
Код:
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r4. \d%L \r%L^n\r5. \d%L \r%L^n^n", LANG_SERVER, "AWP", LANG_SERVER, "ROUND", g_iRound, pCvarCfg[AWPM249RND], LANG_SERVER, "GALIL", LANG_SERVER, "ROUND", g_iRound, pCvarCfg[AWPM249RND]);
lang:

ROUND = [%i/%i raund]

and another tip: replace all LANG_SERVER constant to player index (id)

Next time, give your attempts to solve the problem. Otherwise it looks like an order.
 
Последнее редактирование:

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

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