More Weapons

Unpaid Requests, Public Plugins
Post Reply
User avatar
Luxurious
Mod Tester
Mod Tester
Egypt
Posts: 177
Joined: 6 years ago
Location: Egypt
Contact:

More Weapons

#1

Post by Luxurious » 5 years ago

I need To Add More Weapons to My Weapons Menu

Code: Select all

#include <zombie_escape>
#include <ze_levels>
 
native give_golden_m3(id);
native give_golden_mp5(id);
native give_golden_m4a1(id);
native ze_giveminigun(id);
native give_thantos5(id);
native give_frost_m4a1(id);
 
// Setting File
new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
 
// Keys
const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
const OFFSET_CSMENUCODE = 205
 
// Primary Weapons Entities [Default Values]
new const szPrimaryWeaponEnt[][] =
{
    "weapon_xm1014",  // Level 0
    "weapon_ump45",   // Level 0
    "weapon_m3",      // Level 1
    "weapon_mp5navy", // Level 2
    "weapon_p90",     // Level 3
    "weapon_galil",   // Level 4
    "weapon_famas",   // Level 5
    "weapon_sg550",   // Level 6
    "weapon_g3sg1",   // Level 7
    "weapon_m249",    // Level 8
    "weapon_sg552",   // Level 9
    "weapon_aug",     // Level 10
    "weapon_m4a1",    // Level 11
    "weapon_ak47"     // Level 12
}
 
// Secondary Weapons Entities [Default Values]
new const szSecondaryWeaponEnt[][]=
{
    "weapon_usp",         // Level 0
    "weapon_p228",        // Level 0
    "weapon_glock18",     // Level 1
    "weapon_fiveseven",   // Level 2
    "weapon_deagle",      // Level 3
    "weapon_elite"        // Level 4
}
 
// Primary and Secondary Weapons Names [Default Values]
new const szWeaponNames[][] =
{
    "",
    "P228",
    "",
    "Scout",
    "HE Grenade",
    "XM1014",
    "",
    "MAC-10",
    "AUG",
    "Smoke Grenade",
    "Dual Elite",
    "Five Seven",
    "UMP 45",
    "SG-550",
    "Galil",
    "Famas",
    "USP",
    "Glock",
    "AWP",
    "MP5",
    "M249",
    "M3",
    "M4A1",
    "TMP",
    "G3SG1",
    "Flashbang",
    "Desert Eagle",
    "SG-552",
    "AK-47",
    "",
    "P90"
}
 
// Max Back Clip Ammo (Change it From here if you need)
new const szMaxBPAmmo[] =
{
    -1,
    999,
    -1,
    999,
    1,
    999,
    1,
    999,
    999,
    1,
    999,
    999,
    2090,
    2090,
    2090,
    2090,
    2090,
    2090,
    2090,
    2090,
    2090,
    32,
    2090,
    2090,
    2090,
    2,
    2090,
    2090,
    2090,
    -1,
    2900
}
 
// Menu selections
const MENU_KEY_AUTOSELECT = 7
const MENU_KEY_BACK = 7
const MENU_KEY_NEXT = 8
const MENU_KEY_EXIT = 9
 
// Variables
new Array:g_szPrimaryWeapons, Array:g_szSecondaryWeapons
 
new g_iMenuData[33][4],
    Float:g_fBuyTimeStart[33],
    bool:g_bBoughtPrimary[33],
    bool:g_bBoughtSecondary[33],
    WPN_MAXIDS[33]
 
// Define
#define WPN_STARTID g_iMenuData[id][0]
#define WPN_SELECTION (g_iMenuData[id][0]+key)
#define WPN_AUTO_ON g_iMenuData[id][1]
#define WPN_AUTO_PRI g_iMenuData[id][2]
#define WPN_AUTO_SEC g_iMenuData[id][3]
 
// Cvars
new g_pCvarBuyTime,
    g_pCvarHeGrenade,
    g_pCvarSmokeGrenade,
    g_pCvarFlashGrenade,
    g_pCvarBlockWeapLowLevel
 
public plugin_natives()
{
    register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
    register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
    register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
}
 
public plugin_precache()
{
    // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
    g_szPrimaryWeapons = ArrayCreate(32, 1)
    g_szSecondaryWeapons = ArrayCreate(32, 1)
   
    // Load from external file
    amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
   
    // If we couldn't load from file, use and save default ones
   
    new iIndex
   
    if (ArraySize(g_szPrimaryWeapons) == 0)
    {
        for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
            ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
       
        // If not found .ini File Create it and save default values in it
        amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    }
   
    if (ArraySize(g_szSecondaryWeapons) == 0)
    {
        for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
            ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
       
        // If not found .ini File Create it and save default values in it
        amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    }
}
 
public plugin_init()
{
    register_plugin("[ZE] Levels Weapons Menu", "1.1", "Raheem")
   
    // Commands
    register_clcmd("guns", "Cmd_Buy")
    register_clcmd("say /enable", "Cmd_Enable")
    register_clcmd("say_team /enable", "Cmd_Enable")
   
    // Cvars
    g_pCvarBuyTime = register_cvar("ze_buy_time", "60")
    g_pCvarHeGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
    g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "0")
    g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "0")
    g_pCvarBlockWeapLowLevel = register_cvar("ze_block_weapons_lowlvl", "1")
   
    // Menus
    register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
    register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
   
    // Hams
    RegisterHam(Ham_Touch, "weaponbox", "Fw_TouchWeapon_Pre", 0)
    RegisterHam(Ham_Touch, "armoury_entity", "Fw_TouchWeapon_Pre", 0)
}
 
public client_disconnected(id)
{
    WPN_AUTO_ON = 0
    WPN_STARTID = 0
}
 
public Cmd_Enable(id)
{
    if (WPN_AUTO_ON)
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
        WPN_AUTO_ON = 0
    }
}
 
public Cmd_Buy(id)
{
    // Player Zombie
    if (ze_is_user_zombie(id))
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
        return
    }
   
    // Player Dead
    if (!is_user_alive(id))
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
        return
    }
   
    // Already bought
    if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
    }
   
    Show_Available_Buy_Menus(id)
}
 
public ze_user_humanized(id)
{
    // Static Values
    switch (ze_get_user_level(id))
    {
        case 0: WPN_MAXIDS[id] = 2
        case 1: WPN_MAXIDS[id] = 3
        case 2: WPN_MAXIDS[id] = 4
        case 3: WPN_MAXIDS[id] = 5
        case 4: WPN_MAXIDS[id] = 6
        case 5: WPN_MAXIDS[id] = 7
        case 6: WPN_MAXIDS[id] = 8
        case 7: WPN_MAXIDS[id] = 9
        case 8: WPN_MAXIDS[id] = 10
        case 9: WPN_MAXIDS[id] = 11
        case 10: WPN_MAXIDS[id] = 12
        case 11: WPN_MAXIDS[id] = 13
        case 12..14: WPN_MAXIDS[id] = 14
        case 15..19: WPN_MAXIDS[id] = 15 // Golden m3
        case 20..24: WPN_MAXIDS[id] = 16 // Golden MP5
        case 25..29: WPN_MAXIDS[id] = 17 // Golden M4A1
        case 30: WPN_MAXIDS[id] = 18     // Golden AK47
    }
   
    if (ze_get_user_level(id) > 30)
    {
        WPN_MAXIDS[id] = 18
    }
 
    // Buyzone time starts when player is set to human
    g_fBuyTimeStart[id] = get_gametime()
   
    g_bBoughtPrimary[id] = false
    g_bBoughtSecondary[id] = false
   
    // Player dead or zombie
    if (!is_user_alive(id) || ze_is_user_zombie(id))
        return
   
    if (WPN_AUTO_ON)
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
        Buy_Primary_Weapon(id, WPN_AUTO_PRI)
        Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
    }
   
    // Open available buy menus
    Show_Available_Buy_Menus(id)
   
    // Give HE Grenade
    if (get_pcvar_num(g_pCvarHeGrenade) != 0)
        rg_give_item(id, "weapon_hegrenade")
   
    // Give Smoke Grenade
    if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
        rg_give_item(id, "weapon_smokegrenade")
   
    // Give Flashbang Grenade
    if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
        rg_give_item(id, "weapon_flashbang")
}
 
