كونكر عرب

كونكر عرب (https://conquer-arab.com/index.php)
-   تطوير سيرفرات كونكر (https://conquer-arab.com/forumdisplay.php?f=11)
-   -   سستم exchangeshop (https://conquer-arab.com/showthread.php?t=736)

Hazem 2019-07-11 02:19 PM

سستم exchangeshop
 

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

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

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<uint, CMsgExchangeItems> Items; 
        public static 
void Load() 
        { 
            
string[] text = File.ReadAllLines(Constants.DataHolderPath + "exchange_shop_goods.txt"); 
            
Items = new Dictionary<uint, CMsgExchangeItems>(); 
            
CMsgExchangeItems Item; 
            for (
int x = 0; x < text.Length; x++) 
            {     
                
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]) != 0 ? true : false; 
                
Item.NeededItemID = uint.Parse(split[5]); 
                
Item.NeddedItemCount = uint.Parse(split[6]); 
                if (!
Items.ContainsKey(Item.ID)) 
                { 
                    
Items.Add(Item.ID, Item); 
                } 
            } 
        } 
    } 
} 

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

Network.GamePackets 

وحط فيهم دول
كود PHP:

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 = 0; i < dePacket.Length; i++) 
                { 
                    
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(memoryStream, ExchangeShopArgs, PrefixStyle.Fixed32); 
                var 
pkt = new byte[8 + memoryStream.Length]; 
                
memoryStream.ToArray().CopyTo(pkt, 0); 
                
Writer.WriteUshort((ushort)memoryStream.Length, 0, pkt); 
                
Writer.WriteUshort(2441, 2, pkt); 
                return 
pkt; 
            } 
        } 
    } 
    [
ProtoContract] 
    public class 
ProtoExchangeShop 
    
{ 
        [
ProtoMember(1, IsRequired = true)] 
        public 
uint ShopID; 
        [
ProtoMember(2, IsRequired = true)] 
        public 
uint Action; 
        [
ProtoMember(3, IsRequired = true)] 
        public 
uint TimeIn; 
        [
ProtoMember(4, IsRequired = true)] 
        public 
uint TimeInSeconds; 
    } 
} 

في المكان ده
كود PHP:

Network.GamePackets 

اعمل كلاس باسم CMsgExchangeShopRespond.cs
كود PHP:

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(incoming, 4, Incoming, 0, Incoming.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.ItemID, out 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(PriceItem, Count)) 
                    { 
                        if (
client.Inventory.Remove(PriceItem, Count)) 
                        { 
                            
client.Inventory.Add(Item.ItemID, 0, (byte)Data.Amount, Item.Bound); 
                        } 
                    } 
                } 
            } 
        } 
        public static 
uint[] Read7BitEncodedInt(byte[] buffer) 
        { 
            List<
uint> ptr2 = new List<uint>(); 

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

                    if (
tmp % 8 == 0) 
                        while (
true) 
                        { 
                            if (
i + 1 > 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
وحط ده علشان يقراء القنصل
كود PHP:

CMsgExchangueShopFile.Load(); 

في المسار ده
كود PHP:

bin\Debug\database 

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

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

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
كود PHP:

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
ضيف ده
كود PHP:

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

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

virus7x 2019-07-11 02:35 PM

رد: سستم exchangeshop
 


جميل :o


Hassan Emprator 2019-07-11 02:41 PM

رد: سستم exchangeshop
 
هههههههه اه وبتقولي مش معاك اه بتموت في الكذب انت احازم

MohamedModyAdel 2019-07-11 03:40 PM

رد: سستم exchangeshop
 
تسلم

Hazem 2019-07-11 04:22 PM

رد: سستم exchangeshop
 
اقتباس:

المشاركة الأصلية كتبت بواسطة hassan emprator (المشاركة 4564)
هههههههه اه وبتقولي مش معاك اه بتموت في الكذب انت احازم

ههههههههههه علشان متنزلهوش انت

Hassan Emprator 2019-07-11 04:23 PM

رد: سستم exchangeshop
 
اقتباس:

المشاركة الأصلية كتبت بواسطة hazem (المشاركة 4592)
ههههههههههه علشان متنزلهوش انت


ههههه اه يبن اللزينه

Hazem 2019-07-11 04:25 PM

رد: سستم exchangeshop
 
انت لو معاك حاجه نزله قبل ما انزله انا ههههههههه

Hassan Emprator 2019-07-11 05:25 PM

رد: سستم exchangeshop
 
اقتباس:

المشاركة الأصلية كتبت بواسطة Hazem (المشاركة 4596)
انت لو معاك حاجه نزله قبل ما انزله انا ههههههههه


هغههغهغهغه ماشي ماشي الصبر حلو :o

Mr~Rayzo 2019-07-11 06:38 PM

رد: سستم exchangeshop
 
الله ينور والله

anwer1 2019-07-11 06:48 PM

رد: سستم exchangeshop
 
عاش يا حازم بس عاوز حل بعض الوندزات اللغه العربيه هتبقى علامات ووندوزات تانيه سليمه


الساعة الآن 06:44 AM

مرحبا بكم في منتدي اكواد لتطوير الالعاب
new notificatio by 9adq_ala7sas