• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

shop error

Newbie Spellweaver
Joined
Aug 23, 2014
Messages
59
Reaction score
3
how to fix This error
Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Game.Network.ClientPacket.PROTOCOL_SHOP_BUY_ITEM_REQ.RunImpl() in C:\Users\amr20\Downloads\Compressed\pb-master\Game\Network\ClientPacket\PROTOCOL_SHOP_BUY_ITEM_REQ.cs:line 44
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
 
Initiate Mage
Joined
Feb 18, 2013
Messages
3
Reaction score
0
check PROTOCOL_SHOP_BUY_ITEM_REQ at line 44,
if u have the source its better if u post
PROTOCOL_SHOP_BUY_ITEM_REQ & PROTOCOL_SHOP_BUY_ITEM_ACK here so we can help whats cause the error
 
Last edited:
Upvote 0
Newbie Spellweaver
Joined
Jan 31, 2016
Messages
22
Reaction score
0
But i have diferent notification on server, like this
loma4 - shop error - RaGEZONE Forums
please help me :(
 
Upvote 0
Newbie Spellweaver
Joined
Aug 23, 2014
Messages
59
Reaction score
3
protocol_shop_buy_item_req

Code:
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core.Model;
using Core.Data.Parsers;
using Game.Network.ServerPacket;
using Core.Database.Tables;


namespace Game.Network.ClientPacket
{
    class PROTOCOL_SHOP_BUY_ITEM_REQ : ReceivePacket
    {
        private int id;
        public PROTOCOL_SHOP_BUY_ITEM_REQ(GameNetwork Client, byte[] data)
        {
            makeme(Client, data);
        }
        public override void ReadImpl()
        {
            ReadC();
            id = ReadD(); // error ?
        }
        public override void RunImpl()
        {
            Good good = getGoodItemById(id);
            if (good == null || getClient().getPlayer().getGp() < good.getPricePoints() || getClient().getPlayer().getMoney() < good.getPriceCredits())
            {
                getClient().SendPacket(new PROTOCOL_SHOP_BUY_ITEM_ACK(0x80001019, null, null, 0));
            }
            else
            {
                Item item = new Item
                {
                    Id = ItemsTable.items.Count,
                    ItemId = good.getItemId(),
                    Count = good.getQuantity(),
                    OwnerId = getClient().getPlayer().AccountID,
                    Type = good.getLifeType(),
                    ItemType = good.getItemType(),
                    Slot = good.getSlot()
                };


                ItemsTable.items[item.OwnerId].Add(item);
                getClient().getPlayer().setGp(getClient().getPlayer().getGp() - good.getPricePoints());
                getClient().getPlayer().setMoney(getClient().getPlayer().getMoney() - good.getPriceCredits());
                getClient().SendPacket(new PROTOCOL_SHOP_BUY_ITEM_ACK(0, item, getClient().getPlayer(), good.getItemType()));
            }
        }


        public Good getGoodItemById(int id)
        {
            foreach (Good item in GoodsParser.goods.Values)
            {
                if (item.getGoodId() == id)
                {
                    return item;
                }
            }
            return null;
        }
    }
}


and
PROTOCOL_SHOP_BUY_ITEM_ACK
Code:
/* * C# Server Emulator Project Blackout / PointBlank
 * Authors: the__all
 * Copyright (C) 2015 | OZ-Network
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core.Model;
using Core.Database.Tables;


namespace Game.Network.ServerPacket
{
    class PROTOCOL_SHOP_BUY_ITEM_ACK : SendPacket
    {
        private uint error;
        private Item item;
        private Player player;
        private int Slot;
        private int GP;
        private int Money;


        public PROTOCOL_SHOP_BUY_ITEM_ACK(uint error, Item item, Player player, int ItemType)
        {
            this.error = error;
            this.player = player;
            this.item = item;
        }
        public override void WriteImpl()
        {


            Logger.Warn("Item Type: " + Slot);


            WriteH(0x213);
            if (error == 0)
            {
                WriteD(1);
                WriteD(Convert.ToInt32(DateTime.Now.ToString("yyMMddHHmm"))); //DateTimeUtil.getDateTime()
                Logger.Warn("TIME: " + Convert.ToInt32(DateTime.Now.ToString("yyMMddHHmm")));
                if (item.ItemType >= 0)
                {
                    if (item.ItemType < 5)
                    {
                        WriteD(0);
                        WriteD(1);
                        WriteD(0);
                        //Добавляем итем в базу данных
                        ItemsTable.AddItem(item.OwnerId, item.ItemId, item.ItemType, item.Type, item.Count);
                    }
                    else if (item.ItemType > 4 & item.ItemType < 10)
                    {
                        WriteD(1);
                        WriteD(0);
                        WriteD(0);
                        //Добавляем итем в базу данных
                        ItemsTable.AddItem(item.OwnerId, item.ItemId, item.ItemType, item.Type, item.Count);
                    }
                    else if (item.ItemType >= 10)
                    {
                        WriteD(0);
                        WriteD(0);
                        WriteD(1);


                        int newID = item.ItemId + 30 - 1000000000;
                        ItemsTable.AddItem(item.OwnerId, newID, item.ItemType, item.Type, item.Count);
                    }
                }
                Money = player.getMoney();
                GP = player.getGp();


                //Обновляем кол-во средств на аккаунте
                PlayersTable.UpdateMoney(player.PlayerID, GP, Money);


                if (item.ItemType == 3)
                {
                    WriteQ(0);
                }
                else
                {
                    WriteQ(item.ItemId);
                }


                WriteD(item.ItemId); //id
                WriteC((byte)item.Type); //settings weapon - type
                WriteD(item.Count); //settings weapon - count
                WriteD(player.getGp());
                WriteD(player.getMoney());
            }
            else
            {
                WriteD((int)error);
            }
        }
    }
}


 
Upvote 0
Back
Top