public Show_Available_Buy_Menus(id)
{
    // Already Bought
    if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
        return
   
    // Here we use if and else if so we make sure that Primary weapon come first then secondary
    if (!g_bBoughtPrimary[id])
    {
        // Primary     
        Show_Menu_Buy_Primary(id)
    }
    else if (!g_bBoughtSecondary[id])
    {
        // Secondary
        Show_Menu_Buy_Secondary(id)
    }
}
 
public Show_Menu_Buy_Primary(id)
{
    new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
   
    if (iMenuTime <= 0)
    {
        ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
        return
    }
   
    static szMenu[300], szWeaponName[32]
    new iLen, iIndex, iMaxLoops = min(WPN_STARTID+7, WPN_MAXIDS[id])
   
    // Title
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L \w[\r%d\w-\r%d\w]^n^n", id, "MENU_PRIMARY_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS[id]))
   
    // 1-7. Weapon List
    for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
    {
        if (ze_get_user_level(id) == 0 && iIndex >= 2||
        ze_get_user_level(id) == 1 && iIndex >= 3 ||
        ze_get_user_level(id) == 2 && iIndex >= 4 ||
        ze_get_user_level(id) == 3 && iIndex >= 5 ||
        ze_get_user_level(id) == 4 && iIndex >= 6 ||
        ze_get_user_level(id) == 5 && iIndex >= 7 ||
        ze_get_user_level(id) == 6 && iIndex >= 8 ||
        ze_get_user_level(id) == 7 && iIndex >= 9 ||
        ze_get_user_level(id) == 8 && iIndex >= 10 ||
        ze_get_user_level(id) == 9 && iIndex >= 11 ||
        ze_get_user_level(id) == 10 && iIndex >= 12 ||
        ze_get_user_level(id) == 11 && iIndex >= 13 ||
        ze_get_user_level(id) == 12 && iIndex >= 14)
        {
            break
        }
       
        /*
        *  Note that WPN_MAXIDS start from 1 but iIndex start from 0.
        */
       
        // Golden M3
        if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
                break;
            }
        }
       
        // Golden MP5
        if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
                break;
            }
        }
       
        // Golden M4A1
        if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
                break;
            }
        }
       
        // Golden AK47
        if (ze_get_user_level(id) >= 30)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }
           
            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Thantos-5")
                break;
            }
        }
       
        // Must check if iIndex < 14 means max is AK47
        if (iIndex < 14)
        {
            ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
            iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
        }
    }
   
    if (iIndex < 7)
    {
        ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
   
    if (ze_get_user_level(id) == 5)
    {
        ArrayGetString(g_szPrimaryWeapons, 7, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 6)
    {
        ArrayGetString(g_szPrimaryWeapons, 8, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 7)
    {
        ArrayGetString(g_szPrimaryWeapons, 9, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 8)
    {
        ArrayGetString(g_szPrimaryWeapons, 10, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 9)
    {
        ArrayGetString(g_szPrimaryWeapons, 11, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 10)
    {
        ArrayGetString(g_szPrimaryWeapons, 12, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 11)
    {
        ArrayGetString(g_szPrimaryWeapons, 13, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) >= 12 && ze_get_user_level(id) < 15) // Golden M3
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yFrost M4A1^n")
    }
    else if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20) // Golden MP5
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \yGolden MP5^n")
    }
    else if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25) // Golden M4A1
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 25 Unlock\w: \yGolden M4A1^n")
    }
    else if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30) // Thantos-5
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yThantos-5^n")
    }
 
    // 8. Auto Select
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w8.\y %L \w[\r%L\w]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
   
    // 9. Next/Back - 0. Exit
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\y9.\r %L \w/ \r%L^n^n\w0.\y %L", id, "NEXT", id, "BACK", id, "EXIT")
   
    // Fix for AMXX custom menus
    set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
}
 
public Show_Menu_Buy_Secondary(id)
{
    new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
   
    if (iMenuTime <= 0)
    {
        ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
        return
    }
   
    static szMenu[250], szWeaponName[32]
    new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
   
    // Title
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
   
    // 1-6. Weapon List
    for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
    {
        if (ze_get_user_level(id) == 0 && iIndex >= 2 ||
        ze_get_user_level(id) == 1 && iIndex >= 3 ||
        ze_get_user_level(id) == 2 && iIndex >= 4 ||
        ze_get_user_level(id) == 3 && iIndex >= 5 ||
        ze_get_user_level(id) == 4 && iIndex >= 6)
        {
            break
        }
       
        ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w%d.\y %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
    }
   
    if (iIndex < ArraySize(g_szSecondaryWeapons))
    {
        ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r Next Level Unlock\w: \y%s", szWeaponNames[get_weaponid(szWeaponName)])
    }
   
    // 8. Auto Select
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w8.\y %L \w[\r%L\w]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
   
    // 0. Exit
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\y %L", id, "EXIT")
   
    // Fix for AMXX custom menus
    set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
}
 
public Menu_Buy_Primary(id, key)
{
    // Player dead or zombie or already bought primary
    if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
        return PLUGIN_HANDLED
   
    // Special keys / weapon list exceeded
    if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS[id])
    {
        switch (key)
        {
            case MENU_KEY_AUTOSELECT: // toggle auto select
            {
                WPN_AUTO_ON = 1 - WPN_AUTO_ON
            }
            case MENU_KEY_NEXT: // next/back
            {
                if (WPN_STARTID+7 < WPN_MAXIDS[id])
                    WPN_STARTID += 7
                else
                    WPN_STARTID = 0
            }
            case MENU_KEY_EXIT: // exit
            {
                return PLUGIN_HANDLED
            }
        }
       
        // Show buy menu again
        Show_Menu_Buy_Primary(id)
        return PLUGIN_HANDLED
    }
   
    // Store selected weapon id
    WPN_AUTO_PRI = WPN_SELECTION
   
    // Buy primary weapon
    Buy_Primary_Weapon(id, WPN_AUTO_PRI)
   
    // Show Secondary Weapons
    Show_Available_Buy_Menus(id)
   
    return PLUGIN_HANDLED
}
 
