Vip_Custom + Пулемет

Статус
В этой теме нельзя размещать новые ответы.

fox

Сообщения
176
Реакции
49
Помог
7 раз(а)
Изменил плагин, удалил голд оружие, добавил пулемет, прописал всё в LANG-файле. Компилируется нормально, но плагин не работает. В консоли пишет, что запущен, но не открывается випменю.

Код:
        #include <amxmodx>
        #include <amxmisc>
        #include <hamsandwich>
        #include <fakemeta>

        #define PLUGIN_NAME "V.I.P Custom Weapons"
        #define PLUGIN_VERSION "1.0.0"
        #define PLUGIN_AUTHOR "Vaqtincha"

        // macro; %1 - variable being modified, %2 - player id
        #define CheckFlag(%1,%2)  (%1 &   (1 << (%2 & 31)))
        #define SetFlag(%1,%2)    (%1 |=  (1 << (%2 & 31)))
        #define ClearFlag(%1,%2)  (%1 &= ~(1 << (%2 & 31)))

        #define SetFlagConnected(%1)    g_bConnected |= 1<<(%1 & 31)
        #define ClearFlagConnected(%1)    g_bConnected &= ~( 1<<(%1 & 31))
        #define UserConnected(%1)        (g_bConnected &  1<<(%1 & 31))

        #define cs_get_user_hasprim(%1,%2) (get_pdata_cbase(%1, m_rgpPlayerItems_CBasePlayer[%2])>0)
        #define fm_get_user_money(%1)         get_pdata_int(%1, m_iAccount, XO_PLAYER)
        #define fm_get_weapon_id(%1)         get_pdata_int(%1, m_iId, XO_WEAPON)
        #define fm_set_weapon_ammo(%1,%2)    set_pdata_int(%1, m_iClip, %2, XO_WEAPON)

        #if AMXX_VERSION_NUM < 183
            #define HasShield(%1)    (get_pdata_int(%1, m_iUserPrefs, XO_PLAYER) & m_bHasShield)
        #else
            #define HasShield(%1)    get_pdata_bool(%1, m_bHasShield)
        #endif

        #define MAX_PLAYERS 32
        #define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers )

        #define ITEM_DEAGLE     (1<<0)
        #define ITEM_HE         (1<<1)
        #define ITEM_SMOKE     (1<<2)
        #define ITEM_FLASH     (1<<3)
        #define ITEM_AMMO     (1<<4)
        #define ITEM_ARMOR     (1<<5)
        #define ITEM_DEFUSER (1<<6)

        new Trie:vipChannels
        new g_iAlive[MAX_PLAYERS+1]
        new bool:g_bAccess[MAX_PLAYERS+1]
        new g_iPlayerPos[MAX_PLAYERS+1]
        new g_iPlayerCol[MAX_PLAYERS+1]
        new gbIsUsed, giCounter, g_bConnected, g_iMaxPlayers, target_map

        new g_iKNFPluginId, g_iDGLPluginId, g_iM4A1PluginId, g_iAK47PluginId, g_iAWPPluginId, g_iM249PluginId
        new g_iKNFReload, g_iDGLReload, g_iM4A1Reload, g_iAK47Reload, g_iAWPReload, g_iM249Reload

        new alw_round_eq, alw_round_fm, alw_round_m4ak, alw_round_awp, alw_round_m249
        new vampire, vampire_max, hp_bonus, hp_bonus_hs, item_flags, delay, damager, droptype
        new dmgcolors[3], scrtag, prefix, info, remove_limit, openmenu, nofall, recieved
        static flagaccess

            // Offsets
        new const m_rgpPlayerItems_CBasePlayer[6] = {367, 368, ...}
        #if AMXX_VERSION_NUM < 183
            const m_bHasShield = 1<<24
            const m_iUserPrefs = 510
        #else
            const m_bHasShield = 2043
        #endif
        const m_pNext = 42
        const m_iClip = 51
        const m_iId = 43
        const XO_PLAYER = 5
        const XO_WEAPON = 4
        #if cellbits == 32
            const m_iAccount = 115
        #else
            const m_iAccount = 140
        #endif

        const MENUKEYS = 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 KEY_EXIT = 10

        const PRIMARY_WEAPONS_BIT_SUM = 1<<CSW_SCOUT|1<<CSW_XM1014|1<<CSW_MAC10|1<<CSW_AUG|1<<CSW_UMP45
            |1<<CSW_SG550|1<<CSW_GALIL|1<<CSW_FAMAS|1<<CSW_AWP|1<<CSW_MP5NAVY|1<<CSW_M249|1<<CSW_M3
            |1<<CSW_M4A1|1<<CSW_TMP|1<<CSW_G3SG1|1<<CSW_SG552|1<<CSW_AK47|1<<CSW_P90

        const SECONDARY_WEAPONS_BIT_SUM = 1<<CSW_P228|1<<CSW_ELITE|1<<CSW_FIVESEVEN|1<<CSW_USP|1<<CSW_GLOCK18|1<<CSW_DEAGLE

        const NOCLIP_WPN_BS = ((1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))

            // Max BP ammo for weapons
        new const MAXBPAMMO[31] = { -1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90,
            90, 90, 100, 120, 30, 120, 200, 32, 90, 120, 90, 2, 35, 90, 90, -1, 100
        }
            // Max clip for weapons
        new const MAXCLIP[CSW_P90+1] = { -1, 13, -1, 10, 1, 7, 1, 30, 30, 1, 30, 20, 25, 30,
            35, 25, 12, 20, 10, 30, 100, 8, 30, 30, 20, 2, 7, 30, 30, -1, 50
        }
            // Ammo Type Names for weapons
        new const AMMOTYPE[][] = { "", "357sig", "", "762nato", "", "buckshot", "", "45acp", "556nato",
            "", "9mm", "57mm", "45acp", "556nato", "556nato", "556nato", "45acp", "9mm", "338magnum", "9mm",
            "556natobox","buckshot", "556nato", "9mm", "762nato", "", "50ae", "556nato", "762nato", "", "57mm"
        }

        new const Float:g_flCoords[][] = { {0.50, 0.40},{0.56, 0.44},{0.60, 0.50},
            {0.56, 0.56},{0.50, 0.60},{0.44, 0.56},{0.40, 0.50},{0.44, 0.44}
        }

        new const g_iColors[][] = { {0, 127, 255},/*blue*/{255, 127, 0},/*orange*/
            {127, 0, 255},/*purple*/{0, 255, 0},/*green*/{255, 24, 119},/*pink*/
            {228, 228, 228},/*gray*/{165, 42, 42},/*brown*/{255, 255, 0}/*yellow*/
        }

        new channels[8][] = {
            "#Cstrike_Chat_CT","#Cstrike_Chat_T","#Cstrike_Chat_CT_Dead","#Cstrike_Chat_T_Dead",
            "#Cstrike_Chat_Spec","#Cstrike_Chat_All","#Cstrike_Chat_AllDead","#Cstrike_Chat_AllSpec"
        }

        new newChannels[8][] = {
            "^4(^1Counter-Terrorist^4) [^3V.I.P^4] ^3%s1^1 :  ^4%s2",
            "^4(^1Terrorist^4) [^3V.I.P^4] ^3%s1^1 :  ^4%s2",
            "^1*DEAD*^4(^1Counter-Terrorist^4) [^3V.I.P^4] ^3%s1^1 :  ^4%s2",
            "^1*DEAD*^4(^1Terrorist^4) [^3V.I.P^4] ^3%s1^1 :  ^4%s2",
            "^4(^1Spectator^4) [^3V.I.P^4] ^3%s1^1 :  ^4%s2",
            "^4[^3V.I.P^4] ^3%s1^1 :  ^4%s2",
            "^1*DEAD* ^4[^3V.I.P^4] ^3%s1^1 :  ^4%s2",
            "^1*SPEC* ^4[^3V.I.P^4] ^3%s1^1 :  ^4%s2"
        }


        public plugin_init()
        {
            new mapname[4]
            get_mapname(mapname, charsmax(mapname))
            if(equali(mapname, "de_") || equali(mapname, "cs_"))
            {
                target_map = true
            }
           
            register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
            register_cvar("vip_custom_version", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
            register_concmd("vip_custom_reloadcfg", "cmdReloadCfg", ADMIN_CFG)
            register_dictionary ("vip_custom.txt" )
            loadconfig()
            g_iMaxPlayers = get_maxplayers()

            RegisterHam(Ham_Spawn, "player", "playerspawn_post", 1)
            RegisterHam(Ham_Killed, "player", "playerkilled_post", 1)
           
            if(nofall) RegisterHam(Ham_TakeDamage, "player", "HamTakeDamagePlayerPre", 0)
            if(scrtag) register_message( get_user_msgid("ScoreAttrib"), "msgScoreAttrib" )
            if(damager) register_event("Damage", "Event_Damage", "b", "2>0", "3=0")
            if(prefix)
            {
                vipChannels = TrieCreate()
                for (new i = 0; i < 8; i++)
                {
                    TrieSetString(vipChannels, channels[i], newChannels[i])
                }
                register_message(get_user_msgid("SayText"), "messageSayText")
            }
            if(target_map)
            {
                // Cmds
                register_clcmd( "weaponmenu", "MenuCommand" )
                register_clcmd( "say /vipmenu", "MenuCommand" )
                // Menu
                register_menucmd( register_menuid( "WeaponMenu" ),MENUKEYS, "MenuHandler" )
                register_menucmd( register_menuid( "BuyMenu" ),MENUKEYS, "MenuHandlerCustom" )
                // Events
                register_event( "HLTV", "Event_NewRound", "a", "1=0", "2=0" )
                register_event( "TextMsg", "Event_NewGame", "a", "2=#Game_will_restart_in", "2=#Game_Commencing" )
                if(vampire) register_event( "DeathMsg", "Event_DeathMsg", "a")
                if(remove_limit) register_event( "BarTime", "event_bomb_planting", "be", "1=3")
            }
        }

        public cmdReloadCfg(id, level, cid)
        {
            if (!cmd_access(id, level, cid, 1))
                return PLUGIN_HANDLED

            set_task(0.2, "delayed_load")
            return PLUGIN_HANDLED
        }

        public delayed_load()
        {
            item_flags = 0
            loadconfig()
            if( g_iKNFPluginId > 0 && g_iKNFReload > 0)
            {
                callfunc_begin_i(g_iKNFReload, g_iKNFPluginId)
                callfunc_end()
            }
            if( g_iDGLPluginId > 0 && g_iDGLReload > 0)
            {
                callfunc_begin_i(g_iDGLReload, g_iDGLPluginId)
                callfunc_end()
            }
            if(g_iM4A1PluginId > 0 && g_iM4A1Reload > 0)
            {      
                callfunc_begin_i(g_iM4A1Reload, g_iM4A1PluginId)
                callfunc_end()
            }
            if(g_iAK47PluginId > 0 && g_iAK47Reload > 0)
            {
                callfunc_begin_i(g_iAK47Reload, g_iAK47PluginId)
                callfunc_end()
            }
            if(g_iAWPPluginId > 0 && g_iAWPReload > 0)
            {
                callfunc_begin_i(g_iAWPReload, g_iAWPPluginId)
                callfunc_end()
            }
            if(g_iM249PluginId > 0 && g_iM249Reload > 0)
            {
                callfunc_begin_i(g_iM249Reload, g_iM249PluginId)
                callfunc_end()
            }
        }

        public loadconfig()
        {
            new ConfigFile[64], szMsg[128]     // "addons/amxmodx/configs/vip_custom.ini" 37
            get_localinfo("amxx_configsdir", ConfigFile, charsmax(ConfigFile))
            add(ConfigFile, charsmax(ConfigFile), "/vip_custom.ini")
            if( !file_exists(ConfigFile) )
            {
                formatex( szMsg, charsmax(szMsg), "%s Config File Not Found!", PLUGIN_NAME )
                set_fail_state(szMsg)
                return
            }
           
            new fp = fopen(ConfigFile, "rt")
            if( fp )
            {
                new Datas[86], Setting[32], Value[15]
                while( !feof(fp) )
                {
                    fgets(fp, Datas, charsmax(Datas))
                    trim(Datas)
                    if(!Datas[0] || Datas[0] == ';' || Datas[0] == '#' || Datas[0] == '/' || Datas[0] == '[')
                    {
                        continue
                    }
                    new Sign[3]
                    parse(Datas, Setting, charsmax(Setting), Sign, charsmax(Sign), Value, charsmax(Value))
                    if( equali(Setting, "flag_access"))
                    {
                        flagaccess = read_flags(Value)
                    }else if( equali(Setting, "give_item_flags"))
                    {
                        if (containi(Value, "p") != -1)
                        {
                            item_flags |= ITEM_DEAGLE
                        }
                        if (containi(Value, "h") != -1)
                        {
                            item_flags |= ITEM_HE
                        }
                        if (containi(Value, "s") != -1)
                        {
                            item_flags |= ITEM_SMOKE
                        }
                        if (containi(Value, "f") != -1)
                        {
                            item_flags |= ITEM_FLASH
                        }  
                        if (containi(Value, "a") != -1)
                        {
                            item_flags |= ITEM_AMMO
                        }          
                        if (containi(Value, "v") != -1)
                        {
                            item_flags |= ITEM_ARMOR
                        }          
                        if (containi(Value, "d") != -1)
                        {
                            item_flags |= ITEM_DEFUSER
                        }
                    }else if( equali(Setting, "allowed_round_equip")){
                        alw_round_eq = str_to_num(Value)
                    }else if( equali(Setting, "vip_tag")){
                        scrtag = str_to_num(Value) ? true : false
                    }else if( equali(Setting, "vip_prefix")){
                        prefix = str_to_num(Value) ? true : false
                    }else if( equali(Setting, "vip_info")){
                        info = str_to_num(Value) ? true : false
                    }else if( equali(Setting, "drop_type")){
                        droptype = str_to_num(Value)
                    }else if( equali(Setting, "no_fall_damage")){
                        nofall = str_to_num(Value) ? true : false
                    }else if( equali(Setting, "remove_limit")){
                        remove_limit = str_to_num(Value) ? true : false
                    }else if( equali(Setting, "bullet_damage")){
                        damager = str_to_num(Value)
                    }else if( equali(Setting, "bullet_damage_recieved")){
                        recieved = str_to_num(Value) ? true : false
                    }else if( equali(Setting, "bullet_damage_color")){
                        new red[10], green[10], blue[10]
                        parse(Value, red, charsmax(red), green, charsmax(green), blue, charsmax(blue))
                        dmgcolors[0] = str_to_num(red)
                        dmgcolors[1] = str_to_num(green)
                        dmgcolors[2] = str_to_num(blue)
                    }else if( equali(Setting, "vampire")){
                        vampire = str_to_num(Value) ? true : false
                    }else if( equali(Setting, "vampire_max_hp")){
                        vampire_max = str_to_num(Value)
                    }else if( equali(Setting, "vampire_hp")){
                        hp_bonus = str_to_num(Value)
                    }else if( equali(Setting, "vampire_hp_hs")){
                        hp_bonus_hs = str_to_num(Value)
                    }else if( equali(Setting, "open_menu")){
                        openmenu = str_to_num(Value) ? true : false
                    }else if( equali(Setting, "close_delay")){
                        delay = str_to_num(Value)
                    }else if( equali(Setting, "allowed_round_famas")){
                        alw_round_fm = str_to_num(Value)
                    }else if( equali(Setting, "allowed_round_m4ak")){
                        alw_round_m4ak = str_to_num(Value)
                    }else if( equali(Setting, "allowed_round_awp")){
                        alw_round_awp = str_to_num(Value)
                    }else if( equali(Setting, "allowed_round_m249")){
                        alw_round_m249 = str_to_num(Value)
                    }
                }
                formatex( szMsg, charsmax(szMsg), "%s Config Successfully Loaded!", PLUGIN_NAME )
                server_print(szMsg)
            }
        }

        public client_putinserver(id)
        {
            g_iAlive[id] = 0
            g_bAccess[id] = get_user_flags(id) & flagaccess ? true : false

            if(info)
            {
                set_task(1.0, "vip_connected", id)
                if(target_map)
                {
                    set_task(30.0, "vip_help", id)
                }
            }
            if(!is_user_hltv(id))
            {
                SetFlagConnected(id)
            }
        }

        public client_disconnected(id)
        {
            ClearFlagConnected(id)
        }

        public playerspawn_post(id)
        {
            g_iAlive[id] = is_user_alive(id)
            g_bAccess[id] = get_user_flags(id) & flagaccess ? true : false
            set_task(0.2, "GiveItem", id + 6910)
        }

        public playerkilled_post(id, attacker, shouldgib)
        {
            g_iAlive[id] = 0
        }

        public Event_NewRound()
        {
            gbIsUsed = 0
            giCounter++
        }

        public Event_NewGame()
        {
            giCounter = 0
        }

            // Vip connected info/help
        public vip_connected(id)
        {
            if(g_bAccess[id])
            {
                new name[32]
                get_user_name(id, name, 31)
                ChatColor(0, "%L", LANG_SERVER,"VIP_CONNECTED", name)
            }
        }

        public vip_help(id)
        {
            if(g_bAccess[id])
            {
                new name[32]
                get_user_name(id, name, 31)
                ChatColor(id, "%L", LANG_SERVER,"VIP_HELP", name)
            }
        }

            // ScoreBoard "VIP" String
        public msgScoreAttrib(const MsgId, const MsgType, const MsgDest)
        {
            static id; id = get_msg_arg_int(1)
            if(get_msg_arg_int(2) || !(g_bAccess[id]))
                return
            set_msg_arg_int(2, ARG_BYTE, (1<<2))
        }

            // [V.I.P] prefix and green chat
        public messageSayText(msgid, msgdest, id)
        {
            new channel[64]
            get_msg_arg_string(2, channel, charsmax(channel))
           
            if(!TrieGetString(vipChannels, channel, channel, charsmax(channel)))
            {
                return
            }
            new sender = get_msg_arg_int(1)
            if(g_bAccess[sender])
            {
                set_msg_arg_string(2, channel)
            }
        }

        public plugin_end()
        {
            TrieDestroy(vipChannels)
        }

            // Bullet Damage
        public Event_Damage(iVictim)
        {
            if((read_data(4) || read_data(5) || read_data(6)))
            {
                static damage; damage = read_data(2)
                if( recieved && IsPlayer(iVictim) && UserConnected(iVictim))
                {
                    if(g_bAccess[iVictim])
                    {
                        set_hudmessage(255, 0, 0,  0.45, 0.50, 0, 6.0, 3.0, _, _, 3)
                        show_hudmessage(iVictim, "%d", damage)
                    }
                }
                new id = get_user_attacker(iVictim)
                if( IsPlayer(id) && UserConnected(id))
                {
                    new iPos = ++g_iPlayerPos[id]
                    if( iPos == sizeof(g_flCoords))
                    {
                        iPos = g_iPlayerPos[id] = 0
                    }
                    new iCol = ++g_iPlayerCol[id]
                    if( iCol == sizeof(g_iColors))
                    {
                        iCol = g_iPlayerCol[id] = 0
                    }
                    if(g_bAccess[id])
                    {
                        switch(damager)
                        {    case 1:{
                                set_hudmessage(dmgcolors[0], dmgcolors[1], dmgcolors[2], 0.51, 0.51, 0, 6.0, 3.0, _, _, 3)
                            }
                            case 2:{
                                set_hudmessage(dmgcolors[0], dmgcolors[1], dmgcolors[2], Float:g_flCoords[iPos][0], Float:g_flCoords[iPos][1], 0, 0.1, 2.5, 0.02, 0.02, -1)
                            }
                            case 3:{
                                set_hudmessage(g_iColors[iCol][0], g_iColors[iCol][1], g_iColors[iCol][2], Float:g_flCoords[iPos][0], Float:g_flCoords[iPos][1], 0, 0.1, 2.5, 0.02, 0.02, -1)
                            }
                        }
                        show_hudmessage(id, "%d", damage)
                    }
                }
            }
        }

            // Vampire
        public Event_DeathMsg()
        {
            new KillerId = read_data(1)
            new VictimId = read_data(2)
            new HeadShot = read_data(3)
           
            if(KillerId == VictimId || !IsPlayer(KillerId)
            || !g_iAlive[KillerId] || !(g_bAccess[KillerId])
            || get_user_team(KillerId) == get_user_team(VictimId))
            {
                return
            }
           
            new KillerHealth = get_user_health(KillerId)
            new KillerMaxHealth = vampire_max
            if(KillerHealth < KillerMaxHealth)
            {
                new BonusKillerHealth = HeadShot ? hp_bonus_hs : hp_bonus
                new NewKillerHealth = min(KillerHealth + BonusKillerHealth, KillerMaxHealth)
                fm_set_user_health(KillerId, NewKillerHealth)
                set_hudmessage(0, 255, 100, -1.0, 0.15, 0, 1.0, 1.0, 0.1, 0.1, -1)
                show_hudmessage(KillerId, "Healed +%d hp", NewKillerHealth - KillerHealth)
            }
        }

            // Terrorist planter  :D
        public event_bomb_planting(id)
        {
            if(!g_iAlive[id] || !g_bAccess[id])
                return
            set_pev(id, pev_maxspeed, 250.0)
        }

            // No fall damage
        public HamTakeDamagePlayerPre(victim, inflictor, attacker, Float:dmg, dmg_type)
        {
            if(g_bAccess[victim])
            {
                if(dmg_type & (1<<5)/* dmg fall */)
                {
                    return HAM_SUPERCEDE
                }
            }
            return HAM_IGNORED
        }

            // Equip/Deagle giving
        public GiveItem(TaskID)
        {
            new id = TaskID - 6910

            if( !( g_bAccess[id]) || !g_iAlive[id])
            {
                return
            }
            if(item_flags & ITEM_AMMO)
            {
                giveammo(id)
                refill(id)
            }
            if(!target_map)
            {
                return
            }
            if(giCounter >= alw_round_eq)
            {
                if(item_flags & ITEM_DEAGLE)
                {
                    if(user_has_weapon(id,CSW_DEAGLE))
                    {
                        ExecuteHamB(Ham_GiveAmmo, id, 35, "50ae", 35)
                    }else{
                        drop_weapons(id, 2)
                        fm_give_item(id,"weapon_deagle")
                        ExecuteHamB(Ham_GiveAmmo, id, 35, "50ae", 35)
                    }
                }
                if(item_flags & ITEM_HE)
                {
                    fm_give_item(id,"weapon_hegrenade")          
                }
                if(item_flags & ITEM_SMOKE)
                {
                    fm_give_item(id,"weapon_smokegrenade")
                }  
                if(item_flags & ITEM_FLASH)
                {
                    fm_give_item(id,"weapon_flashbang")
                    fm_give_item(id,"weapon_flashbang")          
                }
                if(item_flags & ITEM_ARMOR)
                {
                    fm_give_item(id,"item_assaultsuit")
                    fm_set_user_armor(id,100)
                }
                if(item_flags & ITEM_DEFUSER)
                {
                    if(get_user_team(id) == 2)
                    {
                        fm_give_item(id,"item_thighpack")
                    }
                }
            }
            if(openmenu)
            {
                if(!cs_get_user_hasprim(id, 1) && giCounter >= alw_round_fm)
                {
                    MenuCommand(id)
                }
            }
        }

            // Weapon Menu
        public MenuCommand(id)
        {
            new szMenu[512]         // it is maximum allowed menu size
            new iKeys
            new iLen = formatex( szMenu, charsmax(szMenu), "\y%L\R%L^t^n^n", LANG_SERVER,"WEAPONS_MENU", LANG_SERVER,"ROUND")
           
            new iItemsDisabled
            if( !( g_bAccess[id]) || !g_iAlive[id] || CheckFlag( gbIsUsed, id ))
                iItemsDisabled = 1
               
            if( iItemsDisabled || giCounter < alw_round_fm )
                {
                    iLen += formatex( szMenu[iLen], charsmax(szMenu) - iLen, "\d1.^t%L\R\r%d^t^n", LANG_SERVER,"WEAPON_FAMAS", alw_round_fm)
                }else{
                    iLen += formatex( szMenu[iLen], charsmax(szMenu) - iLen, "\y1.^t\w%L\R\y%d^t^n", LANG_SERVER,"WEAPON_FAMAS", alw_round_fm)
                    iKeys |= MENU_KEY_1
                }
            if( iItemsDisabled  || giCounter < alw_round_m4ak )
                {
                    iLen += formatex( szMenu[iLen], charsmax(szMenu) - iLen, "\d2.^t%L\R\r%d^t^n", LANG_SERVER, "WEAPON_M4A1", alw_round_m4ak)
                }else{
                    iLen += formatex( szMenu[iLen], charsmax(szMenu) - iLen, "\y2.^t\w%L\R\y%d^t^n", LANG_SERVER, "WEAPON_M4A1", alw_round_m4ak)
                    iKeys |= MENU_KEY_2
                }
            if( iItemsDisabled  || giCounter < alw_round_m4ak )
                {
                    iLen += formatex( szMenu[iLen], charsmax(szMenu) - iLen, "\d3.^t%L\R\r%d^t^n", LANG_SERVER,"WEAPON_AK-47", alw_round_m4ak)
                }else{
                    iLen += formatex( szMenu[iLen], charsmax(szMenu) - iLen, "\y3.^t\w%L\R\y%d^t^n", LANG_SERVER,"WEAPON_AK-47", alw_round_m4ak)
                    iKeys |= MENU_KEY_3
                }
            if( iItemsDisabled  || giCounter < alw_round_awp )
                {
                    iLen += formatex( szMenu[iLen], charsmax(szMenu) - iLen, "\d4.^t%L\R\r%d^t^n", LANG_SERVER,"WEAPON_AWP", alw_round_awp)
                }else{
                    iLen += formatex( szMenu[iLen], charsmax(szMenu) - iLen, "\y4.^t\w%L\R\y%d^t^n", LANG_SERVER,"WEAPON_AWP", alw_round_awp)
                    iKeys |= MENU_KEY_4
                }
            if( iItemsDisabled  || giCounter < alw_round_m249 )
                {
                    iLen += formatex( szMenu[iLen], charsmax(szMenu) - iLen, "\d5.^t%L\R\r%d^t^n", LANG_SERVER,"WEAPON_M249", alw_round_m249)
                }else{
                    iLen += formatex( szMenu[iLen], charsmax(szMenu) - iLen, "\y5.^t\w%L\R\y%d^t^n", LANG_SERVER,"WEAPON_M249", alw_round_m249)
                    iKeys |= MENU_KEY_5
                }
               
            formatex( szMenu[iLen], charsmax(szMenu) - iLen, "^n\y0.^t\w%L", LANG_SERVER, "EXIT" )
            iKeys |=  MENU_KEY_0|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9
            show_menu( id, iKeys, szMenu, delay, .title = "WeaponMenu" )

            return PLUGIN_HANDLED
        }
            // Weapon Menu Func
        public MenuHandler(id, key)
        {
            if(key == KEY_EXIT - 1 || !g_iAlive[id])
                return PLUGIN_HANDLED

            switch(key)
            {
                case 0:{
                    if(user_has_weapon(id,CSW_FAMAS))
                    {
                        client_print(id, print_center, "%L", LANG_SERVER,"ALREADY_OWN_WEAPON")
                    }
                    else{
                        drop_weapons(id, 1)
                        fm_give_item(id,"weapon_famas")
                        ExecuteHamB(Ham_GiveAmmo, id, 90, "556nato", 90)
                        SetFlag( gbIsUsed, id )
                    }
                }
                case 1:{
                    if(user_has_weapon(id,CSW_M4A1))
                    {
                        client_print(id, print_center, "%L", LANG_SERVER,"ALREADY_OWN_WEAPON")
                    }
                    else{
                        drop_weapons(id, 1)
                        fm_give_item(id,"weapon_m4a1")
                        ExecuteHamB(Ham_GiveAmmo, id, 90, "556nato", 90)
                        SetFlag( gbIsUsed, id )
                    }
                }
                case 2:{
                    if(user_has_weapon(id,CSW_AK47))
                    {
                        client_print(id, print_center, "%L", LANG_SERVER,"ALREADY_OWN_WEAPON")
                    }
                    else{
                        drop_weapons(id, 1)
                        fm_give_item(id,"weapon_ak47")
                        ExecuteHamB(Ham_GiveAmmo, id, 90, "762nato", 90)
                        SetFlag( gbIsUsed, id )
                    }
                }
                case 3:{
                    if(user_has_weapon(id,CSW_AWP))
                    {
                        client_print(id, print_center, "%L", LANG_SERVER,"ALREADY_OWN_WEAPON")
                    }
                    else{
                        drop_weapons(id, 1)
                        fm_give_item(id,"weapon_awp")
                        ExecuteHamB(Ham_GiveAmmo, id, 30, "338magnum", 30)
                        SetFlag( gbIsUsed, id )
                    }
                }
                case 4:{
                    if(user_has_weapon(id,CSW_M249))
                    {
                        client_print(id, print_center, "%L", LANG_SERVER,"ALREADY_OWN_WEAPON")
                    }
                    else{
                        drop_weapons(id, 1)
                        fm_give_item(id,"weapon_m249")
                        ExecuteHamB(Ham_GiveAmmo, id, 200, "762nato", 200)
                        SetFlag( gbIsUsed, id )
                    }
                }
            }
            return PLUGIN_HANDLED
        }

        //================================ STOCKS ==============================//

        stock giveammo(id)
        {
            new weap_ids[32], num_weaps
            num_weaps = 0
            get_user_weapons(id, weap_ids, num_weaps)
            for (new i = 0; i < num_weaps; i++)
            {
                new weap_id = weap_ids[i]
                new ammo = MAXBPAMMO[weap_id]
                if(!( NOCLIP_WPN_BS & (1<<weap_id)))
                {
                    ExecuteHamB(Ham_GiveAmmo, id, MAXBPAMMO[weap_id], AMMOTYPE[weap_id], MAXBPAMMO[weap_id], ammo)
                }
            }
        }

        stock refill(id)
        {
            for(new slot = 1; slot<= 2; slot++)
            {
                new iWeapon = get_pdata_cbase(id, m_rgpPlayerItems_CBasePlayer[slot])
                while( iWeapon > 0 )
                {
                    new iId = fm_get_weapon_id(iWeapon)
                    if( !( NOCLIP_WPN_BS & (1<<iId) ) )
                    {
                        fm_set_weapon_ammo(iWeapon, MAXCLIP[iId])
                        iWeapon = get_pdata_cbase(iWeapon, m_pNext, XO_WEAPON)
                    }
                }
            }
        }

        stock drop_weapons(id, dropwhat)
        {
            static weapons[32], num, i, weaponid
            num = 0
            get_user_weapons(id, weapons, num)

            for (i = 0; i < num; i++)
            {
                weaponid = weapons[i]
                if((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM) || HasShield(id))
                || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM )))
                {
                    static wname[32]
                    get_weaponname(weaponid, wname, charsmax(wname))
                    switch(droptype)
                    {
                        case 0: ham_strip_weapon(id, wname)
                        case 1: engclient_cmd(id, "drop", wname)
                    }
                }
            }
        }

        stock ham_strip_weapon(id,weapon[])
        {
            if(!equal(weapon,"weapon_",7)) return 0
           
            new wId = get_weaponid(weapon)
            if(!wId) return 0
           
            new wEnt
            while((wEnt = engfunc(EngFunc_FindEntityByString, wEnt, "classname", weapon)) && pev(wEnt, pev_owner) != id) {}
            if(!wEnt) return 0
           
            new iTmp
            if(get_user_weapon(id, iTmp, iTmp) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon, wEnt)
           
            if(!ExecuteHamB(Ham_RemovePlayerItem, id, any:wEnt)) return 0
           
            ExecuteHamB(Ham_Item_Kill, wEnt)
            set_pev(id, pev_weapons, pev(id, pev_weapons) & ~(1<<wId))
           
            return 1
        }

        stock ChatColor(const id, const input[], any:...)
        {
            new count = 1, players[32], i
            static msg[191]
            vformat(msg, 190, input, 3)
           
            replace_all(msg, 190, "!g", "^4") // Green Color
            replace_all(msg, 190, "!n", "^1") // Default Color
            replace_all(msg, 190, "!t", "^3") // Team Color
         
            if(id)players[0] = id; else get_players(players, count, "ch")
            {
                for(i = 0; i < count; i++)
                {
                    if(is_user_connected(players[i]))
                    {
                        message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
                        write_byte(players[i])
                        write_string(msg)
                        message_end()
                    }
                }
            }
        }

        stock fm_set_user_armor(index, armor)
        {
            set_pev(index, pev_armorvalue, float(armor))
            return 1
        }

        stock fm_set_user_health(index, health)
        {
            health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index)
            return 1
        }

        stock fm_give_item(index, const item[])
        {
            if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5))
                return 0
           
            new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
            if (!pev_valid(ent))
                return 0

            new Float:origin[3]
            pev(index, pev_origin, origin)
            set_pev(ent, pev_origin, origin)
            set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
            dllfunc(DLLFunc_Spawn, ent)

            new save = pev(ent, pev_solid)
            dllfunc(DLLFunc_Touch, ent, index)
            if (pev(ent, pev_solid) != save)
                return ent

            engfunc(EngFunc_RemoveEntity, ent)

            return -1
        }
 
Последнее редактирование:
Сообщения
1,293
Реакции
2,294
Помог
57 раз(а)
В чём вопрос? Вы хотите, чтобы за вас кто-то перелопатил сломанный вами код? Проводите отладку, добавляйте вывод инфы в лог/чат в ключевых моментах, чтобы определить, где не отрабатывает код. Если меню (и команда доступа к нему) регается от условия, надо понять, выполняется ли условие. Если да, смотреть, где затык в функции что открывает меню. Ну и наличие эррорлогов проверяйте, конечно же.
 

fox

Сообщения
176
Реакции
49
Помог
7 раз(а)
BlackSignature, Утром проверил в чём был сбой, так что тему можно /del.
1. не убрал просто
Код:
register_menucmd( register_menuid( "BuyMenu" ),MENUKEYS, "MenuHandlerCustom" )
2. Личность попросившая переделать, не указала что amx 1.8.2, компилил на 1.8.3
 
Статус
В этой теме нельзя размещать новые ответы.

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

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