Trade, with no target entity

Сообщения
14
Реакции
2
Ошибка
L 13/02/2018 - 19:57:08: (map "de_dust2") PF_MessageBegin_I: with no target entity
ОС
Linux
Билд
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.4.0.633-dev
Build date: 10:34:06 Jan 24 2018 (1383)
Build from: https://github.com/dreamstalker/rehlds/commit/82ee1b0
ReGamedll
ReGameDLL version: 5.5.0.291-dev
Build date: 09:37:02 Feb 8 2018
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/40f3bc4
Версия Metamod
Metamod-r v1.3.0.84, API (5:13)
Metamod-r build: 20:03:02 Jul 31 2017
Metamod-r from: https://github.com/theAsmodai/metamod-r/commit/a6ab7ce
Список метамодулей
[ 1] Reunion          RUN   -    reunion_mm_i386.  v0.1.0.9  ini   Start Never
[ 2] AMX Mod X RUN - amxmodx_mm_i386. v1.8.3-R ini Start ANY
[ 3] VoiceTranscoder RUN - VoiceTranscoder. v2017RC3 ini ANY ANY
[ 4] ReAuthCheck RUN - reauthcheck_mm_i v0.1.6 ini Start Never
[ 5] ReSemiclip RUN - resemiclip_mm_i3 v2.3.9 ini Chlvl ANY
[ 6] Rechecker RUN - rechecker_mm_i38 v2.5 ini Chlvl ANY
[ 7] Ultimate Unprec RUN - libunprecacher.s vBeta 2. ini Chlvl Chlvl
[ 8] MySQL RUN - mysql_amxx_i386. v1.8.3-R pl2 ANY ANY
[ 9] CSX RUN - csx_amxx_i386.so v1.8.3-R pl2 ANY ANY
[10] Fun RUN - fun_amxx_i386.so v1.8.3-R pl2 ANY ANY
[11] Engine RUN - engine_amxx_i386 v1.8.3-R pl2 ANY ANY
[12] FakeMeta RUN - fakemeta_amxx_i3 v1.8.3-R pl2 ANY ANY
[13] CStrike RUN - cstrike_amxx_i38 v1.8.3-R pl2 ANY ANY
[14] Ham Sandwich RUN - hamsandwich_amxx v1.8.3-R pl2 ANY ANY
[15] SQLite RUN - sqlite_amxx_i386 v1.8.3-R pl2 ANY ANY
[16] ReAPI RUN - reapi_amxx_i386. v5.5.0.1 pl2 ANY Never
16 plugins, 16 running
Список плагинов
[  1] Lite Bans               1.5         neygomon          lite_bans.amxx   running
[ 2] AMXBans Core 6.13 YamiKaitou amxbans_core.am running
[ 3] AMXBans Main 6.13 YamiKaitou amxbans_main.am running
[ 4] Admin Commands 1.8.3-Re AMXX Dev Team admincmd.amxx running
[ 5] Admin Help 1.8.3-Re AMXX Dev Team adminhelp.amxx running
[ 6] Multi-Lingual System 1.8.3-Re AMXX Dev Team multilingual.am running
[ 7] Commands Menu 1.8.3-Re AMXX Dev Team cmdmenu.amxx running
[ 8] Players Menu 1.8.3-Re AMXX Dev Team plmenu.amxx running
[ 9] Maps Menu 1.8.3-Re AMXX Dev Team mapsmenu.amxx running
[ 10] Menus Front-End 1.8.3-Re AMXX Dev Team menufront.amxx running
[ 11] Plugin Menu 1.8.3-Re AMXX Dev Team pluginmenu.amxx running
[ 12] Admin Chat 1.8.3-Re AMXX Dev Team adminchat.amxx running
[ 13] Anti Flood 1.8.3-Re AMXX Dev Team antiflood.amxx running
[ 14] Admin Votes 1.8.3-Re AMXX Dev Team adminvote.amxx running
[ 15] Pause Plugins 1.8.3-Re AMXX Dev Team pausecfg.amxx running
[ 16] Stats Configuration 1.8.3-Re AMXX Dev Team statscfg.amxx running
[ 17] Restrict Weapons 1.8.3-Re AMXX Dev Team restmenu.amxx running
[ 18] CS Misc. Stats 1.8.3-Re AMXX Dev Team miscstats.amxx running
[ 19] Show IP 1.0 $uicid3 amx_ip.amxx running
[ 20] Vampire 1.0 Shalfey vampire.amxx running
[ 21] AMXX Gag 1.4.9 xPaw & Exolent amx_gag.amxx running
[ 22] FPS Max 1.0 AMXX Dev Team fps_max.amxx paused
[ 23] Pre_cache_Man 1.0 ConMcL precache.amxx stopped
[ 24] Autoresponder/Advertis 0.5 MaximusBrood ad_manager.amxx running
[ 25] Map Manager 2.5.61 Mistrick mapmanager.amxx running
[ 26] Advanced Client Checke 0.3.3 Mistrick cmdchecker.amxx running
[ 27] Simple VIP 4.3 ArtHa simple_vip.amxx running
[ 28] Gang System 1.0 *Terror* rcsgo_gang.amxx running
[ 29] [ReAPI] AimEspFix VIP 1.0 ? fix_vip_tab.amx paused
[ 30] AFK Control 1.4.1 [NoR neygomon afk_control.amx paused
[ 31] Ping Checker 26.0.1 RC1 h1k3 ping_checker.am running
[ 32] ScreenMaker 1.0 neygomon screen_maker.am running
[ 33] Simple Resetscore 1.0 OciXCrom crx_simplers.am running
[ 34] [ReAPI] No Team Flash 0.0.2 Vaqtincha no_team_flash.a running
[ 35] Kills Counter 0.3 serfreeman1337 kills_counter.a running
[ 36] Auto Demo Recorder 1.0 F@nt0M demo_recorder.a running
[ 37] Pirkimu Meniu 1.0 Terror pirkimu_meniu.a running
[ 38] Block Advert 1.4 neygomon block_advert.am running
[ 39] Lite Admin ESP 1.0 neygomon admin_spec_esp. running
[ 40] Auto VIP [STEAM] 1.0 ArtHa auto_steam_vip. running
[ 41] Map Spawns Editor 1.0.16 iG_os Map_Spawns_Edit running
[ 42] FlashBang DynLight 1.3 [REAPI neugomon flashbang_dynli running
[ 43] Advanced Experience Sy 0.5.8 Vega serfreeman1337/s aes_main.amxx running
[ 44] AES: CStrike Addon 0.5.7 Vega serfreeman1337/s aes_exp_cstrike running
[ 45] AES: Informer 0.5.8 Vega serfreeman1337/s aes_informer.am running
[ 46] AES: Admin Tools 0.5.8 Vega serfreeman1337/s aes_exp_editor. running
[ 47] AES: Bonus System 0.5.8 Vega serfreeman1337/s aes_bonus_syste running
[ 48] Bonus: Flags 0.1 Sonyx aes_bonus_flags running
[ 49] AES: StatsX 0.5.8 Vega serfreeman1337/s aes_statsx_cstr running
[ 50] CSStatsX SQL 0.7.4 serfreeman1337 csstatsx_sql.am running
[ 51] Global Offensive 4.62 Psychical saudyk_rcsgo.am debug
[ 52] CSGO Event Saudyk.lt 1.0 horde rcsgo_event.amx debug
[ 53] [ReAPI] Night VIP 1.0 F@nt0M night_vip.amxx debug
[ 54] Supply Crates 2.0 TBagT supply_box.amxx debug
[ 55] Me Hp StatsX 1.35 AMXX Dev Team me_hp_statsx.am debug
[ 56] Lite Translit 2.8 neygomon lite_translit.a debug
Hello Lads.
1. Having an issue with Trade system After Accepting a Trade Player Gets an error with the Error code of : PF_MessageBegin_I: with no target entity.
2. When You Accept a Trade Press How much you want Keys To trade You write '1' And if in that period of time Another Player Press Decline Trade Then Server crashes

Код:
public TradeMenu(id) 
{
    new offer;
    
    if(1 <= TradeTarget[id] <= 32) 
    {
        new target = TradeTarget[id];
        new p_target = TradeTarget[target];
            
        if(is_user_connected(target) && p_target == id) 
        {   // Both trading
            showTradeMenu(id);
        }
        else if((offer = PlayerHasTradingOffer(id)) > 0) 
        {
            new szText[128], menu;
            new name[64];
            get_user_name(offer, name, charsmax(name));
            formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "TRADE_TRADING", PREFIX_EVENT, name);
            menu = menu_create(szText, "TradeOfferHandler");
            
            formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "TRADE_ACCEPT");    
            menu_additem(menu, szText);

            formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "TRADE_DECLINE");    
            menu_additem(menu, szText);

            menu_display(id, menu, 0);
        }
        else 
        {
            showTradeTargets(id);
        }
    }
    else if((offer = PlayerHasTradingOffer(id)) > 0) 
    {
        new szText[128], menu;
        new name[64];
        get_user_name(offer, name, charsmax(name));
        
        formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "TRADE_TRADING", PREFIX_EVENT, name);
        menu = menu_create(szText, "TradeOfferHandler");
        
        formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "TRADE_ACCEPT");    
        menu_additem(menu, szText);

        formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "TRADE_DECLINE");    
        menu_additem(menu, szText);
        
        menu_display(id, menu, 0);
    }
    else 
    {
        showTradeTargets(id);
    }
}