public Buy_Primary_Weapon(id, selection)
{
    if (selection == 14) // Frost M4A1
    {
        give_frost_m4a1(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 15) // Golden MP5
    {
        give_golden_mp5(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 16) // Golden M4A1
    {
        give_golden_m4a1(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 17) // Thantos-5
    {
        give_thantos5(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
   
    static szWeaponName[32]
    ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    new iWeaponId = get_weaponid(szWeaponName)
   
    // Strip and Give Full Weapon
    rg_give_item(id, szWeaponName, GT_REPLACE)
    rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
   
    // Primary bought
    g_bBoughtPrimary[id] = true
    return true;
}
 
public Menu_Buy_Secondary(id, key)
{
    // Player dead or zombie or already bought secondary
    if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
        return PLUGIN_HANDLED
   
    // Special keys / weapon list exceeded
    if (key >= ArraySize(g_szSecondaryWeapons))
    {
        // Toggle autoselect
        if (key == MENU_KEY_AUTOSELECT)
            WPN_AUTO_ON = 1 - WPN_AUTO_ON
       
        // Reshow menu unless user exited
        if (key != MENU_KEY_EXIT)
            Show_Menu_Buy_Secondary(id)
       
        return PLUGIN_HANDLED
    }
   
    // Store selected weapon id
    WPN_AUTO_SEC = key
   
    // Buy secondary weapon
    Buy_Secondary_Weapon(id, key)
   
    return PLUGIN_HANDLED
}
 
public Buy_Secondary_Weapon(id, selection)
{
    if ( ((selection == 2) && (ze_get_user_level(id) < 1)) ||
    ((selection == 3) && (ze_get_user_level(id) < 2)) ||
    ((selection == 4) && (ze_get_user_level(id) < 3)) ||
    ((selection == 5) && (ze_get_user_level(id) < 4)) )
    {
        Show_Menu_Buy_Secondary(id)
        return;
    }
 
    static szWeaponName[32]
    ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    new iWeaponId = get_weaponid(szWeaponName)
   
    // Strip and Give Full Weapon
    rg_give_item(id, szWeaponName, GT_REPLACE)
    rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    ze_giveminigun(id)
 
   
    // Secondary bought
    g_bBoughtSecondary[id] = true
}
 
public Fw_TouchWeapon_Pre(iEnt, id)
{
    if (get_pcvar_num(g_pCvarBlockWeapLowLevel) == 0)
        return HAM_IGNORED;
   
    // Not alive or Not Valid Weapon?
    if(!is_user_alive(id) || !pev_valid(iEnt))
        return HAM_IGNORED;
   
    // Get Weapon Model
    new szWeapModel[32]
    pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
   
    // Remove "models/w_" and ".mdl"
    copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
   
    // Set for mp5 to be same as "weapon_mp5navy"
    if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
        szWeapModel = "mp5navy"
   
    // Add "weapon_" to all model names
    static szWeaponEnt[32]
    formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)
 
    // Get it's index in Weapon Array
    new iIndex, i
   
    // I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
    for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
    {
        new szPrimaryWeapon[32]
        ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
       
        if (equali(szWeaponEnt, szPrimaryWeapon))
            iIndex = i
    }
   
    if (ze_get_user_level(id) == 0 && iIndex > 1)
    {
        return HAM_SUPERCEDE;
    }
   
    for (i = 1; i <= 11; i++)
    {
        if ((ze_get_user_level(id) == i) && iIndex > i+1)
        {
            return HAM_SUPERCEDE;
        }
    }
   
    return HAM_IGNORED;
}
 
// Natives
public native_ze_show_weapon_menu(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return false
    }
   
    Cmd_Buy(id)
    return true
}
 
public native_ze_is_auto_buy_enabled(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return -1;
    }
   
    return WPN_AUTO_ON;
}
 
public native_ze_disable_auto_buy(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return false
    }
   
    WPN_AUTO_ON = 0;
    return true
}
First Werpon

Code: Select all

native_give_balrog
From Level 35

Code: Select all

native_give_watergun
from Level 40
and Pistol

Code: Select all

native_give_dual_infinity
From level 15.
DRK Zombie-Escape V1.6
IP : 81.169.153.129:27015

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#2

Post by sPe3doN » 5 years ago

here i didn't test it:

Code: Select all

#include <zombie_escape>
#include <ze_levels>
 
native give_golden_m3(id);
native give_golden_mp5(id);
native give_golden_m4a1(id);
native ze_giveminigun(id);
native give_thantos5(id); 
native give_frost_m4a1(id);
native give_balrog(id);
native give_watergun(id);
native give_dual_infinity(id);

 
// Setting File
new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
 
// Keys
const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
const OFFSET_CSMENUCODE = 205
 
// Primary Weapons Entities [Default Values]
new const szPrimaryWeaponEnt[][] =
{
    "weapon_xm1014",  // Level 0
    "weapon_ump45",   // Level 0
    "weapon_m3",      // Level 1
    "weapon_mp5navy", // Level 2
    "weapon_p90",     // Level 3
    "weapon_galil",   // Level 4
    "weapon_famas",   // Level 5
    "weapon_sg550",   // Level 6
    "weapon_g3sg1",   // Level 7
    "weapon_m249",    // Level 8
    "weapon_sg552",   // Level 9
    "weapon_aug",     // Level 10
    "weapon_m4a1",    // Level 11
    "weapon_ak47"     // Level 12
}
 
// Secondary Weapons Entities [Default Values]
new const szSecondaryWeaponEnt[][]=
{
    "weapon_usp",         // Level 0
    "weapon_p228",        // Level 0
    "weapon_glock18",     // Level 1
    "weapon_fiveseven",   // Level 2
    "weapon_deagle",      // Level 3
    "weapon_elite"        // Level 4
}
 
// Primary and Secondary Weapons Names [Default Values]
new const szWeaponNames[][] =
{
    "",
    "P228",
    "",
    "Scout",
    "HE Grenade",
    "XM1014",
    "",
    "MAC-10",
    "AUG",
    "Smoke Grenade",
    "Dual Elite",
    "Five Seven",
    "UMP 45",
    "SG-550",
    "Galil",
    "Famas",
    "USP",
    "Glock",
    "AWP",
    "MP5",
    "M249",
    "M3",
    "M4A1",
    "TMP",
    "G3SG1",
    "Flashbang",
    "Desert Eagle",
    "SG-552",
    "AK-47",
    "",
    "P90"
}
 
// Max Back Clip Ammo (Change it From here if you need)
new const szMaxBPAmmo[] =
{
    -1,
    999,
    -1,
    999,
    1,
    999,
    1,
    999,
    999,
    1,
    999,
    999,
    2090,
    2090,
    2090,
    2090,
    2090,
    2090,
    2090,
    2090,
    2090,
    32,
    2090,
    2090,
    2090,
    2,
    2090,
    2090,
    2090,
    -1,
    2900
}
 
// Menu selections
const MENU_KEY_AUTOSELECT = 7
const MENU_KEY_BACK = 7
const MENU_KEY_NEXT = 8
const MENU_KEY_EXIT = 9
 
// Variables
new Array:g_szPrimaryWeapons, Array:g_szSecondaryWeapons
 
new g_iMenuData[33][4],
    Float:g_fBuyTimeStart[33],
    bool:g_bBoughtPrimary[33],
    bool:g_bBoughtSecondary[33],
    WPN_MAXIDS[33]
 
// Define
#define WPN_STARTID g_iMenuData[id][0]
#define WPN_SELECTION (g_iMenuData[id][0]+key)
#define WPN_AUTO_ON g_iMenuData[id][1]
#define WPN_AUTO_PRI g_iMenuData[id][2]
#define WPN_AUTO_SEC g_iMenuData[id][3]
 
// Cvars
new g_pCvarBuyTime,
    g_pCvarHeGrenade,
    g_pCvarSmokeGrenade,
    g_pCvarFlashGrenade,
    g_pCvarBlockWeapLowLevel
 
public plugin_natives()
{
    register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
    register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
    register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
}
 
public plugin_precache()
{
    // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
    g_szPrimaryWeapons = ArrayCreate(32, 1)
    g_szSecondaryWeapons = ArrayCreate(32, 1)
   
    // Load from external file
    amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
   
    // If we couldn't load from file, use and save default ones
   
    new iIndex
   
    if (ArraySize(g_szPrimaryWeapons) == 0)
    {
        for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
            ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
       
        // If not found .ini File Create it and save default values in it
        amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    }
   
    if (ArraySize(g_szSecondaryWeapons) == 0)
    {
        for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
            ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
       
        // If not found .ini File Create it and save default values in it
        amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    }
}
 
public plugin_init()
{
    register_plugin("[ZE] Levels Weapons Menu", "1.1", "Raheem")
   
    // Commands
    register_clcmd("guns", "Cmd_Buy")
    register_clcmd("say /enable", "Cmd_Enable")
    register_clcmd("say_team /enable", "Cmd_Enable")
   
    // Cvars
    g_pCvarBuyTime = register_cvar("ze_buy_time", "60")
    g_pCvarHeGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
    g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "0")
    g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "0")
    g_pCvarBlockWeapLowLevel = register_cvar("ze_block_weapons_lowlvl", "1")
   
    // Menus
    register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
    register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
   
    // Hams
    RegisterHam(Ham_Touch, "weaponbox", "Fw_TouchWeapon_Pre", 0)
    RegisterHam(Ham_Touch, "armoury_entity", "Fw_TouchWeapon_Pre", 0)
}
 
