الموضوع: سستم exchangeshop
عرض مشاركة واحدة
احصائياتى

الردود
19

المشاهدات
6222
 
محمد ياسر

محمد ياسر is on a distinguished road

    غير متواجد

المشاركات
1,940

+التقييم
0.87

تاريخ التسجيل
Apr 2019

الاقامة
https://www.facebook.com/daany

نظام التشغيل

رقم العضوية
1
2019-07-11, 02:19 PM
المشاركة 1 
#1  
افتراضي سستم exchangeshop

السلام عليكم ورحمة الله وبركاته
مرحبا بمسئولين واعضاء وزوار منتدي اكواد الكرام
اليوم جبتلكم سستم ناس كتير كانت بتبحث عنه
اللسستم ده عباره عن ملف شوب بتحدد فيه الحجات المطلوبه علشان تشتري منه
صوره للسستم


يلا ندخل علي التركيب
اعمل كلاس جديد باسم CMsgExchangeShop.cs في فلدر Database
وحط فيهم دول

كود:
using System
using System.Collections.Generic
using System.IO
using System.Linq
using System.Text
using System.Threading.Tasks

namespace 
Alaxx.Database 

    public class 
CMsgExchangeItems 
    

        public 
uint ID
        public 
uint ItemID
        public 
uint UnKnown
        public 
uint Remaining
        public 
bool Bound
        public 
uint NeededItemID
        public 
uint NeddedItemCount
    } 
    public static class 
CMsgExchangueShopFile 
    

        public static 
Dictionary<uintCMsgExchangeItemsItems
        public static 
void Load() 
        { 
            
string[] text File.ReadAllLines(Constants.DataHolderPath "exchange_shop_goods.txt"); 
            
Items = new Dictionary<uintCMsgExchangeItems>(); 
            
CMsgExchangeItems Item
            for (
int x 0text.Lengthx++) 
            {     
                
string line text[x]; 
                
string[] split line.Split(new string[] { "@@" }, StringSplitOptions.RemoveEmptyEntries); 
                
Item = new CMsgExchangeItems(); 
                
Item.ID uint.Parse(split[0]); 
                
Item.ItemID uint.Parse(split[1]); 
                
Item.UnKnown uint.Parse(split[2]); 
                
Item.Remaining uint.Parse(split[3]); 
                
Item.Bound uint.Parse(split[4]) != true false
                
Item.NeededItemID uint.Parse(split[5]); 
                
Item.NeddedItemCount uint.Parse(split[6]); 
                if (!
Items.ContainsKey(Item.ID)) 
                { 
                    
Items.Add(Item.IDItem); 
                } 
            } 
        } 
    } 


واعمل كلاس تاني
باسم CMsgExchangeShop.cs في المكان ده

كود:
Network.GamePackets 

وحط فيهم دول

كود:
namespace Alaxx.Network.GamePackets 

using ProtoBuf
using System
using System.Collections.Generic
using System.IO
using System.Linq
using System.Text
using System.Threading.Tasks

    public 
unsafe class CMsgExchangeShop 
    

        private 
byte[] _packet
        public 