public TradeOfferHandler(id, menu, item) 
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu);
        return PLUGIN_HANDLED;
    }
    
    new offer = PlayerHasTradingOffer(id);
    
    if(!(1 <= offer <= 32) || !is_user_connected(offer)) 
    {
        TradeMenu(id);
        return PLUGIN_HANDLED;
    }
    
    new name[64];
    get_user_name(id, name, charsmax(name));
    
    switch(item)
    {
        case 0: 
        {
            TradeTarget[id] = offer;
            client_print_color(offer, print_team_default, "%L", LANG_PLAYER, "TRADE_YPLAYER_ACCEPT", Prefix, name);

            ResetTrade(id, false);
            ResetTrade(offer, false);
            
            TradeMenu(offer);
        }
        case 1: 
        {
            TradeTarget[offer] = 0;
            client_print_color(offer, print_team_default, "%L", LANG_PLAYER, "TRADE_YPLAYER_DECLINE", Prefix, name);
        }
    }
    TradeMenu(id);
    return PLUGIN_HANDLED;
}

stock PlayerHasTradingOffer(id) 
{
    for(new i = 1; i <= 32; i++) 
    {
        if(is_user_connected(i) && TradeTarget[i] == id) return i;
    }
    return -1;
}

public showTradeTargets(id) 
{    
    new szText[512];
    
    formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "TRADE_SHOW_TARGETS", PREFIX_EVENT);
    new menu = menu_create(szText, "TradePlayersHandler");
    
    new szName[32], szUserId[32], players[32], pnum, tempid;
    get_players(players, pnum); 
    
    for(new i; i < pnum; i++)
    {
        tempid = players[i];
        
        if(tempid == id) 
            continue;
        
        get_user_name(tempid, szName, charsmax(szName));
        
        formatex(szUserId, charsmax(szUserId), "%d", get_user_userid(tempid));
        menu_additem(menu, szName, szUserId, 0);
    }
    menu_display(id, menu, 0);
}

