منتدي اكواد

منتدي اكواد (https://code.vpscairo.com/index.php)
-   تطوير سيرفرات كونكر (https://code.vpscairo.com/forumdisplay.php?f=11)
-   -   اضافة رانك الوحوش [Proto] (https://code.vpscairo.com/showthread.php?t=2701)

Rider 2019-10-29 01:17 AM

اضافة رانك الوحوش [Proto]
 

قد وجب التنبيه ان هذا الشرح منقول منعفواً لايمكن عرض الروابط إلا بعد الرد على الموضوع

ندخل ع الشرح بقا اول حاجه هتعمل كلاس جديد و تسميه BossHarming او اي اسم يعجبك

بعد مده هترمي فيه دول متنساش تغير اسم بروجيكت
كود PHP:

using ProtoBuf;
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Collections.Concurrent;
using System.Text;
using VirusX;
using VirusX.Database;
using System.Threading.Tasks;
 
namespace 
VirusX.Network.GamePackets
{
    public class 
MsgBossHarmRanking
    
{
        public 
MsgBossHarmRanking() { }
        public 
MsgBossHarmRankingProto Info;
        [
ProtoContract]
        public class 
MsgBossHarmRankingProto
        
{
            [
ProtoMember(1IsRequired true)]
            public 
uint Type;
            [
ProtoMember(2IsRequired true)]
            public 
uint BossUID;
            [
ProtoMember(3IsRequired true)]
            public 
Hunter[] Hunters;
        }
        [
ProtoContract]
        public class 
Hunter
        
{
            [
ProtoMember(1IsRequired true)]
            public 
uint Rank;
            [
ProtoMember(2IsRequired true)]
            public 
uint ServerID;
            [
ProtoMember(3IsRequired true)]
            public 
uint UID;
            [
ProtoMember(4IsRequired true)]
            public 
string Name;
            [
ProtoMember(5IsRequired true)]
            public 
uint Damage;
        }
        public 
bool Read(byte[] packet)
        {
            
using (var memoryStream = new MemoryStream(packet))
            {
                
Info Serializer.DeserializeWithLengthPrefix<MsgBossHarmRankingProto>(memoryStreamPrefixStyle.Fixed32);
            }
            return 
true;
        }
        public 
void Ready(VirusX.Client.GameState client)
        {
            var 
proto = new MsgBossHarmRankingProto();
            
proto.BossUID Info.BossUID;
            
proto.Type 1;
            
/* var scores = client.Map.Entities.Where(i => i.Key == proto.BossUID).FirstOrDefault().Value.MonsterInfo.Score.OrderByDescending(i => i.Value).ToArray();
             if (scores.Length != 0)
             {
                 proto.Hunters = new Hunter[scores.Length];
                 for (int i = 0; i < proto.Hunters.Length; i++)
                 {
                     proto.Hunters[i] = new Hunter();
                     proto.Hunters[i].UID = scores[i].Key.UID;
                     proto.Hunters[i].Name = scores[i].Key.Name;
                     proto.Hunters[i].Damage = scores[i].Value;
                     proto.Hunters[i].ServerID = scores[i].Key.ServerID;
                     proto.Hunters[i].Rank = (uint)(i + 1);
                 }
             } */
            
client.Send(Kernel.FinalizeProtoBuf(proto1044));
            
//client.Send(Kernel.FinalizeProtoBuf(Info, 3282));
        
}
        public 
void Handle(VirusX.Client.GameState client)
        {
            switch (
Info.Type)
            {
                case 
0:
                    {
                        var 
proto = new MsgBossHarmRankingProto();
                        
proto.BossUID Info.BossUID;
                        
proto.Type 1;
                        var 
scores client.Map.Entities.Where(=> i.Key == proto.BossUID).FirstOrDefault().Value.MonsterInfo.Score.OrderByDescending(=> i.Value).ToArray();
                        if (
scores.Length != 0)
                        {
                            
proto.Hunters = new Hunter[scores.Length];
                            for (
int i 0proto.Hunters.Lengthi++)
                            {
                                
proto.Hunters[i] = new Hunter();
                                
proto.Hunters[i].UID scores[i].Key.UID;
                                
proto.Hunters[i].Name scores[i].Key.Name;
                                
proto.Hunters[i].Damage scores[i].Value;
                                
proto.Hunters[i].ServerID scores[i].Key.ServerID;
                                
proto.Hunters[i].Rank = (uint)(1);
                            }
                        }
                        
client.Send(Kernel.FinalizeProtoBuf(proto1044));
                        break;
                    }
            }
        }
    }



بعد كده هنفتح packethandler.cs
و ننزل لحد البكتات و نرمي ده وسطهم
كود PHP:

#region MsgBossHarmRanking
                
case 1044:
                    {
                        var 
pkt = new VirusX.Network.GamePackets.MsgBossHarmRanking();
                        var 
myPacket = new byte[packet.Length 8];
                        for (
int i 0myPacket.Lengthi++)
                        {
                            
myPacket[i] = packet[i];
                        }
                        if (
pkt.Read(myPacket))
                            
pkt.Handle(client);
                        break;
                    }
                
#endregion 

بعد كده هنروح MonsterTable.cs
و هرمي ده جواه
كود PHP:

 public Dictionary<Game.EntityuintScore = new Dictionary<Game.Entityuint>(); 

و اخيرا و ليس اخرا هنروح Monster.cs
و هنحط جواه ده
كود PHP:

#region Monster Score
            
if (monster.EntityFlag == EntityFlag.Monster)
            {
                
//if (attacked.Boss > 0)
                
{
                    if (
monster.MonsterInfo != null)
                    {
                        if (
monster.MonsterInfo.Score.ContainsKey(client.Entity))
                            
monster.MonsterInfo.Score[client.Entity] += obj.Damage;
                        else 
monster.MonsterInfo.Score.Add(client.Entityobj.Damage);
 
                        
//new VirusX.Network.GamePackets.MsgBossHarmRanking().Ready(attacker.Owner);
                    
}
                }
            }
            
#endregion 


عمرو الجنرال 2019-10-29 04:37 AM

رد: اضافة رانك الوحوش [Proto]
 
تسلم ايدك

محمد ياسر 2019-10-29 07:57 AM

رد: اضافة رانك الوحوش [Proto]
 
عاش

neno2052 2019-10-29 08:25 AM

رد: اضافة رانك الوحوش [Proto]
 
ممتاز يا رايدر تسلم ايدك

ElSaher 2019-10-29 10:47 AM

رد: اضافة رانك الوحوش [Proto]
 
عاش يا ريدوري

ElSaher 2019-10-29 10:53 AM

رد: اضافة رانك الوحوش [Proto]
 
هوا دا 2دي ولا 3دي

ALz3em 2019-10-29 11:07 AM

رد: اضافة رانك الوحوش [Proto]
 
عاش

ModyMohamedAdel 2019-10-29 03:52 PM

رد: اضافة رانك الوحوش [Proto]
 
عاش

انت عمري 2019-10-31 04:09 AM

رد: اضافة رانك الوحوش [Proto]
 
عايزين نعمل موضوع دة في السيرفر :)

HBESA 2019-11-01 11:23 PM

رد: اضافة رانك الوحوش [Proto]
 
عاااااااااش


الساعة الآن 11:33 AM

مرحبا بكم في منتدي اكواد لتطوير الالعاب