public client_disconnected(id)
{
    WPN_AUTO_ON = 0
    WPN_STARTID = 0
}
 
public Cmd_Enable(id)
{
    if (WPN_AUTO_ON)
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
        WPN_AUTO_ON = 0
    }
}
 
public Cmd_Buy(id)
{
    // Player Zombie
    if (ze_is_user_zombie(id))
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
        return
    }
   
    // Player Dead
    if (!is_user_alive(id))
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
        return
    }
   
    // Already bought
    if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
    }
   
    Show_Available_Buy_Menus(id)
}
 
public ze_user_humanized(id)
{
    // Static Values
    switch (ze_get_user_level(id))
    {
        case 0: WPN_MAXIDS[id] = 2
        case 1: WPN_MAXIDS[id] = 3
        case 2: WPN_MAXIDS[id] = 4
        case 3: WPN_MAXIDS[id] = 5
        case 4: WPN_MAXIDS[id] = 6
        case 5: WPN_MAXIDS[id] = 7
        case 6: WPN_MAXIDS[id] = 8
        case 7: WPN_MAXIDS[id] = 9
        case 8: WPN_MAXIDS[id] = 10
        case 9: WPN_MAXIDS[id] = 11
        case 10: WPN_MAXIDS[id] = 12
        case 11: WPN_MAXIDS[id] = 13
        case 12..14: WPN_MAXIDS[id] = 14
        case 15..19: WPN_MAXIDS[id] = 15 // Golden m3
        case 20..24: WPN_MAXIDS[id] = 16 // Golden MP5
        case 25..29: WPN_MAXIDS[id] = 17 // Golden M4A1
        case 30..34: WPN_MAXIDS[id] = 18     // Golden AK47
        case 35..39: WPN_MAXIDS[id] = 19     // Golden AK47
        case 40: WPN_MAXIDS[id] = 20     // Golden AK47
    }
   
    if (ze_get_user_level(id) > 40)
    {
        WPN_MAXIDS[id] = 20
    }
 
    // Buyzone time starts when player is set to human
    g_fBuyTimeStart[id] = get_gametime()
   
    g_bBoughtPrimary[id] = false
    g_bBoughtSecondary[id] = false
   
    // Player dead or zombie
    if (!is_user_alive(id) || ze_is_user_zombie(id))
        return
   
    if (WPN_AUTO_ON)
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
        Buy_Primary_Weapon(id, WPN_AUTO_PRI)
        Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
    }
   
    // Open available buy menus
    Show_Available_Buy_Menus(id)
   
    // Give HE Grenade
    if (get_pcvar_num(g_pCvarHeGrenade) != 0)
        rg_give_item(id, "weapon_hegrenade")
   
    // Give Smoke Grenade
    if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
        rg_give_item(id, "weapon_smokegrenade")
   
    // Give Flashbang Grenade
    if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
        rg_give_item(id, "weapon_flashbang")
}
 
public Show_Available_Buy_Menus(id)
{
    // Already Bought
    if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
        return
   
    // Here we use if and else if so we make sure that Primary weapon come first then secondary
    if (!g_bBoughtPrimary[id])
    {
        // Primary     
        Show_Menu_Buy_Primary(id)
    }
    else if (!g_bBoughtSecondary[id])
    {
        // Secondary
        Show_Menu_Buy_Secondary(id)
    }
}
 
public Show_Menu_Buy_Primary(id)
{
    new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
   
    if (iMenuTime <= 0)
    {
        ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
        return
    }
   
    static szMenu[300], szWeaponName[32]
    new iLen, iIndex, iMaxLoops = min(WPN_STARTID+7, WPN_MAXIDS[id])
   
    // Title
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L \w[\r%d\w-\r%d\w]^n^n", id, "MENU_PRIMARY_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS[id]))
   
    // 1-7. Weapon List
    for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
    {
        if (ze_get_user_level(id) == 0 && iIndex >= 2||
        ze_get_user_level(id) == 1 && iIndex >= 3 ||
        ze_get_user_level(id) == 2 && iIndex >= 4 ||
        ze_get_user_level(id) == 3 && iIndex >= 5 ||
        ze_get_user_level(id) == 4 && iIndex >= 6 ||
        ze_get_user_level(id) == 5 && iIndex >= 7 ||
        ze_get_user_level(id) == 6 && iIndex >= 8 ||
        ze_get_user_level(id) == 7 && iIndex >= 9 ||
        ze_get_user_level(id) == 8 && iIndex >= 10 ||
        ze_get_user_level(id) == 9 && iIndex >= 11 ||
        ze_get_user_level(id) == 10 && iIndex >= 12 ||
        ze_get_user_level(id) == 11 && iIndex >= 13 ||
        ze_get_user_level(id) == 12 && iIndex >= 14)
        {
            break
        }
       
        /*
        *  Note that WPN_MAXIDS start from 1 but iIndex start from 0.
        */
       
        // Golden M3
        if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
                break;
            }
        }
       
        // Golden MP5
        if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
                break;
            }
        }
       
        // Golden M4A1
        if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
                break;
            }
        }
       
        // Golden AK47
        if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 35)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }
           
            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Thantos-5")
                break;
            }
        }

        // Golden AK47
        if (ze_get_user_level(id) >= 35 && ze_get_user_level(id) < 40)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }

            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Thantos-5")
            }
           
            if (iIndex == 18)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "balrog")
                break;
            }
        }

        // Golden AK47
        if (ze_get_user_level(id) >= 40)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }

            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Thantos-5")
            }

            if (iIndex == 18)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "balrog")
            }
           
            if (iIndex == 19)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "watergun")
                break;
            }
        }
       
        // Must check if iIndex < 14 means max is AK47
        if (iIndex < 14)
        {
            ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
            iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
        }
    }
   
    if (iIndex < 7)
    {
        ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
   
    if (ze_get_user_level(id) == 5)
    {
        ArrayGetString(g_szPrimaryWeapons, 7, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 6)
    {
        ArrayGetString(g_szPrimaryWeapons, 8, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 7)
    {
        ArrayGetString(g_szPrimaryWeapons, 9, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 8)
    {
        ArrayGetString(g_szPrimaryWeapons, 10, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 9)
    {
        ArrayGetString(g_szPrimaryWeapons, 11, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 10)
    {
        ArrayGetString(g_szPrimaryWeapons, 12, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 11)
    {
        ArrayGetString(g_szPrimaryWeapons, 13, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) >= 12 && ze_get_user_level(id) < 15) // Golden M3
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yFrost M4A1^n")
    }
    else if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20) // Golden MP5
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \yGolden MP5^n")
    }
    else if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25) // Golden M4A1
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 25 Unlock\w: \yGolden M4A1^n")
    }
    else if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30) // Thantos-5
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yThantos-5^n")
    }
    else if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 35) // Thantos-5
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 35 Unlock\w: \ybalrog^n")
    }
    else if (ze_get_user_level(id) >= 35 && ze_get_user_level(id) < 40) // Thantos-5
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 40 Unlock\w: \ywatergun^n")
    }
 
    // 8. Auto Select
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w8.\y %L \w[\r%L\w]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
   
    // 9. Next/Back - 0. Exit
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\y9.\r %L \w/ \r%L^n^n\w0.\y %L", id, "NEXT", id, "BACK", id, "EXIT")
   
    // Fix for AMXX custom menus
    set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
}
 