public TradePlayersHandler(id, menu, item) 
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu);
        return PLUGIN_HANDLED;
    }
    
    new szData[6], szName[64];
    new _access, item_callback;
    menu_item_getinfo(menu, item, _access, szData,charsmax(szData), szName,charsmax(szName), item_callback);
    
    new userid = str_to_num(szData);
    
    new player = find_player("k", userid); // flag "k" : find player from userid

    if(player && is_user_connected(player))
    {
        if(canOffer[id])
        {
            new name[64];
            get_user_name(id, name, charsmax(name));

            TradeTarget[id] = player;
            client_print_color(player, print_team_default, "%L", LANG_PLAYER, "TRADE_PLAYER", Prefix, name);
            TradeMenu(player);
            set_task(10.0, "resetOffering", id+8080);
            canOffer[id] = false;
        }
        else client_print_color(id, print_team_default, "%L", LANG_PLAYER, "TRADE_WAITING_TARGETS", Prefix);
    }
    TradeMenu(id);
    
    return PLUGIN_HANDLED;
}

public resetOffering(id)
{
    id -= 8080;
    canOffer[id] = true;
}

public showTradeMenu(id) 
{
    if(1 <= TradeTarget[id] <= 32) 
    {
        new target = TradeTarget[id];
        
        if(is_user_connected(target)) 
        {
            new szText[512], target_name[64];
            get_user_name(target, target_name, charsmax(target_name));
            
            formatex(szText, charsmax(szText), "\y[\rPublic\y] \wKeičiatės su \r%s\d:\w", target_name);
            
            new menu = menu_create(szText, "TradeMenuHandler");
            
            if(TradeSkin[id] != -1) 
            {
                new skin_id = TradeSkin[id];
                formatex(szText, charsmax(szText), "\wSkiną: \y%s \d[\r%s\d]", WeaponNames[skin_id], szWeaponNames[Weapons[skin_id]]);
            }
            else 
            {
                formatex(szText, charsmax(szText), "\wSkiną: \dnepasirinkta");
            }
            menu_additem(menu, szText);
            
            if(TradeChest[id] != -1 && TradeChestCount[id] > 0) 
            {
                new chest_id = TradeChest[id];
                formatex(szText, charsmax(szText), "\wSkrynią: \y%s \d[%d]", chest_name(chest_id), TradeChestCount[id]);
            }
            else 
            {
                formatex(szText, charsmax(szText), "\wSkrynią: \dnepasirinkta");
            }
            menu_additem(menu, szText);
            
            formatex(szText, charsmax(szText), "\wRaktai: \d%d", TradeKey[id]);
            menu_additem(menu, szText);
            
            formatex(szText, charsmax(szText), "\wTaškai: \d$%d", TradeMoney[id]);
            
            new extraText[512];
            formatex(extraText, charsmax(extraText), "%s^n^n\w--- \y%s \w---^n^n", szText, target_name);
            
            if(TradeSkin[target] != -1) 
            {
                new skin_id = TradeSkin[target];
                formatex(extraText, charsmax(extraText), "%s\wSkiną: \y%s \d[\r%s\d]^n", extraText, WeaponNames[skin_id], szWeaponNames[Weapons[skin_id]]);
            }
            else 
            {
                formatex(extraText, charsmax(extraText), "%s\wSkiną: \dnepasirinkta^n", extraText);
            }
            
            if(TradeChest[target] != -1 && TradeChestCount[id] > 0) 
            {
                new chest_id = TradeChest[target];
                formatex(extraText, charsmax(extraText), "%s\wSkrynią: \y%s \d[%d]^n", extraText, chest_name(chest_id), TradeChestCount[target]);
            }
            else 
            {
                formatex(extraText, charsmax(extraText), "%s\wSkrynią: \dnepasirinkta^n", extraText);
            }
            
            formatex(extraText, charsmax(extraText), "%s\wRaktai: \d%d^n", extraText, TradeKey[target]);
            formatex(extraText, charsmax(extraText), "%s\wTaškai: \d$%d^n^n", extraText, TradeMoney[target]);
            menu_additem(menu, extraText);
            
            if(TradeAccept[id] == -1) 
            {    
                formatex(szText, charsmax(szText), "\yPatvirtinti");
                menu_additem(menu, szText);
            }    
            else 
            {    
                formatex(szText, charsmax(szText), "\yPatvirtinti \d[Waiting for other player]");
                menu_additem(menu, szText);
            }    
                        
            formatex(szText, charsmax(szText), "\rAtšaukti");
            menu_additem(menu, szText);
            
            menu_display(id, menu, 0);
        }
        else 
        {
            TradeMenu(id);
        }
    }
    else 
    {
        TradeMenu(id);
    }
}

