Преработка на плъгини [BM System #3]

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
Coca Cola _-FxF-_
Извън линия
Потребител
Потребител
Мнения: 159
Регистриран на: 15 Окт 2016, 15:30
Се отблагодари: 21 пъти
Получена благодарност: 3 пъти
Обратна връзка:

Преработка на плъгини [BM System #3]

Мнение от Coca Cola _-FxF-_ » 13 Юни 2017, 03:11

Да е за контра терорист, и ако е възможно да има меню за купуване на Points, чрез пари. ( Не е задължително купуването на Points, чрез пари :lol: )

Код за потвърждение: Избери целия код

/*==================================================================================================

                   |**********************************|
                   |==================================|
                   |=     BlockMaker Item Shop     =|
                   |==================================|
                   |**********************************|

|= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =|
 |                                                   |
 |                                                   |
 |            Copyright © 2017-2018, AJW1337//                        |
 |            This file is provided as is (no warranties)                    |
 |                                                   |
 |            BlockMaker Item Shop is free software;                          |
 |            you can redistribute it and/or modify it under the terms of the        |
 |            GNU General Public License as published by the Free Software Foundation.   |
 |                                                   |    
 |            This program is distributed in the hope that it will be useful,            |
 |            but WITHOUT ANY WARRANTY; without even the implied warranty of             |
 |            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                |
 |                                                   |
 |                                                   |
 |            Plugin requested by Coca Cola _-FxF-_                       |
 |                                                   |
|= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =| 
                      |---------------|
                      |   Changelog   |
                      |---------------|
                v1.0 Official Plugin Release
                                             
==================================================================================================*/

#include <amxmodx>
#include <amxmisc>
#include <fakemeta_util>
#include <fvault>
#include <WPMGPrintChatColor>
#include <hamsandwich>
#include <engine>

#if AMXX_VERSION_NUM < 183
    #include <dhudmessage>
    #define client_disconnected client_disconnect
#endif

native add_user_immune(id)
native remove_user_immune(id)

native hnsxp_get_user_xp(id)
native hnsxp_set_user_xp(id, iExp)

stock hnsxp_add_user_xp(id, iExp)
    return hnsxp_set_user_xp(id, hnsxp_get_user_xp(id) + iExp)


new const PLUGIN[] = "BlockMaker Item Shop"
new const VERSION[] = "1.0"
new const AUTHOR[] = "AJW1337//"
new const BM_ItemShopDB[] = "BM_ItemShop_DataBase"

enum _:Info
{
    PRICE = 0,
    LIMIT,
    AMOUNT
}

enum _:Items
{
    HEALTH,
    ARMOR,
    HE_NADE,
    NO_FROST,
    NO_FLASH,
    AWP,
    M3,
    DEAGLE,
    XP,
    RESPAWN
}

new const szItemNames[Items][] =
{
    "Health",
    "Armor",
    "HE Grenade",
    "Anti Frost",
    "Anti Flash",
    "AWP",
    "M3",
    "Deagle",
    "XP",
    "Respawn"
}

new ItemInfo[Items][Info], g_ItemsLimit[33][Items], bool:g_IsBought[33][Items]
new g_iPoints[33], bool:g_bConnected[33]
new g_iSyncMessage

// For Anti Flash
new Float:g_flGameTime[2], g_iOwner
new g_iGrenade[32], bool:g_iTrackEnemy, bool:g_iTrack[33]
new g_iMsgScreenFade, g_iLast, g_iSyncData
new g_bNoFlash[33]
// For Anti Flash

enum
{
    SECTION_SHOP = 1,
    SECTION_PRICE,
    SECTION_LIMIT,
    SECTION_AMOUNT
}

enum _:DataItems
{
    SHOP_PREFIX[32],
    SHOP_MENU_PREFIX[32],
    SHOP_COMMAND[32],
    HS_KILL_POINTS,
    KILL_POINTS,
    PRINT_COLOR,
    D_HUD_MESSAGE,
    D_HUD_CUSTOM_COLOR,
    RED_COLOR,
    GREEN_COLOR,
    BLUE_COLOR,
    Float:COORD_X,
    Float:COORD_Y
}

new g_eItems[DataItems]

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_cvar("BM_ItemShop", VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
    
    register_dictionary("blockmaker_itemshop.txt")
    
    register_clcmd("say", "Command_HookSay")
    register_clcmd("say_team", "Command_HookSay")
    
    register_concmd("amx_reload_file", "Command_ReloadFile", ADMIN_BAN)
    
    register_clcmd("BM_Points_Amount", "Command_BM_Points_Amount", ADMIN_BAN)

    register_event("DeathMsg", "eventDeathMsg", "a")
    register_logevent("eventRoundStart", 2, "1=Round_Start")
    
    register_event("ScreenFade", "eventFlash", "be", "4=255", "5=255", "6=255", "7>199")
    register_event("TextMsg", "fire_in_the_hole", "b", "2&#Game_radio", "4&#Fire_in_the_hole")
    register_event("TextMsg", "fire_in_the_hole2", "b", "3&#Game_radio", "5&#Fire_in_the_hole")
    register_event("99", "grenade_throw", "b")
    set_task(2.0, "flash", .flags="b")
    g_iMsgScreenFade = get_user_msgid("ScreenFade")
    
    new iEnt = create_entity("info_target")
    entity_set_string(iEnt, EV_SZ_classname, "task_entity")
    
    register_think("task_entity", "HudEntity")
    entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 2.0)
    
    g_iSyncMessage = CreateHudSyncObj()
    
    ReadFile()
}
public plugin_natives()
{
    register_native("get_user_bm_points", "_get_user_bm_points")
    register_native("set_user_bm_points", "_set_user_bm_points")
}
public Command_ReloadFile(id, level, cid)
{
    if (!cmd_access(id, level, cid, 1))
        goto Handled
    
    ReadFile()
        
    Handled:
    return PLUGIN_HANDLED
}
ReadFile()
{
    static szConfigsDir[64], iFile
    get_configsdir(szConfigsDir, charsmax(szConfigsDir))
    add(szConfigsDir, charsmax(szConfigsDir), "/BM_ItemShop.ini")
    iFile = fopen(szConfigsDir, "rt")
    
    if (iFile)
    {
        static szLineData[160], szKey[32], szValue[128], iSection
        
        while (!feof(iFile))
        {
            fgets(iFile, szLineData, charsmax(szLineData))
            trim(szLineData)
            
            switch (szLineData[0])
            {
                case EOS, ';': continue
                case '[':
                {
                    if (szLineData[strlen(szLineData) -1] == ']')
                    {
                        if (containi(szLineData, "item shop") != -1)
                            iSection = SECTION_SHOP
                        else if (containi(szLineData, "item prices") != -1)
                            iSection = SECTION_PRICE
                        else if (containi(szLineData, "item limits") != -1)
                            iSection = SECTION_LIMIT
                        else if (containi(szLineData, "item amounts") != -1)
                            iSection = SECTION_AMOUNT
                    }                    
                    else
                        continue
                }
                default:
                {
                    strtok(szLineData, szKey, charsmax(szKey), szValue, charsmax(szValue), '=')
                    trim(szKey)
                    trim(szValue)
                    
                    if (is_eos_line(szValue))
                        continue
                        
                    switch(iSection)
                    {
                        case SECTION_SHOP:
                        {
                            if (equal(szKey, "BM_SHOP_COMMANDS"))
                            {
                                while (szValue[0] != 0 && strtok(szValue, szKey, charsmax(szKey), szValue, charsmax(szValue), ','))
                                {
                                    trim(szKey)
                                    trim(szValue)
                                    register_clcmd(szKey, "Command_Shop")
                                }
                            }
                            else if (equal(szKey, "BM_SHOP_PRINT_COLOR"))
                                g_eItems[PRINT_COLOR] = str_to_num(szValue)
                            else if (equal(szKey, "BM_SHOP_PREFIX"))
                                copy(g_eItems[SHOP_PREFIX], charsmax(g_eItems[SHOP_PREFIX]), szValue)
                            else if (equal(szKey, "BM_SHOP_MENU_PREFIX"))
                                copy(g_eItems[SHOP_MENU_PREFIX], charsmax(g_eItems[SHOP_MENU_PREFIX]), szValue)
                            else if (equal(szKey, "BM_SHOP_HEADSHOT_KILL_POINTS"))
                                g_eItems[HS_KILL_POINTS] = str_to_num(szValue)
                            else if (equal(szKey, "BM_SHOP_NORMAL_KILL_POINTS"))
                                g_eItems[KILL_POINTS] = str_to_num(szValue)
                            else if (equal(szKey, "BM_SHOP_D_HUD_MESSAGE"))
                                g_eItems[D_HUD_MESSAGE] = clamp(hud_dhud(szValue), false, true)
                            else if (equal(szKey, "BM_SHOP_D_HUD_CUSTOM_COLOR"))
                                g_eItems[D_HUD_CUSTOM_COLOR] = clamp(on_off(szValue), false, true)
                            else if (equal(szKey, "BM_SHOP_D_HUD_RED_COLOR"))
                                g_eItems[RED_COLOR] = clamp(str_to_num(szValue), 0, 255)
                            else if (equal(szKey, "BM_SHOP_D_HUD_GREEN_COLOR"))
                                g_eItems[GREEN_COLOR] = clamp(str_to_num(szValue), 0, 255)
                            else if (equal(szKey, "BM_SHOP_D_HUD_BLUE_COLOR"))
                                g_eItems[BLUE_COLOR] = clamp(str_to_num(szValue), 0, 255)
                            else if (equal(szKey, "BM_SHOP_D_HUD_COORD_X"))
                                g_eItems[COORD_X] = _:str_to_float(szValue)
                            else if (equal(szKey, "BM_SHOP_D_HUD_COORD_Y"))
                                g_eItems[COORD_Y] = _:str_to_float(szValue)
                        }
                        case SECTION_PRICE:
                        {
                            if (equal(szKey, "BM_HEALTH_PRICE"))
                                ItemInfo[HEALTH][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ARMOR_PRICE"))
                                ItemInfo[ARMOR][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_HE_GRENADE_PRICE"))
                                ItemInfo[HE_NADE][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ANTI_FROST_PRICE"))
                                ItemInfo[NO_FROST][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ANTI_FLASH_PRICE"))
                                ItemInfo[NO_FLASH][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_AWP_PRICE"))
                                ItemInfo[AWP][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_M3_PRICE"))
                                ItemInfo[M3][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_DEAGLE_PRICE"))
                                ItemInfo[DEAGLE][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_XP_PRICE"))
                                ItemInfo[XP][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_RESPAWN_PRICE"))
                                ItemInfo[RESPAWN][PRICE] = str_to_num(szValue)
                        }
                        case SECTION_LIMIT:
                        {
                            if (equal(szKey, "BM_HEALTH_LIMIT"))
                                ItemInfo[HEALTH][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ARMOR_LIMIT"))
                                ItemInfo[ARMOR][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_HE_GRENADE_LIMIT"))
                                ItemInfo[HE_NADE][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ANTI_FROST_LIMIT"))
                                ItemInfo[NO_FROST][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ANTI_FLASH_LIMIT"))
                                ItemInfo[NO_FLASH][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_AWP_LIMIT"))
                                ItemInfo[AWP][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_M3_LIMIT"))
                                ItemInfo[M3][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_DEAGLE_LIMIT"))
                                ItemInfo[DEAGLE][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_XP_LIMIT"))
                                ItemInfo[XP][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_RESPAWN_LIMIT"))
                                ItemInfo[RESPAWN][LIMIT] = str_to_num(szValue)
                        }
                        case SECTION_AMOUNT:
                        {
                            if (equal(szKey, "BM_HEALTH_AMOUNT"))
                                ItemInfo[HEALTH][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ARMOR_AMOUNT"))
                                ItemInfo[ARMOR][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_HE_GRENADE_AMOUNT"))
                                ItemInfo[HE_NADE][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ANTI_FROST_AMOUNT"))
                                ItemInfo[NO_FROST][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ANTI_FLASH_AMOUNT"))
                                ItemInfo[NO_FLASH][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_AWP_AMOUNT"))
                                ItemInfo[AWP][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_M3_AMOUNT"))
                                ItemInfo[M3][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_DEAGLE_AMOUNT"))
                                ItemInfo[DEAGLE][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_XP_AMOUNT"))
                                ItemInfo[XP][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_RESPAWN_AMOUNT"))
                                ItemInfo[RESPAWN][AMOUNT] = str_to_num(szValue)
                        }
                    }
                }
            }
            
        }
        fclose(iFile)
    }
}
bool:is_eos_line(szString[]) return szString[0] == EOS ? true : false
bool:hud_dhud(szString[]) return szString[0] == 'd' ? true : false
bool:on_off(szString[]) return szString[1] == 'n' ? true : false

public _get_user_bm_points(iPlugin, iParams)
{
    new id = get_param(1)
    
    if (!is_user_connected(id))
        return -1
    
    return g_iPoints[id]
}

public _set_user_bm_points(iPlugin, iParams)
{
    new id = get_param(1)
    
    if (!is_user_connected(id))
        return false
    
    g_iPoints[id] = get_param(2)
    return true
}

public HudEntity(iEnt)
{
    static iPlayers[32], iNum, id, szHostName[64]
    get_players(iPlayers, iNum, "ch")
    
    for (new i = 0; i < iNum; i++)
    {
        id = iPlayers[i]
        
        if (!is_user_connected(id) || !is_user_alive(id))
            continue
        
        get_user_name(0, szHostName, charsmax(szHostName))
        
        if (!g_eItems[D_HUD_MESSAGE])
        {
            if (g_eItems[D_HUD_CUSTOM_COLOR])
                set_hudmessage(g_eItems[RED_COLOR], g_eItems[GREEN_COLOR], g_eItems[BLUE_COLOR], g_eItems[COORD_X], g_eItems[COORD_Y], 0, 0.8, 0.8)
            else
                set_hudmessage(random(256), random(256), random(256), g_eItems[COORD_X], g_eItems[COORD_Y], 0, 0.8, 0.8)
            
            if(get_cvar_num("mp_timelimit")) 
            {
                ShowSyncHudMsg(id, g_iSyncMessage, "%L", id, "D_HUD_MESSAGE_TIMELEFT",
                get_user_health(id), g_iPoints[id], hnsxp_get_user_xp(id), szHostName, (get_timeleft( ) / 60), (get_timeleft() % 60))
            }
            else 
            {
                ShowSyncHudMsg(id, g_iSyncMessage, "%L", id, "D_HUD_MESSAGE_NO_TIMELEFT",
                get_user_health(id), get_user_armor(id), g_iPoints[id], hnsxp_get_user_xp(id), szHostName)
            }
        }
        else if (g_eItems[D_HUD_MESSAGE])
        {
            if (g_eItems[D_HUD_CUSTOM_COLOR])
                set_dhudmessage(g_eItems[RED_COLOR], g_eItems[GREEN_COLOR], g_eItems[BLUE_COLOR], g_eItems[COORD_X], g_eItems[COORD_Y], 0, 0.8, 0.8)
            else
                set_dhudmessage(random(256), random(256), random(256), g_eItems[COORD_X], g_eItems[COORD_Y], 0, 0.8, 0.8)
                
            if(get_cvar_num("mp_timelimit")) 
            {
                show_dhudmessage(id, "%L", id, "D_HUD_MESSAGE_TIMELEFT",
                get_user_health(id), g_iPoints[id], hnsxp_get_user_xp(id), szHostName, (get_timeleft( ) / 60), (get_timeleft() % 60))
            }
            else 
            {
                show_dhudmessage(id, "%L", id, "D_HUD_MESSAGE_NO_TIMELEFT",
                get_user_health(id), get_user_armor(id), g_iPoints[id], hnsxp_get_user_xp(id), szHostName)
            }
        }
    }
    entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 0.5)
}

public client_putinserver(id)
{
    for (new i = 0; i < sizeof(szItemNames); i++)
    {
        g_IsBought[id][i] = false
        g_ItemsLimit[id][i] = 0
    }
    
    g_bNoFlash[id] = false
    remove_user_immune(id)
    
    new szName[32]
    get_user_name(id, szName, charsmax(szName))
    
    set_task(0.1, "LoadData", id, szName, charsmax(szName))
}

public client_disconnected(id)
{
    for (new i = 0; i < sizeof(szItemNames); i++)
    {
        g_IsBought[id][i] = false
        g_ItemsLimit[id][i] = 0
    }
    
    g_bNoFlash[id] = false
    remove_user_immune(id)
    
    if (g_bConnected[id])
    {
        new szName[32]
        get_user_name(id, szName, charsmax(szName))
        
        SaveData(id, szName)
        
        g_bConnected[id] = false
    }
}

public eventRoundStart()
{
    for (new i = 0; i < get_maxplayers(); i++)
    {
        for (new j = 0; j < Items; j++)
        {
            g_IsBought[i][j] = false
            g_ItemsLimit[i][j] = 0
        }
        remove_user_immune(i)
        g_bNoFlash[i] = false
    }
}

public eventDeathMsg()
{
    new iKiller = read_data(1)
    ,iVictim = read_data(2)
    ,iHeadShot = read_data(3)
    
    if (iKiller == iVictim || !is_user_connected(iKiller))
        return
    
    new szName[32]
    get_user_name(iKiller, szName, charsmax(szName))
    
    for (new i = 0; i < sizeof(szItemNames); i++)
        g_IsBought[iVictim][i] = false
    
    g_iPoints[iKiller] += iHeadShot == 1 ? g_eItems[HS_KILL_POINTS] : g_eItems[KILL_POINTS]
    
    if (g_bConnected[iKiller])
        SaveData(iKiller, szName)
}

public Command_HookSay(id)
{
    new szArgs[64], szCommand[32], szUser[32], szAmount[8]
    read_args(szArgs, charsmax(szArgs))
    remove_quotes(szArgs)
    parse(szArgs, szCommand, charsmax(szCommand), szUser, charsmax(szUser), szAmount, charsmax(szAmount))
    
    if (equal(szCommand, "/points"))
    {
        if (szUser[0] == EOS)
        {
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "YOUR_POINTS", g_eItems[SHOP_PREFIX], g_iPoints[id])
            return PLUGIN_HANDLED
        }
        else
        {
            new iTarget = cmd_target(id, szUser, 0)
            
            if (!iTarget)
            {
                PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NOT_FOUND",g_eItems[SHOP_PREFIX])
                return PLUGIN_HANDLED
            }
            
            new szName[32]
            get_user_name(iTarget, szName, charsmax(szName))
            
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "TARGET_POINTS", g_eItems[SHOP_PREFIX], szName, g_iPoints[iTarget])
            return PLUGIN_HANDLED
        }
    }
    else if (equal(szCommand, "/shopmenu"))
    {
        if (get_user_flags(id) & ADMIN_BAN)
            ToggleShopMenu(id)
        else
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NO_ACCESS", g_eItems[SHOP_PREFIX])
        
        return PLUGIN_HANDLED
    }
    else if (equal(szCommand, "/give"))
    {
        if (szUser[0] == EOS || szAmount[0] == EOS)
        {
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "USAGE_GIVE", g_eItems[SHOP_PREFIX])
            return PLUGIN_HANDLED
        }
        
        new iAmount = str_to_num(szAmount)
        
        if (iAmount <= 0)
        {
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "ONLY_POSITIVE", g_eItems[SHOP_PREFIX])
            return PLUGIN_HANDLED
        }
        
        new iTarget = cmd_target(id, szUser, 0)
        
        if (!iTarget)
        {
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NOT_FOUND", g_eItems[SHOP_PREFIX])
            return PLUGIN_HANDLED
        }
        
        if (iTarget == id)
        {
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "CANT_GIVE_TO_YOURSELF", g_eItems[SHOP_PREFIX])
            return PLUGIN_HANDLED
        }
            
        if (iAmount > g_iPoints[id])
            iAmount = g_iPoints[id]
        
        new szName[2][32]
        get_user_name(id, szName[0], charsmax(szName[]))
        get_user_name(iTarget, szName[1], charsmax(szName[]))
        
        g_iPoints[id] -= iAmount
        g_iPoints[iTarget] += iAmount
        
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "POINTS_GAVE", g_eItems[SHOP_PREFIX], iAmount, szName[1])
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "POINTS_RECEIVE", g_eItems[SHOP_PREFIX], szName[0], iAmount)
        
        return PLUGIN_HANDLED
    }
    
    return PLUGIN_CONTINUE
}
public Command_Shop(id)
{
    if (cs_get_user_team(id) == CS_TEAM_T)
        OpenItemShop(id)
    else
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "MUST_BE_TERROR", g_eItems[SHOP_PREFIX])
            
    return PLUGIN_HANDLED
}
public OpenItemShop(id)
{
    static szTitle[128]
    formatex(szTitle, charsmax(szTitle), "%L", id, "ITEM_SHOP_MENU_NAME", g_eItems[SHOP_MENU_PREFIX], g_iPoints[id])
    new iMenu = menu_create(szTitle, "shop_handler")
    
    for (new i = 0; i < sizeof(szItemNames); i++)
    {
        new szItem[128]
        
        if (i == HEALTH || i == ARMOR || i == XP)
        {
            formatex(szItem, charsmax(szItem), "%L", id, "HP_AP_XP_SHOP_ITEMS", g_ItemsLimit[id][i] >= ItemInfo[i][LIMIT] ? "\d" : "\w",
            ItemInfo[i][AMOUNT], szItemNames[i], ItemInfo[i][PRICE],
            g_ItemsLimit[id][i] >= ItemInfo[i][LIMIT] ? "\r" : "\d", g_ItemsLimit[id][i], ItemInfo[i][LIMIT])
        }
        else
        {
            formatex(szItem, charsmax(szItem), "%L", id, "ALL_OTHER_ITEMS", g_ItemsLimit[id][i] >= ItemInfo[i][LIMIT] ? "\d" : "\w",
            szItemNames[i], ItemInfo[i][PRICE],
            g_ItemsLimit[id][i] >= ItemInfo[i][LIMIT] ? "\r" : "\d", g_ItemsLimit[id][i], ItemInfo[i][LIMIT])
        }
        menu_additem(iMenu, szItem)
    }
    menu_display(id, iMenu)
    return PLUGIN_HANDLED
}

public shop_handler(id, iMenu, Item)
{
    if (!is_user_connected(id))
        goto Handled
    
    if (Item == MENU_EXIT)
    {
        menu_cancel(id)
        goto Handled
    }
    
    if (g_iPoints[id] < ItemInfo[Item][PRICE])
    {
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NO_MONEY", g_eItems[SHOP_PREFIX])
        menu_destroy(iMenu)
        goto Handled
    }
    
    if (g_ItemsLimit[id][Item] >= ItemInfo[Item][LIMIT])
    {
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "MAX_BUYS", g_eItems[SHOP_PREFIX])
        menu_destroy(iMenu)
        goto Handled
    }
    
    if (!is_user_alive(id) && Item != RESPAWN)
    {
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NOT_ALIVE", g_eItems[SHOP_PREFIX])
        menu_destroy(iMenu)
        goto Handled
    }
    
    switch (Item)
    {
        case HEALTH: fm_set_user_health(id, get_user_health(id) + ItemInfo[HEALTH][AMOUNT])
        case ARMOR: fm_set_user_armor(id, get_user_armor(id) + ItemInfo[ARMOR][AMOUNT])
        case HE_NADE:
        {
            if (!user_has_weapon(id, CSW_HEGRENADE))
                fm_give_item(id, "weapon_hegrenade")
            else
            {
                fm_give_item(id, "weapon_hegrenade")
                cs_set_user_bpammo(id, CSW_HEGRENADE, cs_get_user_bpammo(id, CSW_HEGRENADE) + ItemInfo[HE_NADE][AMOUNT])
            }
        }
        case NO_FROST: add_user_immune(id)
        case NO_FLASH: g_bNoFlash[id] = true
        case AWP:
        {
            new iWeapon = fm_give_item(id, "weapon_awp")
            
            if (pev_valid(iWeapon))
            {
                cs_set_weapon_ammo(iWeapon, ItemInfo[AWP][AMOUNT])
            }
        }
        case M3:
        {
            new iWeapon = fm_give_item(id, "weapon_m3")
            
            if (pev_valid(iWeapon))
            {
                cs_set_weapon_ammo(iWeapon, ItemInfo[M3][AMOUNT])
            }
        }
        case DEAGLE:
        {
            new iWeapon = fm_give_item(id, "weapon_deagle")
            
            if (pev_valid(iWeapon))
            {
                cs_set_weapon_ammo(iWeapon, ItemInfo[DEAGLE][AMOUNT])
            }
        }
        case XP: hnsxp_add_user_xp(id, ItemInfo[XP][AMOUNT])
        case RESPAWN:
        {
            if (is_user_alive(id))
            {
                PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "RESPAWN_ALIVE", g_eItems[SHOP_PREFIX])
                return PLUGIN_CONTINUE
            }
            ExecuteHamB(Ham_CS_RoundRespawn, id)
        }
    }
    
    g_iPoints[id] -= ItemInfo[Item][PRICE]
    g_ItemsLimit[id][Item]++
    g_IsBought[id][Item] = true
    
    if (Item == HEALTH || Item == ARMOR || Item == XP)
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "HP_AP_XP_SHOP_ITEMS_CHAT", g_eItems[SHOP_PREFIX], ItemInfo[Item][AMOUNT], szItemNames[Item], ItemInfo[Item][PRICE])
    else
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "ALL_OTHER_ITEMS_CHAT", g_eItems[SHOP_PREFIX], szItemNames[Item], ItemInfo[Item][PRICE])
        
    menu_destroy(iMenu)
    
    Handled:
    return PLUGIN_HANDLED
}

// Anti-Flash - Start
public flash()
{
    new Float:flGameTime = get_gametime()
    
    if (flGameTime - g_flGameTime[1] > 2.5)
    {
        for (new i = 0; i < 32; i++)
            g_iGrenade[i] = 0
    }
}

public eventFlash(id)
{
    new Float:flGameTime = get_gametime()
    
    if (flGameTime != g_flGameTime[0])
    {
        g_iOwner = get_grenade_owner()
        g_flGameTime[0] = flGameTime
        
        for (new i = 0; i < 32; i++)
            g_iTrack[i] = false
            
        g_iTrackEnemy = false
    }
    if (is_user_connected(g_iOwner) && g_bNoFlash[id])
    {
        g_iTrackEnemy = true
        
        message_begin(MSG_ONE, g_iMsgScreenFade, {0,0,0}, id)
        write_short(1)
        write_short(1)
        write_short(1)
        write_byte(0)
        write_byte(0)
        write_byte(0)
        write_byte(255)
        message_end()
    }
}
public flash_delay()
{
    if (!g_iTrackEnemy)
    {
        for (new i = 0; i < 33; i++)
        {
            if (g_iTrack[i] && is_user_connected(i))
            {
                message_begin(MSG_ONE, g_iMsgScreenFade, {0,0,0}, i) 
                write_short(1)
                write_short(1)
                write_short(1)
                write_byte(0)
                write_byte(0)
                write_byte(0)
                write_byte(255)
                message_end()
            }
        }
    }
}

public grenade_throw()
{
    if (g_iSyncData == 0)
        goto Continue
        
    g_iSyncData--
    
    if (read_datanum() < 2)
        return PLUGIN_HANDLED_MAIN
        
    if (read_data(1) == 11 && (read_data(2) == 0 || read_data(2) == 1))
        add_grenade_owner(g_iLast)
    
    Continue:
    return PLUGIN_CONTINUE
}
public fire_in_the_hole()
{
    new szName[32]
    read_data(3, szName, charsmax(szName))
    
    new iTempLast = get_user_index(szName)
    new iJunk
    
    if ((iTempLast == 0) || (!is_user_connected(iTempLast)))
        goto Continue
    
    if (get_user_weapon(iTempLast, iJunk, iJunk) == CSW_FLASHBANG)
    {
        g_iLast  =iTempLast
        g_iSyncData = 2
    }
    
    Continue:
    return PLUGIN_CONTINUE
}

public fire_in_the_hole2()
{
    new szName[32]
    read_data(4, szName, charsmax(szName))
    
    new iTempLast = get_user_index(szName)
    new iJunk
    
    if ((iTempLast == 0) || (!is_user_connected(iTempLast)))
        goto Continue
    
    if (get_user_weapon(iTempLast, iJunk, iJunk) == CSW_FLASHBANG)
    {
        g_iLast  =iTempLast
        g_iSyncData = 2
    }
    
    Continue:
    return PLUGIN_CONTINUE
}
add_grenade_owner(iOwner)
{
    new Float:flGameTime = get_gametime()
    
    g_flGameTime[1] = flGameTime
    
    for (new i = 0; i < 32; i++)
    {
        if (g_iGrenade[i] == 0)
        {
            g_iGrenade[i] = iOwner
            return
        }
    }
}
get_grenade_owner()
{
    new iWhich = g_iGrenade[0]
    
    for (new i = 1; i < 32; i++)
        g_iGrenade[i-1] = g_iGrenade[i]
    
    g_iGrenade[31] = 0
    return iWhich
}

public fw_emitsound(entity, channel, const szSample[], Float:volume, Float:attenuation, fFlags, pitch)
{
    if(!equali(szSample,"weapons/flashbang-1.wav") && !equali(szSample,"weapons/flashbang-2.wav"))
        goto Ignored
    
    new Float:flGameTime = get_gametime()
    
    if(flGameTime != g_flGameTime[0])
    {
        g_iOwner = get_grenade_owner()
        goto Ignored
    }
    
    Ignored:
    return FMRES_IGNORED;
}

/* ================================================
    Shop Points Menu
================================================ */
new g_iPlayer[33], g_iMenuType[33]

public ToggleShopMenu(id)
{
    static szTitle[64]
    formatex(szTitle, charsmax(szTitle), "%s \d~ \wShop Admin Menu", g_eItems[SHOP_MENU_PREFIX])
    new iMenu = menu_create(szTitle, "shopmenu_handler")
    
    menu_additem(iMenu, "\yGive \dPlayer \rBM Points")
    menu_additem(iMenu, "\yTake \dPlayer \rBM Points^n")
    
    menu_setprop(iMenu, MPROP_NUMBER_COLOR, "\w")
    menu_setprop(iMenu, MPROP_EXITNAME, "\yExit \rShop \dAdmin \rMenu\d..")
    menu_display(id, iMenu, 0)
    return PLUGIN_HANDLED
}
public shopmenu_handler(id, iMenu, Item)
{
    if (Item == MENU_EXIT)
    {
        menu_destroy(iMenu)
        goto Handled
    }
    
    switch(Item)
    {
        case 0: PlayerPointsMenu(id, 1)
        case 1: PlayerPointsMenu(id, 2)
    }
    
    menu_destroy(iMenu)
    Handled:
    return PLUGIN_HANDLED
}

public PlayerPointsMenu(id, iType)
{
    static szTitle[64]
    formatex(szTitle, charsmax(szTitle), "Choose Player to %s XP", iType == 1 ? "Give" : "Take")
    new iMenu = menu_create(szTitle, "points_handler")
    
    g_iMenuType[id] = iType
    
    new iPlayers[32], iNum, iPlayer
    new szName[34], szTempID[10]
    get_players(iPlayers, iNum)
    
    for(new i; i < iNum; i++)
    {
        iPlayer = iPlayers[i]
        if(!is_user_connected(iPlayer))
            continue
        
        get_user_name(iPlayer, szName, sizeof szName - 1)
        num_to_str(iPlayer, szTempID, charsmax(szTempID))
        menu_additem(iMenu, szName, szTempID)
    }
    menu_setprop(iMenu, MPROP_EXITNAME, "Go back..")
    menu_display(id, iMenu, 0)
    return PLUGIN_HANDLED
}
public points_handler(id, iMenu, Item)
{
    if (Item == MENU_EXIT)
    {
        ToggleShopMenu(id)
        g_iMenuType[id] = 0
        goto Handled
    }
    
    new szData[6], iName[64], iAccess, iCallBack
    menu_item_getinfo(iMenu, Item, iAccess, szData, charsmax(szData), iName, charsmax(iName), iCallBack)
    
    g_iPlayer[id] = str_to_num(szData)
    
    if (!is_user_connected(g_iPlayer[id]))
    {
        g_iPlayer[id] = 0
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NOT_IN_SERVER", g_eItems[SHOP_PREFIX])
        goto Handled
    }
    
    PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "TARGET_POINTS", g_eItems[SHOP_PREFIX], iName, g_iPoints[g_iPlayer[id]])
    
    client_cmd(id, "messagemode BM_Points_Amount")
    menu_destroy(iMenu)
    Handled:
    return PLUGIN_HANDLED
}
public Command_BM_Points_Amount(id, level, cid)
{
    if (!cmd_access(id, level, cid, 1))
        goto Handled
        
    if (!g_iPlayer[id])
        goto Handled
        
    if (!is_user_connected(g_iPlayer[id]))
    {
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NOT_IN_SERVER", g_eItems[SHOP_PREFIX])
        goto Handled
    }
    
    new szArgs[12]
    read_argv(1, szArgs, charsmax(szArgs))
    
    new iBM_Points = str_to_num(szArgs)
    
    new szNames[2][32]
    get_user_name(id, szNames[0], charsmax(szNames[]))
    get_user_name(g_iPlayer[id], szNames[1], charsmax(szNames[]))
    
    switch (g_iMenuType[id])
    {
        case 1:
        {
            g_iPoints[g_iPlayer[id]] += iBM_Points
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "ADMIN_GAVE", g_eItems[SHOP_PREFIX], szNames[0], iBM_Points, szNames[1])
        }
        case 2:
        {
            g_iPoints[g_iPlayer[id]] -= iBM_Points
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "ADMIN_TAKE", g_eItems[SHOP_PREFIX], szNames[0], iBM_Points, szNames[1])
        }
    }
    g_iPlayer[id] = 0
    g_iMenuType[id] = 0
    
    ToggleShopMenu(id)
    
    Handled:
    return PLUGIN_HANDLED
}
public client_infochanged(id)
{
    if (!is_user_connected(id))
        goto Handled
    
    new szNewName[32], szOldName[32]
    get_user_name(id, szOldName, charsmax(szOldName))
    get_user_info(id, "name", szNewName, charsmax(szNewName))
    
    if (!equal(szNewName, szOldName))
    {
        SaveData(id, szOldName)
        set_task(0.1, "LoadData", id, szNewName, charsmax(szNewName))
        goto Handled
    }
    
    Handled:
    return PLUGIN_HANDLED
}
public SaveData(id, szName[])
{
    new szData[18]
    num_to_str(g_iPoints[id], szData, charsmax(szData))
    
    fvault_set_data(BM_ItemShopDB, szName, szData)
}

public LoadData(szName[], id)
{
    new szData[18]
    
    if (fvault_get_data(BM_ItemShopDB, szName, szData, charsmax(szData)))
        g_iPoints[id] = str_to_num(szData)
    else
        g_iPoints[id] = 0
    
    g_bConnected[id] = true
}
 
Mobile Legends BANG BANG!
- Nick: Marksman <GX>
- Add me for RANKS
!

Аватар
JustInCase
Извън линия
Потребител
Потребител
Мнения: 582
Регистриран на: 14 Окт 2016, 23:31
Се отблагодари: 4 пъти
Получена благодарност: 15 пъти

Re: Преработка на плъгини [BM System #3]

Мнение от JustInCase » 13 Юни 2017, 13:39

Код за потвърждение: Избери целия код

/*==================================================================================================

|**********************************|
|==================================|
|=     BlockMaker Item Shop     =|
|==================================|
|**********************************|

|= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =|
|                                                   |
|                                                   |
|            Copyright © 2017-2018, AJW1337//                        |
|            This file is provided as is (no warranties)                    |
|                                                   |
|            BlockMaker Item Shop is free software;                          |
|            you can redistribute it and/or modify it under the terms of the        |
|            GNU General Public License as published by the Free Software Foundation.   |
|                                                   |    
|            This program is distributed in the hope that it will be useful,            |
|            but WITHOUT ANY WARRANTY; without even the implied warranty of             |
|            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                |
|                                                   |
|                                                   |
|            Plugin requested by Coca Cola _-FxF-_                       |
|                                                   |
|= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =| 
|---------------|
|   Changelog   |
|---------------|
v1.0 Official Plugin Release

==================================================================================================*/

#include <amxmodx>
#include <amxmisc>
#include <fakemeta_util>
#include <fvault>
#include <WPMGPrintChatColor>
#include <hamsandwich>
#include <engine>

#if AMXX_VERSION_NUM < 183
#include <dhudmessage>
#define client_disconnected client_disconnect
#endif

native add_user_immune(id)
    native remove_user_immune(id)
    
native hnsxp_get_user_xp(id)
    native hnsxp_set_user_xp(id, iExp)
    
stock hnsxp_add_user_xp(id, iExp)
    return hnsxp_set_user_xp(id, hnsxp_get_user_xp(id) + iExp)


new const PLUGIN[] = "BlockMaker Item Shop"
new const VERSION[] = "1.0"
new const AUTHOR[] = "AJW1337//"
new const BM_ItemShopDB[] = "BM_ItemShop_DataBase"

enum _:Info {
    PRICE = 0,
    LIMIT,
    AMOUNT
}

enum _:Items {
    HEALTH,
    ARMOR,
    HE_NADE,
    NO_FROST,
    NO_FLASH,
    AWP,
    M3,
    DEAGLE,
    XP,
    RESPAWN
}

new const szItemNames[Items][] ={
    "Health",
    "Armor",
    "HE Grenade",
    "Anti Frost",
    "Anti Flash",
    "AWP",
    "M3",
    "Deagle",
    "XP",
    "Respawn"
}

new ItemInfo[Items][Info], g_ItemsLimit[33][Items], bool:g_IsBought[33][Items]
new g_iPoints[33], bool:g_bConnected[33]
new g_iSyncMessage

// For Anti Flash
new Float:g_flGameTime[2], g_iOwner
new g_iGrenade[32], bool:g_iTrackEnemy, bool:g_iTrack[33]
new g_iMsgScreenFade, g_iLast, g_iSyncData
new g_bNoFlash[33]
// For Anti Flash

enum {
    SECTION_SHOP = 1,
    SECTION_PRICE,
    SECTION_LIMIT,
    SECTION_AMOUNT
}

enum _:DataItems {
    SHOP_PREFIX[32],
    SHOP_MENU_PREFIX[32],
    SHOP_COMMAND[32],
    HS_KILL_POINTS,
    KILL_POINTS,
    PRINT_COLOR,
    D_HUD_MESSAGE,
    D_HUD_CUSTOM_COLOR,
    RED_COLOR,
    GREEN_COLOR,
    BLUE_COLOR,
    Float:COORD_X,
    Float:COORD_Y
}

new g_eItems[DataItems]

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_cvar("BM_ItemShop", VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
    
    register_dictionary("blockmaker_itemshop.txt")
    
    register_clcmd("say", "Command_HookSay")
    register_clcmd("say_team", "Command_HookSay")
    
    register_concmd("amx_reload_file", "Command_ReloadFile", ADMIN_BAN)
    
    register_clcmd("BM_Points_Amount", "Command_BM_Points_Amount", ADMIN_BAN)
    
    register_event("DeathMsg", "eventDeathMsg", "a")
    register_logevent("eventRoundStart", 2, "1=Round_Start")
    
    register_event("ScreenFade", "eventFlash", "be", "4=255", "5=255", "6=255", "7>199")
    register_event("TextMsg", "fire_in_the_hole", "b", "2&#Game_radio", "4&#Fire_in_the_hole")
    register_event("TextMsg", "fire_in_the_hole2", "b", "3&#Game_radio", "5&#Fire_in_the_hole")
    register_event("99", "grenade_throw", "b")
    set_task(2.0, "flash", .flags="b")
    g_iMsgScreenFade = get_user_msgid("ScreenFade")
    
    new iEnt = create_entity("info_target")
    entity_set_string(iEnt, EV_SZ_classname, "task_entity")
    
    register_think("task_entity", "HudEntity")
    entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 2.0)
    
    g_iSyncMessage = CreateHudSyncObj()
    
    ReadFile()
}
public plugin_natives()
{
    register_native("get_user_bm_points", "_get_user_bm_points")
    register_native("set_user_bm_points", "_set_user_bm_points")
}
public Command_ReloadFile(id, level, cid)
{
    if (!cmd_access(id, level, cid, 1))
        goto Handled
    
    ReadFile()
    
    Handled:
    return PLUGIN_HANDLED
}
ReadFile()
{
static szConfigsDir[64], iFile
get_configsdir(szConfigsDir, charsmax(szConfigsDir))
add(szConfigsDir, charsmax(szConfigsDir), "/BM_ItemShop.ini")
iFile = fopen(szConfigsDir, "rt")

if (iFile)
{
    static szLineData[160], szKey[32], szValue[128], iSection
    
    while (!feof(iFile))
    {
        fgets(iFile, szLineData, charsmax(szLineData))
        trim(szLineData)
        
        switch (szLineData[0])
        {
            case EOS, ';': continue
                case '[':
                {
                    if (szLineData[strlen(szLineData) -1] == ']')
                    {
                        if (containi(szLineData, "item shop") != -1)
                            iSection = SECTION_SHOP
                        else if (containi(szLineData, "item prices") != -1)
                            iSection = SECTION_PRICE
                        else if (containi(szLineData, "item limits") != -1)
                            iSection = SECTION_LIMIT
                        else if (containi(szLineData, "item amounts") != -1)
                            iSection = SECTION_AMOUNT
                    }                    
                    else
                        continue
                }
                default:
            {
                strtok(szLineData, szKey, charsmax(szKey), szValue, charsmax(szValue), '=')
                trim(szKey)
                trim(szValue)
                
                if (is_eos_line(szValue))
                    continue
                    
                    switch(iSection)
                    {
                        case SECTION_SHOP:
                        {
                            if (equal(szKey, "BM_SHOP_COMMANDS"))
                            {
                                while (szValue[0] != 0 && strtok(szValue, szKey, charsmax(szKey), szValue, charsmax(szValue), ','))
                                {
                                    trim(szKey)
                                    trim(szValue)
                                    register_clcmd(szKey, "Command_Shop")
                                }
                            }
                            else if (equal(szKey, "BM_SHOP_PRINT_COLOR"))
                                g_eItems[PRINT_COLOR] = str_to_num(szValue)
                            else if (equal(szKey, "BM_SHOP_PREFIX"))
                                copy(g_eItems[SHOP_PREFIX], charsmax(g_eItems[SHOP_PREFIX]), szValue)
                            else if (equal(szKey, "BM_SHOP_MENU_PREFIX"))
                                copy(g_eItems[SHOP_MENU_PREFIX], charsmax(g_eItems[SHOP_MENU_PREFIX]), szValue)
                            else if (equal(szKey, "BM_SHOP_HEADSHOT_KILL_POINTS"))
                                g_eItems[HS_KILL_POINTS] = str_to_num(szValue)
                            else if (equal(szKey, "BM_SHOP_NORMAL_KILL_POINTS"))
                                g_eItems[KILL_POINTS] = str_to_num(szValue)
                            else if (equal(szKey, "BM_SHOP_D_HUD_MESSAGE"))
                                g_eItems[D_HUD_MESSAGE] = clamp(hud_dhud(szValue), false, true)
                            else if (equal(szKey, "BM_SHOP_D_HUD_CUSTOM_COLOR"))
                                g_eItems[D_HUD_CUSTOM_COLOR] = clamp(on_off(szValue), false, true)
                            else if (equal(szKey, "BM_SHOP_D_HUD_RED_COLOR"))
                                g_eItems[RED_COLOR] = clamp(str_to_num(szValue), 0, 255)
                            else if (equal(szKey, "BM_SHOP_D_HUD_GREEN_COLOR"))
                                g_eItems[GREEN_COLOR] = clamp(str_to_num(szValue), 0, 255)
                            else if (equal(szKey, "BM_SHOP_D_HUD_BLUE_COLOR"))
                                g_eItems[BLUE_COLOR] = clamp(str_to_num(szValue), 0, 255)
                            else if (equal(szKey, "BM_SHOP_D_HUD_COORD_X"))
                                g_eItems[COORD_X] = _:str_to_float(szValue)
                            else if (equal(szKey, "BM_SHOP_D_HUD_COORD_Y"))
                                g_eItems[COORD_Y] = _:str_to_float(szValue)
                        }
                        case SECTION_PRICE:
                        {
                            if (equal(szKey, "BM_HEALTH_PRICE"))
                                ItemInfo[HEALTH][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ARMOR_PRICE"))
                                ItemInfo[ARMOR][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_HE_GRENADE_PRICE"))
                                ItemInfo[HE_NADE][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ANTI_FROST_PRICE"))
                                ItemInfo[NO_FROST][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ANTI_FLASH_PRICE"))
                                ItemInfo[NO_FLASH][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_AWP_PRICE"))
                                ItemInfo[AWP][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_M3_PRICE"))
                                ItemInfo[M3][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_DEAGLE_PRICE"))
                                ItemInfo[DEAGLE][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_XP_PRICE"))
                                ItemInfo[XP][PRICE] = str_to_num(szValue)
                            else if (equal(szKey, "BM_RESPAWN_PRICE"))
                                ItemInfo[RESPAWN][PRICE] = str_to_num(szValue)
                        }
                        case SECTION_LIMIT:
                        {
                            if (equal(szKey, "BM_HEALTH_LIMIT"))
                                ItemInfo[HEALTH][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ARMOR_LIMIT"))
                                ItemInfo[ARMOR][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_HE_GRENADE_LIMIT"))
                                ItemInfo[HE_NADE][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ANTI_FROST_LIMIT"))
                                ItemInfo[NO_FROST][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ANTI_FLASH_LIMIT"))
                                ItemInfo[NO_FLASH][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_AWP_LIMIT"))
                                ItemInfo[AWP][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_M3_LIMIT"))
                                ItemInfo[M3][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_DEAGLE_LIMIT"))
                                ItemInfo[DEAGLE][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_XP_LIMIT"))
                                ItemInfo[XP][LIMIT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_RESPAWN_LIMIT"))
                                ItemInfo[RESPAWN][LIMIT] = str_to_num(szValue)
                        }
                        case SECTION_AMOUNT:
                        {
                            if (equal(szKey, "BM_HEALTH_AMOUNT"))
                                ItemInfo[HEALTH][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ARMOR_AMOUNT"))
                                ItemInfo[ARMOR][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_HE_GRENADE_AMOUNT"))
                                ItemInfo[HE_NADE][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ANTI_FROST_AMOUNT"))
                                ItemInfo[NO_FROST][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_ANTI_FLASH_AMOUNT"))
                                ItemInfo[NO_FLASH][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_AWP_AMOUNT"))
                                ItemInfo[AWP][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_M3_AMOUNT"))
                                ItemInfo[M3][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_DEAGLE_AMOUNT"))
                                ItemInfo[DEAGLE][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_XP_AMOUNT"))
                                ItemInfo[XP][AMOUNT] = str_to_num(szValue)
                            else if (equal(szKey, "BM_RESPAWN_AMOUNT"))
                                ItemInfo[RESPAWN][AMOUNT] = str_to_num(szValue)
                        }
                    }
                }
            }
            
        }
        fclose(iFile)
    }
}
bool:is_eos_line(szString[]) return szString[0] == EOS ? true : false
bool:hud_dhud(szString[]) return szString[0] == 'd' ? true : false
bool:on_off(szString[]) return szString[1] == 'n' ? true : false

public _get_user_bm_points(iPlugin, iParams)
{
    new id = get_param(1)
    
    if (!is_user_connected(id))
        return -1
    
    return g_iPoints[id]
}

public _set_user_bm_points(iPlugin, iParams)
{
    new id = get_param(1)
    
    if (!is_user_connected(id))
        return false
    
    g_iPoints[id] = get_param(2)
    return true
}

public HudEntity(iEnt)
{
    static iPlayers[32], iNum, id, szHostName[64]
    get_players(iPlayers, iNum, "ch")
    
    for (new i = 0; i < iNum; i++)
    {
        id = iPlayers[i]
        
        if (!is_user_connected(id) || !is_user_alive(id))
            continue
        
        get_user_name(0, szHostName, charsmax(szHostName))
        
        if (!g_eItems[D_HUD_MESSAGE])
        {
            if (g_eItems[D_HUD_CUSTOM_COLOR])
                set_hudmessage(g_eItems[RED_COLOR], g_eItems[GREEN_COLOR], g_eItems[BLUE_COLOR], g_eItems[COORD_X], g_eItems[COORD_Y], 0, 0.8, 0.8)
            else
                set_hudmessage(random(256), random(256), random(256), g_eItems[COORD_X], g_eItems[COORD_Y], 0, 0.8, 0.8)
            
            if(get_cvar_num("mp_timelimit")) 
            {
                ShowSyncHudMsg(id, g_iSyncMessage, "%L", id, "D_HUD_MESSAGE_TIMELEFT",
                get_user_health(id), g_iPoints[id], hnsxp_get_user_xp(id), szHostName, (get_timeleft( ) / 60), (get_timeleft() % 60))
            }
            else 
            {
                ShowSyncHudMsg(id, g_iSyncMessage, "%L", id, "D_HUD_MESSAGE_NO_TIMELEFT",
                get_user_health(id), get_user_armor(id), g_iPoints[id], hnsxp_get_user_xp(id), szHostName)
            }
        }
        else if (g_eItems[D_HUD_MESSAGE])
        {
            if (g_eItems[D_HUD_CUSTOM_COLOR])
                set_dhudmessage(g_eItems[RED_COLOR], g_eItems[GREEN_COLOR], g_eItems[BLUE_COLOR], g_eItems[COORD_X], g_eItems[COORD_Y], 0, 0.8, 0.8)
            else
                set_dhudmessage(random(256), random(256), random(256), g_eItems[COORD_X], g_eItems[COORD_Y], 0, 0.8, 0.8)
            
            if(get_cvar_num("mp_timelimit")) 
            {
                show_dhudmessage(id, "%L", id, "D_HUD_MESSAGE_TIMELEFT",
                get_user_health(id), g_iPoints[id], hnsxp_get_user_xp(id), szHostName, (get_timeleft( ) / 60), (get_timeleft() % 60))
            }
            else 
            {
                show_dhudmessage(id, "%L", id, "D_HUD_MESSAGE_NO_TIMELEFT",
                get_user_health(id), get_user_armor(id), g_iPoints[id], hnsxp_get_user_xp(id), szHostName)
            }
        }
    }
    entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 0.5)
}

public client_putinserver(id)
{
    for (new i = 0; i < sizeof(szItemNames); i++)
    {
        g_IsBought[id][i] = false
        g_ItemsLimit[id][i] = 0
    }
    
    g_bNoFlash[id] = false
    remove_user_immune(id)
    
    new szName[32]
    get_user_name(id, szName, charsmax(szName))
    
    set_task(0.1, "LoadData", id, szName, charsmax(szName))
}

public client_disconnected(id)
{
    for (new i = 0; i < sizeof(szItemNames); i++)
    {
        g_IsBought[id][i] = false
        g_ItemsLimit[id][i] = 0
    }
    
    g_bNoFlash[id] = false
    remove_user_immune(id)
    
    if (g_bConnected[id])
    {
        new szName[32]
        get_user_name(id, szName, charsmax(szName))
        
        SaveData(id, szName)
        
        g_bConnected[id] = false
    }
}

public eventRoundStart()
{
    for (new i = 0; i < get_maxplayers(); i++)
    {
        for (new j = 0; j < Items; j++)
        {
            g_IsBought[i][j] = false
            g_ItemsLimit[i][j] = 0
        }
        remove_user_immune(i)
        g_bNoFlash[i] = false
    }
}

public eventDeathMsg()
{
    new iKiller = read_data(1)
    ,iVictim = read_data(2)
    ,iHeadShot = read_data(3)
    
    if (iKiller == iVictim || !is_user_connected(iKiller))
        return
    
    new szName[32]
    get_user_name(iKiller, szName, charsmax(szName))
    
    for (new i = 0; i < sizeof(szItemNames); i++)
        g_IsBought[iVictim][i] = false
    
    g_iPoints[iKiller] += iHeadShot == 1 ? g_eItems[HS_KILL_POINTS] : g_eItems[KILL_POINTS]
    
    if (g_bConnected[iKiller])
        SaveData(iKiller, szName)
}

public Command_HookSay(id)
{
    new szArgs[64], szCommand[32], szUser[32], szAmount[8]
    read_args(szArgs, charsmax(szArgs))
    remove_quotes(szArgs)
    parse(szArgs, szCommand, charsmax(szCommand), szUser, charsmax(szUser), szAmount, charsmax(szAmount))
    
    if (equal(szCommand, "/points"))
    {
        if (szUser[0] == EOS)
        {
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "YOUR_POINTS", g_eItems[SHOP_PREFIX], g_iPoints[id])
            return PLUGIN_HANDLED
        }
        else
        {
            new iTarget = cmd_target(id, szUser, 0)
            
            if (!iTarget)
            {
                PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NOT_FOUND",g_eItems[SHOP_PREFIX])
                return PLUGIN_HANDLED
            }
            
            new szName[32]
            get_user_name(iTarget, szName, charsmax(szName))
            
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "TARGET_POINTS", g_eItems[SHOP_PREFIX], szName, g_iPoints[iTarget])
            return PLUGIN_HANDLED
        }
    }
    else if (equal(szCommand, "/shopmenu"))
    {
        if (get_user_flags(id) & ADMIN_BAN)
            ToggleShopMenu(id)
        else
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NO_ACCESS", g_eItems[SHOP_PREFIX])
        
        return PLUGIN_HANDLED
    }
    else if (equal(szCommand, "/give"))
    {
        if (szUser[0] == EOS || szAmount[0] == EOS)
        {
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "USAGE_GIVE", g_eItems[SHOP_PREFIX])
            return PLUGIN_HANDLED
        }
        
        new iAmount = str_to_num(szAmount)
        
        if (iAmount <= 0)
        {
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "ONLY_POSITIVE", g_eItems[SHOP_PREFIX])
            return PLUGIN_HANDLED
        }
        
        new iTarget = cmd_target(id, szUser, 0)
        
        if (!iTarget)
        {
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NOT_FOUND", g_eItems[SHOP_PREFIX])
            return PLUGIN_HANDLED
        }
        
        if (iTarget == id)
        {
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "CANT_GIVE_TO_YOURSELF", g_eItems[SHOP_PREFIX])
            return PLUGIN_HANDLED
        }
        
        if (iAmount > g_iPoints[id])
            iAmount = g_iPoints[id]
        
        new szName[2][32]
        get_user_name(id, szName[0], charsmax(szName[]))
        get_user_name(iTarget, szName[1], charsmax(szName[]))
        
        g_iPoints[id] -= iAmount
        g_iPoints[iTarget] += iAmount
        
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "POINTS_GAVE", g_eItems[SHOP_PREFIX], iAmount, szName[1])
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "POINTS_RECEIVE", g_eItems[SHOP_PREFIX], szName[0], iAmount)
        
        return PLUGIN_HANDLED
    }
    
    return PLUGIN_CONTINUE
}
public Command_Shop(id)
{
    if (cs_get_user_team(id) == CS_TEAM_CT)
        OpenItemShop(id)
    else
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "MUST_BE_TERROR", g_eItems[SHOP_PREFIX])
    
    return PLUGIN_HANDLED
}
public OpenItemShop(id)
{
    static szTitle[128]
    formatex(szTitle, charsmax(szTitle), "%L", id, "ITEM_SHOP_MENU_NAME", g_eItems[SHOP_MENU_PREFIX], g_iPoints[id])
    new iMenu = menu_create(szTitle, "shop_handler")
    
    for (new i = 0; i < sizeof(szItemNames); i++)
    {
        new szItem[128]
        
        if (i == HEALTH || i == ARMOR || i == XP)
        {
            formatex(szItem, charsmax(szItem), "%L", id, "HP_AP_XP_SHOP_ITEMS", g_ItemsLimit[id][i] >= ItemInfo[i][LIMIT] ? "\d" : "\w",
            ItemInfo[i][AMOUNT], szItemNames[i], ItemInfo[i][PRICE],
            g_ItemsLimit[id][i] >= ItemInfo[i][LIMIT] ? "\r" : "\d", g_ItemsLimit[id][i], ItemInfo[i][LIMIT])
        }
        else
        {
            formatex(szItem, charsmax(szItem), "%L", id, "ALL_OTHER_ITEMS", g_ItemsLimit[id][i] >= ItemInfo[i][LIMIT] ? "\d" : "\w",
            szItemNames[i], ItemInfo[i][PRICE],
            g_ItemsLimit[id][i] >= ItemInfo[i][LIMIT] ? "\r" : "\d", g_ItemsLimit[id][i], ItemInfo[i][LIMIT])
        }
        menu_additem(iMenu, szItem)
    }
    menu_display(id, iMenu)
    return PLUGIN_HANDLED
}

public shop_handler(id, iMenu, Item)
{
    if (!is_user_connected(id))
        goto Handled
    
    if (Item == MENU_EXIT)
    {
        menu_cancel(id)
        goto Handled
    }
    
    if (g_iPoints[id] < ItemInfo[Item][PRICE])
    {
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NO_MONEY", g_eItems[SHOP_PREFIX])
        menu_destroy(iMenu)
        goto Handled
    }
    
    if (g_ItemsLimit[id][Item] >= ItemInfo[Item][LIMIT])
    {
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "MAX_BUYS", g_eItems[SHOP_PREFIX])
        menu_destroy(iMenu)
        goto Handled
    }
    
    if (!is_user_alive(id) && Item != RESPAWN)
    {
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NOT_ALIVE", g_eItems[SHOP_PREFIX])
        menu_destroy(iMenu)
        goto Handled
    }
    
    switch (Item)
    {
        case HEALTH: fm_set_user_health(id, get_user_health(id) + ItemInfo[HEALTH][AMOUNT])
            case ARMOR: fm_set_user_armor(id, get_user_armor(id) + ItemInfo[ARMOR][AMOUNT])
            case HE_NADE:
        {
            if (!user_has_weapon(id, CSW_HEGRENADE))
                fm_give_item(id, "weapon_hegrenade")
            else
            {
                fm_give_item(id, "weapon_hegrenade")
                cs_set_user_bpammo(id, CSW_HEGRENADE, cs_get_user_bpammo(id, CSW_HEGRENADE) + ItemInfo[HE_NADE][AMOUNT])
            }
        }
        case NO_FROST: add_user_immune(id)
            case NO_FLASH: g_bNoFlash[id] = true
            case AWP:
        {
            new iWeapon = fm_give_item(id, "weapon_awp")
            
            if (pev_valid(iWeapon))
            {
                cs_set_weapon_ammo(iWeapon, ItemInfo[AWP][AMOUNT])
            }
        }
        case M3:
        {
            new iWeapon = fm_give_item(id, "weapon_m3")
            
            if (pev_valid(iWeapon))
            {
                cs_set_weapon_ammo(iWeapon, ItemInfo[M3][AMOUNT])
            }
        }
        case DEAGLE:
        {
            new iWeapon = fm_give_item(id, "weapon_deagle")
            
            if (pev_valid(iWeapon))
            {
                cs_set_weapon_ammo(iWeapon, ItemInfo[DEAGLE][AMOUNT])
            }
        }
        case XP: hnsxp_add_user_xp(id, ItemInfo[XP][AMOUNT])
            case RESPAWN:
        {
            if (is_user_alive(id))
            {
                PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "RESPAWN_ALIVE", g_eItems[SHOP_PREFIX])
                return PLUGIN_CONTINUE
            }
            ExecuteHamB(Ham_CS_RoundRespawn, id)
        }
    }
    
    g_iPoints[id] -= ItemInfo[Item][PRICE]
    g_ItemsLimit[id][Item]++
    g_IsBought[id][Item] = true
    
    if (Item == HEALTH || Item == ARMOR || Item == XP)
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "HP_AP_XP_SHOP_ITEMS_CHAT", g_eItems[SHOP_PREFIX], ItemInfo[Item][AMOUNT], szItemNames[Item], ItemInfo[Item][PRICE])
    else
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "ALL_OTHER_ITEMS_CHAT", g_eItems[SHOP_PREFIX], szItemNames[Item], ItemInfo[Item][PRICE])
    
    menu_destroy(iMenu)
    
    Handled:
    return PLUGIN_HANDLED
}

// Anti-Flash - Start
public flash()
{
    new Float:flGameTime = get_gametime()
    
    if (flGameTime - g_flGameTime[1] > 2.5)
    {
        for (new i = 0; i < 32; i++)
            g_iGrenade[i] = 0
    }
}

public eventFlash(id)
{
    new Float:flGameTime = get_gametime()
    
    if (flGameTime != g_flGameTime[0])
    {
        g_iOwner = get_grenade_owner()
        g_flGameTime[0] = flGameTime
        
        for (new i = 0; i < 32; i++)
            g_iTrack[i] = false
        
        g_iTrackEnemy = false
    }
    if (is_user_connected(g_iOwner) && g_bNoFlash[id])
    {
        g_iTrackEnemy = true
        
        message_begin(MSG_ONE, g_iMsgScreenFade, {0,0,0}, id)
        write_short(1)
        write_short(1)
        write_short(1)
        write_byte(0)
        write_byte(0)
        write_byte(0)
        write_byte(255)
        message_end()
    }
}
public flash_delay()
{
    if (!g_iTrackEnemy)
    {
        for (new i = 0; i < 33; i++)
        {
            if (g_iTrack[i] && is_user_connected(i))
            {
                message_begin(MSG_ONE, g_iMsgScreenFade, {0,0,0}, i) 
                write_short(1)
                write_short(1)
                write_short(1)
                write_byte(0)
                write_byte(0)
                write_byte(0)
                write_byte(255)
                message_end()
            }
        }
    }
}

public grenade_throw()
{
    if (g_iSyncData == 0)
        goto Continue
    
    g_iSyncData--
    
    if (read_datanum() < 2)
        return PLUGIN_HANDLED_MAIN
    
    if (read_data(1) == 11 && (read_data(2) == 0 || read_data(2) == 1))
        add_grenade_owner(g_iLast)
    
    Continue:
    return PLUGIN_CONTINUE
}
public fire_in_the_hole()
{
    new szName[32]
    read_data(3, szName, charsmax(szName))
    
    new iTempLast = get_user_index(szName)
    new iJunk
    
    if ((iTempLast == 0) || (!is_user_connected(iTempLast)))
        goto Continue
    
    if (get_user_weapon(iTempLast, iJunk, iJunk) == CSW_FLASHBANG)
    {
        g_iLast  =iTempLast
        g_iSyncData = 2
    }
    
    Continue:
    return PLUGIN_CONTINUE
}

public fire_in_the_hole2()
{
    new szName[32]
    read_data(4, szName, charsmax(szName))
    
    new iTempLast = get_user_index(szName)
    new iJunk
    
    if ((iTempLast == 0) || (!is_user_connected(iTempLast)))
        goto Continue
    
    if (get_user_weapon(iTempLast, iJunk, iJunk) == CSW_FLASHBANG)
    {
        g_iLast  =iTempLast
        g_iSyncData = 2
    }
    
    Continue:
    return PLUGIN_CONTINUE
}
add_grenade_owner(iOwner)
{
new Float:flGameTime = get_gametime()

g_flGameTime[1] = flGameTime

for (new i = 0; i < 32; i++)
{
    if (g_iGrenade[i] == 0)
    {
        g_iGrenade[i] = iOwner
        return
    }
}
}
get_grenade_owner()
{
new iWhich = g_iGrenade[0]

for (new i = 1; i < 32; i++)
g_iGrenade[i-1] = g_iGrenade[i]

g_iGrenade[31] = 0
return iWhich
}

public fw_emitsound(entity, channel, const szSample[], Float:volume, Float:attenuation, fFlags, pitch)
{
if(!equali(szSample,"weapons/flashbang-1.wav") && !equali(szSample,"weapons/flashbang-2.wav"))
    goto Ignored
    
    new Float:flGameTime = get_gametime()
    
    if(flGameTime != g_flGameTime[0])
    {
        g_iOwner = get_grenade_owner()
        goto Ignored
    }
    
    Ignored:
    return FMRES_IGNORED;
}

/* ================================================
Shop Points Menu
================================================ */
new g_iPlayer[33], g_iMenuType[33]

public ToggleShopMenu(id)
{
    static szTitle[64]
    formatex(szTitle, charsmax(szTitle), "%s \d~ \wShop Admin Menu", g_eItems[SHOP_MENU_PREFIX])
    new iMenu = menu_create(szTitle, "shopmenu_handler")
    
    menu_additem(iMenu, "\yGive \dPlayer \rBM Points")
    menu_additem(iMenu, "\yTake \dPlayer \rBM Points^n")
    
    menu_setprop(iMenu, MPROP_NUMBER_COLOR, "\w")
    menu_setprop(iMenu, MPROP_EXITNAME, "\yExit \rShop \dAdmin \rMenu\d..")
    menu_display(id, iMenu, 0)
    return PLUGIN_HANDLED
}
public shopmenu_handler(id, iMenu, Item)
{
    if (Item == MENU_EXIT)
    {
        menu_destroy(iMenu)
        goto Handled
    }
    
    switch(Item)
    {
        case 0: PlayerPointsMenu(id, 1)
            case 1: PlayerPointsMenu(id, 2)
        }
    
    menu_destroy(iMenu)
    Handled:
    return PLUGIN_HANDLED
}

public PlayerPointsMenu(id, iType)
{
    static szTitle[64]
    formatex(szTitle, charsmax(szTitle), "Choose Player to %s XP", iType == 1 ? "Give" : "Take")
    new iMenu = menu_create(szTitle, "points_handler")
    
    g_iMenuType[id] = iType
    
    new iPlayers[32], iNum, iPlayer
    new szName[34], szTempID[10]
    get_players(iPlayers, iNum)
    
    for(new i; i < iNum; i++)
    {
        iPlayer = iPlayers[i]
        if(!is_user_connected(iPlayer))
            continue
        
        get_user_name(iPlayer, szName, sizeof szName - 1)
        num_to_str(iPlayer, szTempID, charsmax(szTempID))
        menu_additem(iMenu, szName, szTempID)
    }
    menu_setprop(iMenu, MPROP_EXITNAME, "Go back..")
    menu_display(id, iMenu, 0)
    return PLUGIN_HANDLED
}
public points_handler(id, iMenu, Item)
{
    if (Item == MENU_EXIT)
    {
        ToggleShopMenu(id)
        g_iMenuType[id] = 0
        goto Handled
    }
    
    new szData[6], iName[64], iAccess, iCallBack
    menu_item_getinfo(iMenu, Item, iAccess, szData, charsmax(szData), iName, charsmax(iName), iCallBack)
    
    g_iPlayer[id] = str_to_num(szData)
    
    if (!is_user_connected(g_iPlayer[id]))
    {
        g_iPlayer[id] = 0
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NOT_IN_SERVER", g_eItems[SHOP_PREFIX])
        goto Handled
    }
    
    PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "TARGET_POINTS", g_eItems[SHOP_PREFIX], iName, g_iPoints[g_iPlayer[id]])
    
    client_cmd(id, "messagemode BM_Points_Amount")
    menu_destroy(iMenu)
    Handled:
    return PLUGIN_HANDLED
}
public Command_BM_Points_Amount(id, level, cid)
{
    if (!cmd_access(id, level, cid, 1))
        goto Handled
    
    if (!g_iPlayer[id])
        goto Handled
    
    if (!is_user_connected(g_iPlayer[id]))
    {
        PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "NOT_IN_SERVER", g_eItems[SHOP_PREFIX])
        goto Handled
    }
    
    new szArgs[12]
    read_argv(1, szArgs, charsmax(szArgs))
    
    new iBM_Points = str_to_num(szArgs)
    
    new szNames[2][32]
    get_user_name(id, szNames[0], charsmax(szNames[]))
    get_user_name(g_iPlayer[id], szNames[1], charsmax(szNames[]))
    
    switch (g_iMenuType[id])
    {
        case 1:
        {
            g_iPoints[g_iPlayer[id]] += iBM_Points
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "ADMIN_GAVE", g_eItems[SHOP_PREFIX], szNames[0], iBM_Points, szNames[1])
        }
        case 2:
        {
            g_iPoints[g_iPlayer[id]] -= iBM_Points
            PrintChatColor(id, g_eItems[PRINT_COLOR], "%L", id, "ADMIN_TAKE", g_eItems[SHOP_PREFIX], szNames[0], iBM_Points, szNames[1])
        }
    }
    g_iPlayer[id] = 0
    g_iMenuType[id] = 0
    
    ToggleShopMenu(id)
    
    Handled:
    return PLUGIN_HANDLED
}
public client_infochanged(id)
{
    if (!is_user_connected(id))
        goto Handled
    
    new szNewName[32], szOldName[32]
    get_user_name(id, szOldName, charsmax(szOldName))
    get_user_info(id, "name", szNewName, charsmax(szNewName))
    
    if (!equal(szNewName, szOldName))
    {
        SaveData(id, szOldName)
        set_task(0.1, "LoadData", id, szNewName, charsmax(szNewName))
        goto Handled
    }
    
    Handled:
    return PLUGIN_HANDLED
}
public SaveData(id, szName[])
{
    new szData[18]
    num_to_str(g_iPoints[id], szData, charsmax(szData))
    
    fvault_set_data(BM_ItemShopDB, szName, szData)
}

public LoadData(szName[], id)
{
    new szData[18]
    
    if (fvault_get_data(BM_ItemShopDB, szName, szData, charsmax(szData)))
        g_iPoints[id] = str_to_num(szData)
    else
        g_iPoints[id] = 0
    
    g_bConnected[id] = true
} 
Пробвай за дали е само за CT
MANSION - HNS : 45.144.155.99:27026
ONLINE

Аватар
Coca Cola _-FxF-_
Извън линия
Потребител
Потребител
Мнения: 159
Регистриран на: 15 Окт 2016, 15:30
Се отблагодари: 21 пъти
Получена благодарност: 3 пъти
Обратна връзка:

Re: Преработка на плъгини [BM System #3]

Мнение от Coca Cola _-FxF-_ » 13 Юни 2017, 20:01

Не е все още е за Terrorist

Добавено преди 18 минути 43 секунди:
*п.с. работи моя грешка.
Mobile Legends BANG BANG!
- Nick: Marksman <GX>
- Add me for RANKS
!

Публикувай отговор
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Заявки за плъгини”

Кой е на линия

Потребители разглеждащи този форум: 0 регистрирани и 18 госта