public Show_Menu_Buy_Secondary(id)
{
    new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
   
    if (iMenuTime <= 0)
    {
        ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
        return
    }
   
    static szMenu[250], szWeaponName[32]
    new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
   
    // Title
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
   
    // 1-6. Weapon List
    for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
    {
        if (ze_get_user_level(id) == 0 && iIndex >= 2 ||
        ze_get_user_level(id) == 1 && iIndex >= 3 ||
        ze_get_user_level(id) == 2 && iIndex >= 4 ||
        ze_get_user_level(id) == 3 && iIndex >= 5 ||
        ze_get_user_level(id) == 4 && iIndex >= 6)
        {
            break
        }
       
        /*
        *  Note that WPN_MAXIDS start from 1 but iIndex start from 0.
        */
       
        // Golden M3
        if (ze_get_user_level(id) >= 15)
        {
            if (iIndex == 6)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Dual Infinity")
                break;
            }
        }

        ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w%d.\y %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
    }
   
    if (iIndex < ArraySize(g_szSecondaryWeapons))
    {
        ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r Next Level Unlock\w: \y%s", szWeaponNames[get_weaponid(szWeaponName)])
    }
       else if (ze_get_user_level(id) >= 1 && ze_get_user_level(id) < 15) // Golden M3
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yDual Infinity^n")
    }

    // 8. Auto Select
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w8.\y %L \w[\r%L\w]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
   
    // 0. Exit
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\y %L", id, "EXIT")
   
    // Fix for AMXX custom menus
    set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
}
 
public Menu_Buy_Primary(id, key)
{
    // Player dead or zombie or already bought primary
    if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
        return PLUGIN_HANDLED
   
    // Special keys / weapon list exceeded
    if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS[id])
    {
        switch (key)
        {
            case MENU_KEY_AUTOSELECT: // toggle auto select
            {
                WPN_AUTO_ON = 1 - WPN_AUTO_ON
            }
            case MENU_KEY_NEXT: // next/back
            {
                if (WPN_STARTID+7 < WPN_MAXIDS[id])
                    WPN_STARTID += 7
                else
                    WPN_STARTID = 0
            }
            case MENU_KEY_EXIT: // exit
            {
                return PLUGIN_HANDLED
            }
        }
       
        // Show buy menu again
        Show_Menu_Buy_Primary(id)
        return PLUGIN_HANDLED
    }
   
    // Store selected weapon id
    WPN_AUTO_PRI = WPN_SELECTION
   
    // Buy primary weapon
    Buy_Primary_Weapon(id, WPN_AUTO_PRI)
   
    // Show Secondary Weapons
    Show_Available_Buy_Menus(id)
   
    return PLUGIN_HANDLED
}
 