public TradeMenuHandler(id, menu, item) 
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu);
        return PLUGIN_HANDLED;
    }

    if(TradeAccept[id] == -1) 
    {
        switch(item) 
        {
            case 0: 
            {     // Skin
                showTradeSkinsMenu(id);
            }
            case 1: 
            {     // Chest
                showTradeChestsMenu(id);
            }
            case 2: 
            {     // Keys
                inMM[id] = true;
                client_cmd(id, "messagemode SET_TRADE_KEYS");
                TradeMenu(id);
            }
            case 3: 
            {     // Money
                inMM[id] = true;
                client_cmd(id, "messagemode SET_TRADE_MONEY");
                TradeMenu(id);
            }
        }
    }
        
    new target = TradeTarget[id];
    
    if(item == 4) 
    { // Accept
        if(TradeAccept[id] == -1) 
        {
            TradeAccept[id] = 1;
        }
        else 
        {
            TradeAccept[id] = -1;
        }
        
        if(TradeAccept[id] != -1) 
        {
            client_print_color(id, print_team_default, "%L", LANG_PLAYER, "TRADE_PLAYER_ACCEPT", Prefix);
            
            if(TradeAccept[target] != -1) 
            {
                MakeTrade(id, target);
            }
            TradeMenu(id);
        }
    }
    else if(item == 5) 
    { // Decline
        client_print_color(id, print_team_default, "%L", LANG_PLAYER, "TRADE_PLAYER_DECLINE", Prefix);
        ResetTrade(id, true);
        ResetTrade(target, true);
        TradeMenu(id);
    }
    
    return PLUGIN_HANDLED;
}