CMsgExchangeShop(byte[] incoming
        { 
            
_packet incoming
        } 
        public 
bool Read() 
        { 
            try 
            { 
                var 
dePacket = new byte[_packet.Length 8]; 

                for (
int i 0dePacket.Lengthi++) 
                { 
                    
dePacket[i] = _packet[i]; 
                } 
                
Data Serializer.DeserializeWithLengthPrefix<ProtoExchangeShop>(new System.IO.MemoryStream(dePacket), PrefixStyle.Fixed32); 
                return 
true
            } 
            catch 
            { 
                return 
false
            } 
        } 
        public 
ProtoExchangeShop Data
        public static 
implicit operator byte[](CMsgExchangeShop packet
        { 
            return 
packet._packet
        } 
        public static 
byte[] FinalizeProtoBuf(ProtoExchangeShop ExchangeShopArgs
        { 
            
using (var memoryStream = new MemoryStream()) 
            { 
                
Serializer.SerializeWithLengthPrefix(memoryStreamExchangeShopArgsPrefixStyle.Fixed32); 
                var 
pkt = new byte[memoryStream.Length]; 
                
memoryStream.ToArray().CopyTo(pkt0); 
                
Writer.WriteUshort((ushort)memoryStream.Length0pkt); 
                
Writer.WriteUshort(24412pkt); 
                return 
pkt
            } 
        } 
    } 
    [
ProtoContract
    public class 
ProtoExchangeShop 
    

        [
ProtoMember(1IsRequired true)] 
        public 
uint ShopID
        [
ProtoMember(2IsRequired true)] 
        public 
uint Action
        [
ProtoMember(3IsRequired true)] 
        public 
uint TimeIn
        [
ProtoMember(4IsRequired true)] 
        public 
uint TimeInSeconds
    } 


في المكان ده

كود:
Network.GamePackets 

اعمل كلاس باسم CMsgExchangeShopRespond.cs

كود:
using CMsgConquer.Client
using CMsgConquer.Database
using ProtoBuf
using System
using System.Collections.Generic
using System.IO
using System.Linq
using System.Text
using System.Threading.Tasks

namespace 
Alaxx.Network.GamePackets 

    public class 
CMsgExchangeShopRespond 
    

        private 
byte[] _packet
        public 
CMsgExchangeShopRespond(byte[] incoming
        { 
            
int newLegnth incoming.Length 12
            
byte[] Incoming = new byte[newLegnth]; 
            Array.
Copy(incoming4Incoming0Incoming.Length); 
            
_packet Incoming
        } 
        public 
ExchangeShopRespondProto Data null
        public 
void Handle(GameClient client
        { 
            
uint[] ptr Read7BitEncodedInt(_packet); 
            
int index 0
            
Data = new ExchangeShopRespondProto(); 
            
Data.ShopID ptr[index]; 
            
index++; 
            
Data.Action ptr[index]; 
            
index++; 
            
Data.Amount ptr[index]; 
            
index++; 
            
Data.ItemID ptr[index]; 
            if (
Data != null
            { 
                if (
CMsgExchangueShopFile.Items.ContainsKey(Data.ItemID)) 
                { 
                    
CMsgExchangeItems Item null
                    
CMsgExchangueShopFile.Items.TryGetValue(Data.ItemIDout Item); 
                    if (
Item == null
                        return; 
                    if (
Data.Amount Item.Remaining
                        return; 
                    
uint Count Item.NeddedItemCount Data.Amount
                    
uint PriceItem Item.NeededItemID
                    if (
client.Inventory.Contains(PriceItemCount)) 
                    { 
                        if (
client.Inventory.Remove(PriceItemCount)) 
                        { 
                            
client.Inventory.Add(Item.ItemID0, (byte)Data.AmountItem.Bound); 
                        } 
                    } 
                } 
            } 
        } 
        public static 
uint[] Read7BitEncodedInt(byte[] buffer
        { 
            List<
uintptr2 = new List<uint>(); 

            for (
int i 0buffer.Length; ) 
            { 
                if (
<= buffer.Length
                { 
                    
int tmp buffer[i++]; 

                    if (
tmp == 0
                        while (
true
                        { 
                            if (
buffer.Length) break; 
                            
tmp buffer[i++]; 
                            if (
tmp 128
                            { 
                                
ptr2.Add((uint)tmp); 
                                break; 
                            } 
                            else 
                            { 
                                
int result tmp 0x7f
                                if ((
tmp buffer[i++]) < 128
                                { 
                                    
result |= tmp << 7
                                    
ptr2.Add((uint)result); 
                                    break; 
                                } 
                                else 
                                { 
                                    
result |= (tmp 0x7f) << 7
                                    if ((
tmp buffer[i++]) < 128
                                    { 
                                        
result |= tmp << 14
                                        
ptr2.Add((uint)result); 
                                        break; 
                                    } 
                                    else 
                                    { 
                                        
result |= (tmp 0x7f) << 14
                                        if ((
tmp buffer[i++]) < 128
                                        { 
                                            
result |= tmp << 21
                                            
ptr2.Add((uint)result); 
                                            break; 
                                        } 
                                        else 
                                        { 
                                            
result |= (tmp 0x7f) << 21
                                            
result |= (tmp buffer[i++]) << 28
                                            
ptr2.Add((uint)result); 
                                            break; 
                                        } 
                                    } 
                                } 
                            } 
                        } 
                } 
                else break; 
            } 
            return 
ptr2.ToArray(); 
        } 
    } 
    public class 
ExchangeShopRespondProto 
    

        public 
uint ShopID
        public 
uint Action
        public 
uint Amount
        public 
uint ItemID
        public 
uint U1
        public 
uint U2
    } 


افتح كلاس program او server
وحط ده علشان يقراء القنصل

كود:
CMsgExchangueShopFile.Load(); 

في المسار ده

كود:
bin\Debug\database 

اعمل ملف باسم
exchange_shop_goods.txt

ونحط فيهم الايتمات ده

كود:
1@@3300036@@1@@1@@0@@3300035@@1000@@0@@0@@0@@0@@0@@0@@ 
2@@3300045@@1@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@ 
3@@3300049@@1@@1@@0@@3300035@@188@@0@@0@@0@@0@@0@@0@@ 
4@@3300056@@1@@1@@0@@3300035@@188@@0@@0@@0@@0@@0@@0@@ 
5@@3008727@@1@@3@@0@@3300035@@50@@0@@0@@0@@0@@0@@0@@ 
6@@3300050@@1@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@ 
7@@729242@@1@@100@@1@@3300035@@299@@0@@0@@0@@0@@0@@0@@ 
8@@3300051@@1@@100@@0@@3300035@@10@@0@@0@@0@@0@@0@@0@@ 
9@@3300052@@1@@10@@0@@3300035@@100@@0@@0@@0@@0@@0@@0@@ 
10@@730001@@1@@100@@1@@3300035@@10@@0@@0@@0@@0@@0@@0@@ 
11@@730003@@1@@10@@1@@3300035@@120@@0@@0@@0@@0@@0@@0@@ 
12@@3004895@@1@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@ 
13@@3004898@@1@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@ 
14@@3004897@@1@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@ 
15@@3004896@@1@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@ 
17@@3004247@@1@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@ 
18@@3004248@@1@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@ 
19@@3008058@@1@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@ 
20@@3300036@@2@@1@@0@@3300035@@1000@@0@@0@@0@@0@@0@@0@@ 
21@@3300045@@2@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@ 
22@@3300049@@2@@1@@0@@3300035@@188@@0@@0@@0@@0@@0@@0@@ 
23@@3300056@@2@@1@@0@@3300035@@188@@0@@0@@0@@0@@0@@0@@ 
24@@3008727@@2@@3@@0@@3300035@@50@@0@@0@@0@@0@@0@@0@@ 
25@@3300050@@2@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@ 
26@@729242@@2@@100@@1@@3300035@@299@@0@@0@@0@@0@@0@@0@@ 
27@@3300051@@2@@100@@0@@3300035@@10@@0@@0@@0@@0@@0@@0@@ 
28@@3300052@@2@@10@@0@@3300035@@100@@0@@0@@0@@0@@0@@0@@ 
29@@730001@@2@@100@@1@@3300035@@10@@0@@0@@0@@0@@0@@0@@ 
30@@730003@@2@@10@@1@@3300035@@120@@0@@0@@0@@0@@0@@0@@ 
31@@3004895@@2@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@ 
32@@3004898@@2@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@ 
33@@3004897@@2@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@ 
34@@3004896@@2@@1@@0@@3300035@@88@@0@@0@@0@@0@@0@@0@@ 
35@@3004247@@2@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@ 
36@@3004248@@2@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@ 
37@@3008058@@2@@1@@0@@3300035@@588@@0@@0@@0@@0@@0@@0@@ 

وضيف ده في shop

كود:
case 50
                                    { 
                                        var 
shop = new ProtoExchangeShop() 
                                        { 
                                            
ShopID 19424
                                            
Action 1
                                            
TimeIn 1714178
                                            
TimeInSeconds 46389
                                        }; 
                                        
client.Send(CMsgExchangeShop.FinalizeProtoBuf(shop)); 
                                        break; 
                                    } 

ده اي دي الشوب 19424 الي ايتحط في npc وايكون 1 بدل 2
في NpcServer
ضيف ده

كود:
 case 50
                                    { 
                                        var 
shop = new ProtoExchangeShop() 
                                        { 
                                            
ShopID 19424
                                            
Action 1
                                            
TimeIn 1714178
                                            
TimeInSeconds 46389
                                        }; 
                                        
client.Send(CMsgExchangeShop.FinalizeProtoBuf(shop)); 
                                        break; 
                                    } 

كده انتهيت وبالتوفيق للجميع