public Buy_Primary_Weapon(id, selection)
{
    if (selection == 14) // Frost M4A1
    {
        give_frost_m4a1(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 15) // Golden MP5
    {
        give_golden_mp5(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 16) // Golden M4A1
    {
        give_golden_m4a1(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 17) // Thantos-5
    {
        give_thantos5(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 18) // Thantos-5
    {
        give_balrog(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 19) // Thantos-5
    {
        give_watergun(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
   
    static szWeaponName[32]
    ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    new iWeaponId = get_weaponid(szWeaponName)
   
    // Strip and Give Full Weapon
    rg_give_item(id, szWeaponName, GT_REPLACE)
    rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
   
    // Primary bought
    g_bBoughtPrimary[id] = true
    return true;
}
 
public Menu_Buy_Secondary(id, key)
{
    // Player dead or zombie or already bought secondary
    if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
        return PLUGIN_HANDLED
   
    // Special keys / weapon list exceeded
    if (key >= ArraySize(g_szSecondaryWeapons))
    {
        // Toggle autoselect
        if (key == MENU_KEY_AUTOSELECT)
            WPN_AUTO_ON = 1 - WPN_AUTO_ON
       
        // Reshow menu unless user exited
        if (key != MENU_KEY_EXIT)
            Show_Menu_Buy_Secondary(id)
       
        return PLUGIN_HANDLED
    }
   
    // Store selected weapon id
    WPN_AUTO_SEC = key
   
    // Buy secondary weapon
    Buy_Secondary_Weapon(id, key)
   
    return PLUGIN_HANDLED
}
 
public Buy_Secondary_Weapon(id, selection)
    {
      if (selection == 6) // Frost M4A1
    {
        give_dual_infinity(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
 
    static szWeaponName[32]
    ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    new iWeaponId = get_weaponid(szWeaponName)
   
    // Strip and Give Full Weapon
    rg_give_item(id, szWeaponName, GT_REPLACE)
    rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    ze_giveminigun(id)
 
   
    // Secondary bought
    g_bBoughtSecondary[id] = true
}
 
public Fw_TouchWeapon_Pre(iEnt, id)
{
    if (get_pcvar_num(g_pCvarBlockWeapLowLevel) == 0)
        return HAM_IGNORED;
   
    // Not alive or Not Valid Weapon?
    if(!is_user_alive(id) || !pev_valid(iEnt))
        return HAM_IGNORED;
   
    // Get Weapon Model
    new szWeapModel[32]
    pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
   
    // Remove "models/w_" and ".mdl"
    copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
   
    // Set for mp5 to be same as "weapon_mp5navy"
    if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
        szWeapModel = "mp5navy"
   
    // Add "weapon_" to all model names
    static szWeaponEnt[32]
    formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)
 
    // Get it's index in Weapon Array
    new iIndex, i
   
    // I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
    for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
    {
        new szPrimaryWeapon[32]
        ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
       
        if (equali(szWeaponEnt, szPrimaryWeapon))
            iIndex = i
    }
   
    if (ze_get_user_level(id) == 0 && iIndex > 1)
    {
        return HAM_SUPERCEDE;
    }
   
    for (i = 1; i <= 11; i++)
    {
        if ((ze_get_user_level(id) == i) && iIndex > i+1)
        {
            return HAM_SUPERCEDE;
        }
    }
   
    return HAM_IGNORED;
}
 
// Natives
public native_ze_show_weapon_menu(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return false
    }
   
    Cmd_Buy(id)
    return true
}
 
public native_ze_is_auto_buy_enabled(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return -1;
    }
   
    return WPN_AUTO_ON;
}
 
public native_ze_disable_auto_buy(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return false
    }
   
    WPN_AUTO_ON = 0;
    return true
}
Image

User avatar
Luxurious
Mod Tester
Mod Tester
Egypt
Posts: 177
Joined: 6 years ago
Location: Egypt
Contact:

#3

Post by Luxurious » 5 years ago

sPe3doN wrote: 5 years ago here i didn't test it:

Code: Select all

#include <zombie_escape>
#include <ze_levels>
 
native give_golden_m3(id);
native give_golden_mp5(id);
native give_golden_m4a1(id);
native ze_giveminigun(id);
native give_thantos5(id); 
native give_frost_m4a1(id);
native give_balrog(id);
native give_watergun(id);
native give_dual_infinity(id);

 
// Setting File
new const ZE_SETTING_RESOURCES[] = "zombie_escape.ini"
 
// Keys
const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
const OFFSET_CSMENUCODE = 205
 
// Primary Weapons Entities [Default Values]
new const szPrimaryWeaponEnt[][] =
{
    "weapon_xm1014",  // Level 0
    "weapon_ump45",   // Level 0
    "weapon_m3",      // Level 1
    "weapon_mp5navy", // Level 2
    "weapon_p90",     // Level 3
    "weapon_galil",   // Level 4
    "weapon_famas",   // Level 5
    "weapon_sg550",   // Level 6
    "weapon_g3sg1",   // Level 7
    "weapon_m249",    // Level 8
    "weapon_sg552",   // Level 9
    "weapon_aug",     // Level 10
    "weapon_m4a1",    // Level 11
    "weapon_ak47"     // Level 12
}
 
// Secondary Weapons Entities [Default Values]
new const szSecondaryWeaponEnt[][]=
{
    "weapon_usp",         // Level 0
    "weapon_p228",        // Level 0
    "weapon_glock18",     // Level 1
    "weapon_fiveseven",   // Level 2
    "weapon_deagle",      // Level 3
    "weapon_elite"        // Level 4
}
 
// Primary and Secondary Weapons Names [Default Values]
new const szWeaponNames[][] =
{
    "",
    "P228",
    "",
    "Scout",
    "HE Grenade",
    "XM1014",
    "",
    "MAC-10",
    "AUG",
    "Smoke Grenade",
    "Dual Elite",
    "Five Seven",
    "UMP 45",
    "SG-550",
    "Galil",
    "Famas",
    "USP",
    "Glock",
    "AWP",
    "MP5",
    "M249",
    "M3",
    "M4A1",
    "TMP",
    "G3SG1",
    "Flashbang",
    "Desert Eagle",
    "SG-552",
    "AK-47",
    "",
    "P90"
}
 
// Max Back Clip Ammo (Change it From here if you need)
new const szMaxBPAmmo[] =
{
    -1,
    999,
    -1,
    999,
    1,
    999,
    1,
    999,
    999,
    1,
    999,
    999,
    2090,
    2090,
    2090,
    2090,
    2090,
    2090,
    2090,
    2090,
    2090,
    32,
    2090,
    2090,
    2090,
    2,
    2090,
    2090,
    2090,
    -1,
    2900
}
 
// Menu selections
const MENU_KEY_AUTOSELECT = 7
const MENU_KEY_BACK = 7
const MENU_KEY_NEXT = 8
const MENU_KEY_EXIT = 9
 
// Variables
new Array:g_szPrimaryWeapons, Array:g_szSecondaryWeapons
 
new g_iMenuData[33][4],
    Float:g_fBuyTimeStart[33],
    bool:g_bBoughtPrimary[33],
    bool:g_bBoughtSecondary[33],
    WPN_MAXIDS[33]
 
// Define
#define WPN_STARTID g_iMenuData[id][0]
#define WPN_SELECTION (g_iMenuData[id][0]+key)
#define WPN_AUTO_ON g_iMenuData[id][1]
#define WPN_AUTO_PRI g_iMenuData[id][2]
#define WPN_AUTO_SEC g_iMenuData[id][3]
 
// Cvars
new g_pCvarBuyTime,
    g_pCvarHeGrenade,
    g_pCvarSmokeGrenade,
    g_pCvarFlashGrenade,
    g_pCvarBlockWeapLowLevel
 
public plugin_natives()
{
    register_native("ze_show_weapon_menu", "native_ze_show_weapon_menu", 1)
    register_native("ze_is_auto_buy_enabled", "native_ze_is_auto_buy_enabled", 1)
    register_native("ze_disable_auto_buy", "native_ze_disable_auto_buy", 1)
}
 
public plugin_precache()
{
    // Initialize arrays (32 is the max length of Weapon Entity like: weapon_ak47)
    g_szPrimaryWeapons = ArrayCreate(32, 1)
    g_szSecondaryWeapons = ArrayCreate(32, 1)
   
    // Load from external file
    amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    amx_load_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
   
    // If we couldn't load from file, use and save default ones
   
    new iIndex
   
    if (ArraySize(g_szPrimaryWeapons) == 0)
    {
        for (iIndex = 0; iIndex < sizeof szPrimaryWeaponEnt; iIndex++)
            ArrayPushString(g_szPrimaryWeapons, szPrimaryWeaponEnt[iIndex])
       
        // If not found .ini File Create it and save default values in it
        amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "PRIMARY", g_szPrimaryWeapons)
    }
   
    if (ArraySize(g_szSecondaryWeapons) == 0)
    {
        for (iIndex = 0; iIndex < sizeof szSecondaryWeaponEnt; iIndex++)
            ArrayPushString(g_szSecondaryWeapons, szSecondaryWeaponEnt[iIndex])
       
        // If not found .ini File Create it and save default values in it
        amx_save_setting_string_arr(ZE_SETTING_RESOURCES, "Weapons Menu", "SECONDARY", g_szSecondaryWeapons)
    }
}
 
public plugin_init()
{
    register_plugin("[ZE] Levels Weapons Menu", "1.1", "Raheem")
   
    // Commands
    register_clcmd("guns", "Cmd_Buy")
    register_clcmd("say /enable", "Cmd_Enable")
    register_clcmd("say_team /enable", "Cmd_Enable")
   
    // Cvars
    g_pCvarBuyTime = register_cvar("ze_buy_time", "60")
    g_pCvarHeGrenade = register_cvar("ze_give_HE_nade", "1") // 0 Nothing || 1 Give HE
    g_pCvarSmokeGrenade = register_cvar("ze_give_SM_nade", "0")
    g_pCvarFlashGrenade = register_cvar("ze_give_FB_nade", "0")
    g_pCvarBlockWeapLowLevel = register_cvar("ze_block_weapons_lowlvl", "1")
   
    // Menus
    register_menu("Primary Weapons", KEYSMENU, "Menu_Buy_Primary")
    register_menu("Secondary Weapons", KEYSMENU, "Menu_Buy_Secondary")
   
    // Hams
    RegisterHam(Ham_Touch, "weaponbox", "Fw_TouchWeapon_Pre", 0)
    RegisterHam(Ham_Touch, "armoury_entity", "Fw_TouchWeapon_Pre", 0)
}
 
public client_disconnected(id)
{
    WPN_AUTO_ON = 0
    WPN_STARTID = 0
}
 
public Cmd_Enable(id)
{
    if (WPN_AUTO_ON)
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "BUY_ENABLED")
        WPN_AUTO_ON = 0
    }
}
 
public Cmd_Buy(id)
{
    // Player Zombie
    if (ze_is_user_zombie(id))
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "NO_BUY_ZOMBIE")
        return
    }
   
    // Player Dead
    if (!is_user_alive(id))
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "DEAD_CANT_BUY_WEAPON")
        return
    }
   
    // Already bought
    if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "ALREADY_BOUGHT")
    }
   
    Show_Available_Buy_Menus(id)
}
 
public ze_user_humanized(id)
{
    // Static Values
    switch (ze_get_user_level(id))
    {
        case 0: WPN_MAXIDS[id] = 2
        case 1: WPN_MAXIDS[id] = 3
        case 2: WPN_MAXIDS[id] = 4
        case 3: WPN_MAXIDS[id] = 5
        case 4: WPN_MAXIDS[id] = 6
        case 5: WPN_MAXIDS[id] = 7
        case 6: WPN_MAXIDS[id] = 8
        case 7: WPN_MAXIDS[id] = 9
        case 8: WPN_MAXIDS[id] = 10
        case 9: WPN_MAXIDS[id] = 11
        case 10: WPN_MAXIDS[id] = 12
        case 11: WPN_MAXIDS[id] = 13
        case 12..14: WPN_MAXIDS[id] = 14
        case 15..19: WPN_MAXIDS[id] = 15 // Golden m3
        case 20..24: WPN_MAXIDS[id] = 16 // Golden MP5
        case 25..29: WPN_MAXIDS[id] = 17 // Golden M4A1
        case 30..34: WPN_MAXIDS[id] = 18     // Golden AK47
        case 35..39: WPN_MAXIDS[id] = 19     // Golden AK47
        case 40: WPN_MAXIDS[id] = 20     // Golden AK47
    }
   
    if (ze_get_user_level(id) > 40)
    {
        WPN_MAXIDS[id] = 20
    }
 
    // Buyzone time starts when player is set to human
    g_fBuyTimeStart[id] = get_gametime()
   
    g_bBoughtPrimary[id] = false
    g_bBoughtSecondary[id] = false
   
    // Player dead or zombie
    if (!is_user_alive(id) || ze_is_user_zombie(id))
        return
   
    if (WPN_AUTO_ON)
    {
        ze_colored_print(id, "%L", LANG_PLAYER, "RE_ENABLE_MENU")
        Buy_Primary_Weapon(id, WPN_AUTO_PRI)
        Buy_Secondary_Weapon(id, WPN_AUTO_SEC)
    }
   
    // Open available buy menus
    Show_Available_Buy_Menus(id)
   
    // Give HE Grenade
    if (get_pcvar_num(g_pCvarHeGrenade) != 0)
        rg_give_item(id, "weapon_hegrenade")
   
    // Give Smoke Grenade
    if (get_pcvar_num(g_pCvarSmokeGrenade) != 0)
        rg_give_item(id, "weapon_smokegrenade")
   
    // Give Flashbang Grenade
    if (get_pcvar_num(g_pCvarFlashGrenade) != 0)
        rg_give_item(id, "weapon_flashbang")
}
 