public showTradeSkinsMenu(id) 
{
    new szText[512];
        
    formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "TRADE_ITEM_SKINS", PREFIX_EVENT);
    new menu = menu_create(szText, "skinsTradeMenuHandler");

    menu_additem(menu, "None", "-1");
    
    new String[32], All;
    for(new i = 1; i < AllWeapon; i++)
    {
        if(uWeapon[i][id] <= 0)
            continue;
        
        num_to_str(i, String, 31);
        formatex(szText, sizeof(szText), "%L", LANG_PLAYER, "SKINPIECE", (bUsingGuns[id][Weapons[i]] == i) ? "\w" : "\y", WeaponNames[i], szWeaponNames[Weapons[i]], uWeapon[i][id]);
        menu_additem(menu, szText, String);
        All++;
        
    }
    menu_display(id, menu, 0);
}

public skinsTradeMenuHandler(id, menu, item) 
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu);
        TradeMenu(id);
        return PLUGIN_HANDLED;
    }
    
    new szData[6], szName[64];
    new _access, item_callback;
    menu_item_getinfo(menu, item, _access, szData, charsmax(szData), szName, charsmax(szName), item_callback);
    
    new skin_id = str_to_num(szData);
    
    if(skin_id != -1) 
    {
        new name[64];
        get_user_name(id, name, charsmax(name));
        
        TradeSkin[id] = skin_id;
        client_print_color(TradeTarget[id], print_team_default, "[^4Public^1] ^3%s ^1set ^4%s ^1[^4%s^1] skiną!", name, WeaponNames[skin_id], szWeaponNames[Weapons[skin_id]]);
    }
    TradeMenu(id);
    TradeMenu(TradeTarget[id]);
    
    return PLUGIN_HANDLED;
}

public showTradeChestsMenu(id) 
{
    new szText[512];
    formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "TRADE_ITEM_CHESTS", PREFIX_EVENT);
    new menu = menu_create(szText, "chestsTradeMenuHandler");
    
    menu_additem(menu, "None", "-1");
    
    for(new i = 1; i <= CHEST_COUNT; i++)
    {
        if(Chest[id][i] > 0)
        {
            formatex(szText, sizeof(szText), "%L", LANG_PLAYER, "CHESTPIECE", chest_name(i), Chest[id][i]);
            
            new szButton[128]; formatex(szButton, charsmax(szButton), "%d", i);
            menu_additem(menu, szText, szButton);
            
        }
    }
    menu_display(id, menu, 0);
}

public chestsTradeMenuHandler(id, menu, item) 
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu);
        TradeMenu(id);
        return PLUGIN_HANDLED;
    }
    
    new szData[6], szName[64];
    new _access, item_callback;
    menu_item_getinfo( menu, item, _access, szData,charsmax(szData), szName, charsmax(szName), item_callback);
    
    new chest_id = str_to_num(szData);
    
    if(chest_id != -1) 
    {
        new name[64];
        get_user_name(id, name, charsmax(name));
        
        TradeChest[id] = chest_id;
        
        inMM[id] = true;
        client_cmd(id, "messagemode SET_TRADE_CHESTS");
    }
    TradeMenu(id);
    return PLUGIN_HANDLED;
}

public ResetTrade(id, bool:reset) 
{
    if(reset) 
    TradeTarget[id] = 0;
    TradeAccept[id] = -1;
    TradeSkin[id] = -1;
    TradeChest[id] = -1;
    TradeKey[id] = 0;
    TradeMoney[id] = 0;
}

public cmdKeys(id)
{
    if(inMM[id])
    {
        new szTemp[64];
        
        read_args(szTemp, charsmax(szTemp));
        remove_quotes(szTemp);
        
        if(IsInteger(szTemp))
        {
            new pts = str_to_num(szTemp);
            
            if(TradeKey[id] != pts)
            {
                if(pts > pKey[id]) pts = pKey[id];
                TradeKey[id] = pts;
                
                new name[64];
                get_user_name(id, name, charsmax(name));
                client_print_color(TradeTarget[id], print_team_default, "[^4Public^1] ^3%s ^1set ^4%d ^1raktų!", name, pts);
                TradeMenu(TradeTarget[id]);
            }
            else 
            {
                client_print_color(id, print_team_default, "%L", LANG_PLAYER, "TRADE_PLAYER_DECLINE", Prefix);
            }
        }
        else
        {
            client_cmd(id, "messagemode SET_TRADE_KEYS");
            return PLUGIN_HANDLED;
        }
    }
    
    inMM[id] = false;
    set_task(0.5, "TradeMenu", id);
    return PLUGIN_HANDLED;
}

public cmdMoney(id)
{
    if(inMM[id])
    {
        new szTemp[64];
        
        read_args(szTemp, charsmax(szTemp));
        remove_quotes(szTemp);
        
        if(IsInteger(szTemp))
        {
            new pts = str_to_num(szTemp);
            if(TradeMoney[id] != pts)
            {
                if(pts > Points[id]) pts = Points[id];
                TradeMoney[id] = pts;
                
                new name[64];
                get_user_name(id, name, charsmax(name));
                client_print_color(TradeTarget[id], print_team_default, "[^4Public^1] ^3%s ^1set ^4%d ^1taškų!", name, pts);
                TradeMenu(TradeTarget[id]);
            }
            else 
            {
                client_print_color(id, print_team_default, "%L", LANG_PLAYER, "TRADE_PLAYER_DECLINE", Prefix);
            }
        }
        else
        {
            client_cmd(id, "messagemode SET_TRADE_MONEY");
            return PLUGIN_HANDLED;
        }
    }
    
    inMM[id] = false;
    set_task(0.5, "TradeMenu", id);
    
    return PLUGIN_HANDLED;
}

public cmdChests(id)
{
    if(inMM[id])
    {
        new szTemp[64];
        
        read_args(szTemp, charsmax(szTemp));
        remove_quotes(szTemp);
        
        if(IsInteger(szTemp) && str_to_num(szTemp) > 0)
        {
            new pts = str_to_num(szTemp);
            
            if(TradeChestCount[id] != pts && TradeChest[id] != -1 && (1 <= TradeChest[id] <= CHEST_COUNT) )
            {
                new cnt = Chest[id][TradeChest[id]];
                
                if(pts > cnt) pts = cnt;
                
                if(pts <= 0) TradeChest[id] = -1;
                TradeChestCount[id] = pts;
                
                new name[64];
                get_user_name(id, name, charsmax(name));
                client_print_color(TradeTarget[id], print_team_default, "[^4Public^1] ^3%s ^1set ^4%s %d ^1skrynių!", name, chest_name(TradeChest[id]), pts);
                TradeMenu(TradeTarget[id]);
            }
            else
            {
                client_print_color(id, print_team_default, "%L", LANG_PLAYER, "TRADE_PLAYER_DECLINE", Prefix);
            }
        }
        else
        {
            client_cmd(id, "messagemode SET_TRADE_CHESTS");
            return PLUGIN_HANDLED;
        }
    }
    
    inMM[id] = false;
    set_task(0.5, "TradeMenu", id);
    
    return PLUGIN_HANDLED;
}