public Show_Available_Buy_Menus(id)
{
    // Already Bought
    if (g_bBoughtPrimary[id] && g_bBoughtSecondary[id])
        return
   
    // Here we use if and else if so we make sure that Primary weapon come first then secondary
    if (!g_bBoughtPrimary[id])
    {
        // Primary     
        Show_Menu_Buy_Primary(id)
    }
    else if (!g_bBoughtSecondary[id])
    {
        // Secondary
        Show_Menu_Buy_Secondary(id)
    }
}
 
public Show_Menu_Buy_Primary(id)
{
    new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
   
    if (iMenuTime <= 0)
    {
        ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
        return
    }
   
    static szMenu[300], szWeaponName[32]
    new iLen, iIndex, iMaxLoops = min(WPN_STARTID+7, WPN_MAXIDS[id])
   
    // Title
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L \w[\r%d\w-\r%d\w]^n^n", id, "MENU_PRIMARY_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS[id]))
   
    // 1-7. Weapon List
    for (iIndex = WPN_STARTID; iIndex < iMaxLoops; iIndex++)
    {
        if (ze_get_user_level(id) == 0 && iIndex >= 2||
        ze_get_user_level(id) == 1 && iIndex >= 3 ||
        ze_get_user_level(id) == 2 && iIndex >= 4 ||
        ze_get_user_level(id) == 3 && iIndex >= 5 ||
        ze_get_user_level(id) == 4 && iIndex >= 6 ||
        ze_get_user_level(id) == 5 && iIndex >= 7 ||
        ze_get_user_level(id) == 6 && iIndex >= 8 ||
        ze_get_user_level(id) == 7 && iIndex >= 9 ||
        ze_get_user_level(id) == 8 && iIndex >= 10 ||
        ze_get_user_level(id) == 9 && iIndex >= 11 ||
        ze_get_user_level(id) == 10 && iIndex >= 12 ||
        ze_get_user_level(id) == 11 && iIndex >= 13 ||
        ze_get_user_level(id) == 12 && iIndex >= 14)
        {
            break
        }
       
        /*
        *  Note that WPN_MAXIDS start from 1 but iIndex start from 0.
        */
       
        // Golden M3
        if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
                break;
            }
        }
       
        // Golden MP5
        if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
                break;
            }
        }
       
        // Golden M4A1
        if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
                break;
            }
        }
       
        // Golden AK47
        if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 35)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }
           
            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Thantos-5")
                break;
            }
        }

        // Golden AK47
        if (ze_get_user_level(id) >= 35 && ze_get_user_level(id) < 40)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }

            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Thantos-5")
            }
           
            if (iIndex == 18)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "balrog")
                break;
            }
        }

        // Golden AK47
        if (ze_get_user_level(id) >= 40)
        {
            if (iIndex == 14)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Frost M4A1")
            }
           
            if (iIndex == 15)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden MP5")
            }
           
            if (iIndex == 16)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Golden M4A1")
            }

            if (iIndex == 17)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Thantos-5")
            }

            if (iIndex == 18)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "balrog")
            }
           
            if (iIndex == 19)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "watergun")
                break;
            }
        }
       
        // Must check if iIndex < 14 means max is AK47
        if (iIndex < 14)
        {
            ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
            iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, szWeaponNames[get_weaponid(szWeaponName)])
        }
    }
   
    if (iIndex < 7)
    {
        ArrayGetString(g_szPrimaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
   
    if (ze_get_user_level(id) == 5)
    {
        ArrayGetString(g_szPrimaryWeapons, 7, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 6)
    {
        ArrayGetString(g_szPrimaryWeapons, 8, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 7)
    {
        ArrayGetString(g_szPrimaryWeapons, 9, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 8)
    {
        ArrayGetString(g_szPrimaryWeapons, 10, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 9)
    {
        ArrayGetString(g_szPrimaryWeapons, 11, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 10)
    {
        ArrayGetString(g_szPrimaryWeapons, 12, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) == 11)
    {
        ArrayGetString(g_szPrimaryWeapons, 13, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Next Level Unlock\w: \y%s^n", szWeaponNames[get_weaponid(szWeaponName)])
    }
    else if (ze_get_user_level(id) >= 12 && ze_get_user_level(id) < 15) // Golden M3
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yFrost M4A1^n")
    }
    else if (ze_get_user_level(id) >= 15 && ze_get_user_level(id) < 20) // Golden MP5
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 20 Unlock\w: \yGolden MP5^n")
    }
    else if (ze_get_user_level(id) >= 20 && ze_get_user_level(id) < 25) // Golden M4A1
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 25 Unlock\w: \yGolden M4A1^n")
    }
    else if (ze_get_user_level(id) >= 25 && ze_get_user_level(id) < 30) // Thantos-5
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 30 Unlock\w: \yThantos-5^n")
    }
    else if (ze_get_user_level(id) >= 30 && ze_get_user_level(id) < 35) // Thantos-5
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 35 Unlock\w: \ybalrog^n")
    }
    else if (ze_get_user_level(id) >= 35 && ze_get_user_level(id) < 40) // Thantos-5
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 40 Unlock\w: \ywatergun^n")
    }
 
    // 8. Auto Select
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w8.\y %L \w[\r%L\w]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
   
    // 9. Next/Back - 0. Exit
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\y9.\r %L \w/ \r%L^n^n\w0.\y %L", id, "NEXT", id, "BACK", id, "EXIT")
   
    // Fix for AMXX custom menus
    set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    show_menu(id, KEYSMENU, szMenu, iMenuTime, "Primary Weapons")
}
 
public Show_Menu_Buy_Secondary(id)
{
    new iMenuTime = floatround(g_fBuyTimeStart[id] + get_pcvar_float(g_pCvarBuyTime) - get_gametime())
   
    if (iMenuTime <= 0)
    {
        ze_colored_print(id, "%L", id, "BUY_MENU_TIME_EXPIRED")
        return
    }
   
    static szMenu[250], szWeaponName[32]
    new iLen, iIndex, iMaxLoops = ArraySize(g_szSecondaryWeapons)
   
    // Title
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\y%L^n", id, "MENU_SECONDARY_TITLE")
   
    // 1-6. Weapon List
    for (iIndex = 0; iIndex < iMaxLoops; iIndex++)
    {
        if (ze_get_user_level(id) == 0 && iIndex >= 2 ||
        ze_get_user_level(id) == 1 && iIndex >= 3 ||
        ze_get_user_level(id) == 2 && iIndex >= 4 ||
        ze_get_user_level(id) == 3 && iIndex >= 5 ||
        ze_get_user_level(id) == 4 && iIndex >= 6)
        {
            break
        }
       
        /*
        *  Note that WPN_MAXIDS start from 1 but iIndex start from 0.
        */
       
        // Golden M3
        if (ze_get_user_level(id) >= 15)
        {
            if (iIndex == 6)
            {
                iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\w%d.\y %s^n", iIndex-WPN_STARTID+1, "Dual Infinity")
                break;
            }
        }

        ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\w%d.\y %s", iIndex+1, szWeaponNames[get_weaponid(szWeaponName)])
    }
   
    if (iIndex < ArraySize(g_szSecondaryWeapons))
    {
        ArrayGetString(g_szSecondaryWeapons, iIndex, szWeaponName, charsmax(szWeaponName))
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r Next Level Unlock\w: \y%s", szWeaponNames[get_weaponid(szWeaponName)])
    }
       else if (ze_get_user_level(id) >= 1 && ze_get_user_level(id) < 15) // Golden M3
    {
        iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r Level 15 Unlock\w: \yDual Infinity^n")
    }

    // 8. Auto Select
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w8.\y %L \w[\r%L\w]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "SAVE_YES" : "SAVE_NO")
   
    // 0. Exit
    iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\w0.\y %L", id, "EXIT")
   
    // Fix for AMXX custom menus
    set_pdata_int(id, OFFSET_CSMENUCODE, 0)
    show_menu(id, KEYSMENU, szMenu, iMenuTime, "Secondary Weapons")
}
 