bool:IsInteger(buffer[])
{
    new len = strlen(buffer);
    
    for(new i = 0; i < len; i++)
    {
        if(!isdigit(buffer[i]))
            return false;
    }
    return true;    
}

public MakeTrade(id, target) 
{
    if(!is_user_connected(id) || !is_user_connected(target)) return;
    
    new bool:TradeWillHappen = true;
    new skin_id, target_skin_id, chest_id, target_chest_id, chest_count, target_chest_count, keys, target_keys, money, target_money;
    
    if(TradeSkin[id] != -1) 
    {
        if(uWeapon[TradeSkin[id]][id] <= 0) 
        {
            TradeWillHappen = false;
        }
        else 
        {
            skin_id = TradeSkin[id];
        }
    }
    
    if(TradeSkin[target] != -1) 
    {
        if(uWeapon[TradeSkin[target]][target] <= 0) 
        {
            TradeWillHappen = false;
        }
        else 
        {
            target_skin_id = TradeSkin[target];
        }
    }
    
    if(TradeChest[id] != -1 && TradeChestCount[id] > 0) 
    {
        if(Chest[id][TradeChest[id]] < TradeChestCount[id]) 
        {
            TradeWillHappen = false;
        }
        else 
        {
            chest_id = TradeChest[id];
            chest_count = TradeChestCount[id];
        }
    }
    
    if(TradeChest[target] != -1 && TradeChestCount[target] > 0) 
    {
        if(Chest[target][TradeChest[target]] < TradeChestCount[target]) 
        {
            TradeWillHappen = false;
        }
        else 
        {
            target_chest_id = TradeChest[target];
            target_chest_count = TradeChestCount[target];
        }
    }
    
    if(TradeKey[id] > 0) 
    {
        if(pKey[id] < TradeKey[id]) TradeWillHappen = false;
        else keys = TradeKey[id];
    }
    
    if(TradeKey[target] > 0) 
    {
        if(pKey[target] < TradeKey[target]) TradeWillHappen = false;
        else target_keys = TradeKey[target];
    }
    
    if(TradeMoney[id] > 0) 
    {
        if(Points[id] < TradeMoney[id]) TradeWillHappen = false;
        else money = TradeMoney[id];
    }
    
    if(TradeMoney[target] > 0) 
    {
        if(Points[target] < TradeMoney[target]) TradeWillHappen = false;
        else target_money = TradeMoney[target];
    }
    
    if(TradeWillHappen) 
    {
        pKey[id] -= keys; pKey[target] -= target_keys; pKey[id] += target_keys; pKey[target] += keys;
        Points[id] -= money; Points[target] -= target_money; Points[id] += target_money; Points[target] += money;
        
        uWeapon[skin_id][id]--; uWeapon[target_skin_id][target]--; uWeapon[target_skin_id][id]++; uWeapon[skin_id][target]++;
        Chest[id][chest_id] -= chest_count;
        Chest[id][target_chest_id]  += target_chest_count;
        Chest[target][target_chest_id] -= target_chest_count;
        Chest[target][chest_id] += chest_count;
        
        client_print_color(id, print_team_default, "%L", LANG_PLAYER, "TRADE_SUCCESSFULLY_MAKE", Prefix);
        SaveData(id);
        SaveData(target);
    }
    else 
    {
        client_print_color(id, print_team_default, "%L", LANG_PLAYER, "TRADE_FAILED_MISSING", Prefix);
        client_print_color(target, print_team_default, "%L", LANG_PLAYER, "TRADE_FAILED_MISSING", Prefix);
    }

    ResetTrade(id, true);
    ResetTrade(target, true);
}
 
Последнее редактирование:

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

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