public Menu_Buy_Primary(id, key)
{
    // Player dead or zombie or already bought primary
    if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtPrimary[id])
        return PLUGIN_HANDLED
   
    // Special keys / weapon list exceeded
    if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS[id])
    {
        switch (key)
        {
            case MENU_KEY_AUTOSELECT: // toggle auto select
            {
                WPN_AUTO_ON = 1 - WPN_AUTO_ON
            }
            case MENU_KEY_NEXT: // next/back
            {
                if (WPN_STARTID+7 < WPN_MAXIDS[id])
                    WPN_STARTID += 7
                else
                    WPN_STARTID = 0
            }
            case MENU_KEY_EXIT: // exit
            {
                return PLUGIN_HANDLED
            }
        }
       
        // Show buy menu again
        Show_Menu_Buy_Primary(id)
        return PLUGIN_HANDLED
    }
   
    // Store selected weapon id
    WPN_AUTO_PRI = WPN_SELECTION
   
    // Buy primary weapon
    Buy_Primary_Weapon(id, WPN_AUTO_PRI)
   
    // Show Secondary Weapons
    Show_Available_Buy_Menus(id)
   
    return PLUGIN_HANDLED
}
 
public Buy_Primary_Weapon(id, selection)
{
    if (selection == 14) // Frost M4A1
    {
        give_frost_m4a1(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 15) // Golden MP5
    {
        give_golden_mp5(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 16) // Golden M4A1
    {
        give_golden_m4a1(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 17) // Thantos-5
    {
        give_thantos5(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 18) // Thantos-5
    {
        give_balrog(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
    else if (selection == 19) // Thantos-5
    {
        give_watergun(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
   
    static szWeaponName[32]
    ArrayGetString(g_szPrimaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    new iWeaponId = get_weaponid(szWeaponName)
   
    // Strip and Give Full Weapon
    rg_give_item(id, szWeaponName, GT_REPLACE)
    rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
   
    // Primary bought
    g_bBoughtPrimary[id] = true
    return true;
}
 
public Menu_Buy_Secondary(id, key)
{
    // Player dead or zombie or already bought secondary
    if (!is_user_alive(id) || ze_is_user_zombie(id) || g_bBoughtSecondary[id])
        return PLUGIN_HANDLED
   
    // Special keys / weapon list exceeded
    if (key >= ArraySize(g_szSecondaryWeapons))
    {
        // Toggle autoselect
        if (key == MENU_KEY_AUTOSELECT)
            WPN_AUTO_ON = 1 - WPN_AUTO_ON
       
        // Reshow menu unless user exited
        if (key != MENU_KEY_EXIT)
            Show_Menu_Buy_Secondary(id)
       
        return PLUGIN_HANDLED
    }
   
    // Store selected weapon id
    WPN_AUTO_SEC = key
   
    // Buy secondary weapon
    Buy_Secondary_Weapon(id, key)
   
    return PLUGIN_HANDLED
}
 
public Buy_Secondary_Weapon(id, selection)
    {
      if (selection == 6) // Frost M4A1
    {
        give_dual_infinity(id)
        g_bBoughtPrimary[id] = true
        return true;
    }
 
    static szWeaponName[32]
    ArrayGetString(g_szSecondaryWeapons, selection, szWeaponName, charsmax(szWeaponName))
    new iWeaponId = get_weaponid(szWeaponName)
   
    // Strip and Give Full Weapon
    rg_give_item(id, szWeaponName, GT_REPLACE)
    rg_set_user_bpammo(id, WeaponIdType:iWeaponId, szMaxBPAmmo[iWeaponId])
    ze_giveminigun(id)
 
   
    // Secondary bought
    g_bBoughtSecondary[id] = true
}
 
public Fw_TouchWeapon_Pre(iEnt, id)
{
    if (get_pcvar_num(g_pCvarBlockWeapLowLevel) == 0)
        return HAM_IGNORED;
   
    // Not alive or Not Valid Weapon?
    if(!is_user_alive(id) || !pev_valid(iEnt))
        return HAM_IGNORED;
   
    // Get Weapon Model
    new szWeapModel[32]
    pev(iEnt, pev_model, szWeapModel, charsmax(szWeapModel))
   
    // Remove "models/w_" and ".mdl"
    copyc(szWeapModel, charsmax(szWeapModel), szWeapModel[contain(szWeapModel, "_" ) + 1], '.')
   
    // Set for mp5 to be same as "weapon_mp5navy"
    if(szWeapModel[1] == 'p' && szWeapModel[2] == '5')
        szWeapModel = "mp5navy"
   
    // Add "weapon_" to all model names
    static szWeaponEnt[32]
    formatex(szWeaponEnt, charsmax(szWeaponEnt), "weapon_%s", szWeapModel)
 
    // Get it's index in Weapon Array
    new iIndex, i
   
    // I won't explain the blew code if you need to understand ask me in Escapers-Zone.XYZ
    for (i = 0; i < ArraySize(g_szPrimaryWeapons); i++)
    {
        new szPrimaryWeapon[32]
        ArrayGetString(g_szPrimaryWeapons, i, szPrimaryWeapon, charsmax(szPrimaryWeapon))
       
        if (equali(szWeaponEnt, szPrimaryWeapon))
            iIndex = i
    }
   
    if (ze_get_user_level(id) == 0 && iIndex > 1)
    {
        return HAM_SUPERCEDE;
    }
   
    for (i = 1; i <= 11; i++)
    {
        if ((ze_get_user_level(id) == i) && iIndex > i+1)
        {
            return HAM_SUPERCEDE;
        }
    }
   
    return HAM_IGNORED;
}
 
// Natives
public native_ze_show_weapon_menu(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return false
    }
   
    Cmd_Buy(id)
    return true
}
 
public native_ze_is_auto_buy_enabled(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return -1;
    }
   
    return WPN_AUTO_ON;
}
 
public native_ze_disable_auto_buy(id)
{
    if (!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d)", id)
        return false
    }
   
    WPN_AUTO_ON = 0;
    return true
}

Code: Select all

// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v1.8.3\scripting\ze_weapon_menu1.sma(803) : warning 217: loose indentation
// D:\Games\Funny\Rehlds_publish_3.4.0.641_artifacts\old\Addons\Compiler v1.8.3\scripting\ze_weapon_menu1.sma(815) : warning 209: function "Buy_Secondary_Weapon" should return a value
DRK Zombie-Escape V1.6
IP : 81.169.153.129:27015

User avatar
Luxurious
Mod Tester
Mod Tester
Egypt
Posts: 177
Joined: 6 years ago
Location: Egypt
Contact:

#4

Post by Luxurious » 5 years ago

up
DRK Zombie-Escape V1.6
IP : 81.169.153.129:27015

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 2 guests