احصائياتى

الردود
5

المشاهدات
967
 
Alaa Ghanem
.:: عضو نشيط ::.
الإجابات المقدمة: 4

    غير متواجد

المشاركات
56

+التقييم
0.02

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

الاقامة

نظام التشغيل

رقم العضوية
3287
2019-12-08, 07:10 PM
المشاركة 1
2019-12-08, 07:10 PM
المشاركة 1
Important تمت الإجابة مشكلة في السورس الي نزلو Mr_ZeZo
[COLOR="Purple"]السلام عليكم[/COLOR]

بعدت ما ركبت السورس الي نزلو Mr_ZeZo متشكرين طبعاً ع السورس بس بييجي ايرور في القونصل
لينك موضوع السورس


https://code.vpscairo.com/showthread.php?t=3220

صورة من المشكلة



أفضل جواب - كتبه zezonever
هريحك خالص علشان ميجيش ارور تاني لما تمسح ملف الكلان وار ال بيجي من الورد ابعت عن ملف UnoinWar.cs هتمسح كل ال فيه وهضيف دول وكل سنه وانت طيب خلاص كده المشكله


كود:
// * Created by ZeZoOo
// * Copyright © 2020
// * All rights reserved Mr.ZeZoOo - Project
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mr_ZeZo.Network.GamePackets;
using Mr_ZeZo.Database;

namespace 
Mr_ZeZo.Game
{
    public class 
ClanWar
    
{
        public static 
SobNpcSpawn Pole;
        public static 
SafeDictionary<uint, Clan> Scores = new SafeDictionary<uint, Clan>(100);
        public static 
bool IsWar = false, FirstRound = false;
        public static 
Time32 ScoreSendStamp, LastWin;
        public static 
Clan PoleKeeper, CurrentTopLeader;
        private static 
bool changed = false;
        private static 
string[] scoreMessages;
        public static 
DateTime StartTime;
        public static 
bool Claim
        
{
            
get { return Program.Vars["cwclaim"]; }
            
set { Program.Vars["cwclaim"] = value; }
        }
        public static 
uint KeeperID
        
{
            
get { return Program.Vars["cwkeeperid"]; }
            
set { Program.Vars["cwkeeperid"] = value; }
        }
        public static 
void Initiate()
        {
            
Database.DMaps.LoadMap(1509);
            var 
Map = Kernel.Maps[1509];
            
Pole = (SobNpcSpawn)Map.Npcs[812];
        }
        public static 
void Start()
        {
            
Scores = new SafeDictionary<uint, Clan>(100);
            
StartTime = DateTime.Now;
            
FirstRound = true;
            foreach (
Clan clan in Kernel.Clans.Values)
            {
                
clan.WarScore = 0;
            }
            
Claim = false;
            
IsWar = true;
        }

        public static 
void Reset()
        {
            
Scores = new SafeDictionary<uint, Clan>(100);
            
Pole.Hitpoints = Pole.MaxHitpoints;

            foreach (
Clan clan in Kernel.Clans.Values)
            {
                
clan.WarScore = 0;
            }

            
IsWar = true;
        }

        public static 
void FinishRound()
        {
            
LastWin = Time32.Now;

            
FirstRound = false;
            
SortScores(out PoleKeeper);
            if (
PoleKeeper != null)
            {
                
KeeperID = PoleKeeper.ID;
                
Pole.Name = PoleKeeper.Name;
            }
            
Pole.Hitpoints = Pole.MaxHitpoints;
            
Kernel.SendWorldMessage(Pole, Program.Values, (ushort)1509);
            
Reset();
        }

        public static 
void End()
        {
            if (
PoleKeeper != null)
            {
                
Kernel.SendWorldMessage(new Message("The Union, " + PoleKeeper.Name + ", owned by " + PoleKeeper.LeaderName + " has won " + rates.Clanwarday + " cps!---Clan war has ended!", System.Drawing.Color.White, Message.Center), Program.Values);

                
PoleKeeper.PoleKeeper = true;
            }
            else
            {
                
Kernel.SendWorldMessage(new Message(" Union has ended and there was no winner ", System.Drawing.Color.Red, Message.Center), Program.Values);

            }
            
Claim = true;
            
IsWar = false;
            
UpdatePole(Pole);
        }

        public static 
void AddScore(uint addScore, Clan clan)
        {
            if (
clan != null)
            {
                
clan.WarScore += addScore;
                
changed = true;
                if (!
Scores.ContainsKey(clan.ID))
                    
Scores.Add(clan.ID, clan);
                if ((int)
Pole.Hitpoints <= 0)
                {
                    
FinishRound();

                    return;
                }
            }
        }

        public static 
void SendScores()
        {
            if (
scoreMessages == null)
                
scoreMessages = new string[0];
            if (
Scores.Count == 0)
                return;
            if (
changed)
                
SortScores(out CurrentTopLeader);

            for (
int c = 0; c < scoreMessages.Length; c++)
            {
                
Message msg = new Message(scoreMessages[c], System.Drawing.Color.Red, c == 0 ? Message.FirstRightCorner : Message.ContinueRightCorner);
                
Kernel.SendWorldMessage(msg, Program.Values, (ushort)1510);
            }
        }

        private static 
void SortScores(out Clan winner)
        {
            
winner = null;
            List<
string> ret = new List<string>();
            
int Place = 0;
            foreach (
Clan clan in Scores.Values.OrderByDescending((p) => p.WarScore))
            {
                if (
Place == 0)
                    
winner = clan;
                
string str = "No  " + (Place + 1).ToString() + ": " + clan.Name + "(" + clan.WarScore + ")";
                
ret.Add(str);
                
Place++;
                if (
Place == 4)
                    break;
            }

            
changed = false;
            
scoreMessages = ret.ToArray();
        }

        private static 
void UpdatePole(SobNpcSpawn pole)
        {
            new 
Database.MySqlCommand(Mr_ZeZo.Database.MySqlCommandType.UPDATE)
            .
Update("sobnpcs").Set("name", pole.Name).Set("life", Pole.Hitpoints).Where("id", pole.UID).Execute();
        }
    }
    public class 
UnionWar
    
{
        public static 
SobNpcSpawn Pole;
        public static 
SafeDictionary<uint, Mr_ZeZo.Network.GamePackets.Union.UnionClass> Scores = new SafeDictionary<uint, Mr_ZeZo.Network.GamePackets.Union.UnionClass>(100);
        public static 
bool IsWar = false, FirstRound = false;
        public static 
Time32 ScoreSendStamp, LastWin;
        public static 
Mr_ZeZo.Network.GamePackets.Union.UnionClass PoleKeeper, CurrentTopLeader;
        private static 
string[] scoreMessages;
        public static 
DateTime StartTime;
        public static 
bool Claim
        
{
            
get { return Program.Vars["uwclaim"]; }
            
set { Program.Vars["uwclaim"] = value; }
        }
        public static 
uint KeeperID
        
{
            
get { return Program.Vars["uwkeeperid"]; }
            
set { Program.Vars["uwkeeperid"] = value; }
        }
        public static 
void Initiate()
        {
            
Database.DMaps.LoadMap(1510);
            var 
Map = Kernel.Maps[1510];
            
Pole = (SobNpcSpawn)Map.Npcs[817];
        }
        public static 
void Start()
        {
            
Scores = new SafeDictionary<uint, Mr_ZeZo.Network.GamePackets.Union.UnionClass>(100);
            
StartTime = DateTime.Now;
            
Kernel.SendWorldMessage(new Message("Union war has began!", System.Drawing.Color.Red, Message.Center), Program.Values);
            
FirstRound = true;
            foreach (
Mr_ZeZo.Network.GamePackets.Union.UnionClass clan in Kernel.Unions.Values)
            {
                
clan.WarScore = 0;
            }
            
Claim = false;
            
IsWar = true;
        }

        public static 
void Reset()
        {
            
Scores = new SafeDictionary<uint, Mr_ZeZo.Network.GamePackets.Union.UnionClass>(100);
            
Pole.Hitpoints = Pole.MaxHitpoints;

            foreach (
Mr_ZeZo.Network.GamePackets.Union.UnionClass clan in Kernel.Unions.Values)
            {
                
clan.WarScore = 0;
            }

            
IsWar = true;
        }

        public static 
void FinishRound()
        {
            
LastWin = Time32.Now;

            
FirstRound = false;
            
SortScores(out PoleKeeper);
            if (
PoleKeeper != null)
            {
                
KeeperID = PoleKeeper.ID;
                
Kernel.SendWorldMessage(new Message("The Union, " + PoleKeeper.Name + ", owned by " + PoleKeeper.LeaderName + " has won this Union war round", System.Drawing.Color.Red, Message.Center), Program.Values);

                
Pole.Name = PoleKeeper.Name;
            }
            
Pole.Hitpoints = Pole.MaxHitpoints;
            
SendScreen(Pole.ToArray());
            
Kernel.SendWorldMessage(Pole, Program.Values, (ushort)1510);
            
Reset();
        }

        public static 
void End()
        {
            if (
PoleKeeper != null)
            {
                
Mr_ZeZo.Kernel.SendWorldMessage(new Message(" The Union " + PoleKeeper.Name + " claimed the prize [250.000] ConquerPoints for winning the UnionWar ", System.Drawing.Color.Black, Message.Center), Program.Values);
                
PoleKeeper.PoleKeeper = true;
            }
            else
            {
                
Kernel.SendWorldMessage(new Message(" Union war has ended and there was no winner ", System.Drawing.Color.Red, Message.Center), Program.Values);

            }
            
Claim = true;
            
IsWar = false;
            
UpdatePole(Pole);
        }
        public static 
void SendScreen(byte[] buffer)
        {
            foreach (
Client.GameState client in Program.Values)
            {

                if (
client != null)
                {
                    if (
client.Player != null)
                    {
                        {
                            if (
Kernel.GetDistance(client.Player.X, client.Player.Y, Pole.X, Pole.Y) > 18 && client.Player.MapID == 1510)
                            {
                                continue;
                            }
                            
client.Send(buffer);
                        }
                    }
                }
            }
        }
        public static 
void AddScore(uint addScore, Mr_ZeZo.Network.GamePackets.Union.UnionClass clan)
        {
            if (
clan != null)
            {
                
clan.WarScore += addScore;
                if (!
Scores.ContainsKey(clan.ID))
                    
Scores.Add(clan.ID, clan);
                
SendScores();
                if ((int)
Pole.Hitpoints <= 0)
                {
                    
FinishRound();

                    return;
                }
            }
        }
     
        public static 
void SendScores()
        {
            if (
scoreMessages == null)
                
scoreMessages = new string[0];
            if (
Scores.Count == 0)
                return;
            for (
int c = 0; c < scoreMessages.Length; c++)
            {
                
Message msg = new Message(scoreMessages[c], System.Drawing.Color.Red, c == 0 ? Message.FirstRightCorner : Message.ContinueRightCorner);
                
Kernel.SendWorldMessage(msg, Program.Values, (ushort)1510);
            }
        }

        private static 
void SortScores(out Mr_ZeZo.Network.GamePackets.Union.UnionClass winner)
        {
            
winner = null;
            List<
string> ret = new List<string>();
            
int Place = 0;
            foreach (
Mr_ZeZo.Network.GamePackets.Union.UnionClass clan in Scores.Values.OrderByDescending((p) => p.WarScore))
            {
                if (
Place == 0)
                    
winner = clan;
                
string str = "No  " + (Place + 1).ToString() + ": " + clan.Name + "(" + clan.WarScore + ")";
                
ret.Add(str);
                
Place++;
                if (
Place == 4)
                    break;
            }

            
scoreMessages = ret.ToArray();
        }

        private static 
void UpdatePole(SobNpcSpawn pole)
        {
            new 
Database.MySqlCommand(Mr_ZeZo.Database.MySqlCommandType.UPDATE)
            .
Update("sobnpcs").Set("name", pole.Name).Set("life", Pole.Hitpoints).Where("id", pole.UID).Execute();
        }
    }
} 

قديم 2019-12-09, 12:01 AM
المشاركة 2
zezonever
.:: عضو نشيط ::.
الإجابات المقدمة: 23
  • غير متواجد
افتراضي رد: مشكلة في السورس الي نزلو Mr_ZeZo
ادخل ع World.cs وبعدين روح ع ClanWar

وامسح الرساله ال بتجيلك من الكلان وار والموضوع انتهي

قديم 2019-12-09, 12:14 AM
المشاركة 3
zezonever
.:: عضو نشيط ::.
الإجابات المقدمة: 23
  • غير متواجد
افتراضي رد: مشكلة في السورس الي نزلو Mr_ZeZo
هريحك خالص علشان ميجيش ارور تاني لما تمسح ملف الكلان وار ال بيجي من الورد ابعت عن ملف UnoinWar.cs هتمسح كل ال فيه وهضيف دول وكل سنه وانت طيب خلاص كده المشكله


كود:
// * Created by ZeZoOo
// * Copyright © 2020
// * All rights reserved Mr.ZeZoOo - Project
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mr_ZeZo.Network.GamePackets;
using Mr_ZeZo.Database;

namespace 
Mr_ZeZo.Game
{
    public class 
ClanWar
    
{
        public static 
SobNpcSpawn Pole;
        public static 
SafeDictionary<uint, Clan> Scores = new SafeDictionary<uint, Clan>(100);
        public static 
bool IsWar = false, FirstRound = false;
        public static 
Time32 ScoreSendStamp, LastWin;
        public static 
Clan PoleKeeper, CurrentTopLeader;
        private static 
bool changed = false;
        private static 
string[] scoreMessages;
        public static 
DateTime StartTime;
        public static 
bool Claim
        
{
            
get { return Program.Vars["cwclaim"]; }
            
set { Program.Vars["cwclaim"] = value; }
        }
        public static 
uint KeeperID
        
{
            
get { return Program.Vars["cwkeeperid"]; }
            
set { Program.Vars["cwkeeperid"] = value; }
        }
        public static 
void Initiate()
        {
            
Database.DMaps.LoadMap(1509);
            var 
Map = Kernel.Maps[1509];
            
Pole = (SobNpcSpawn)Map.Npcs[812];
        }
        public static 
void Start()
        {
            
Scores = new SafeDictionary<uint, Clan>(100);
            
StartTime = DateTime.Now;
            
FirstRound = true;
            foreach (
Clan clan in Kernel.Clans.Values)
            {
                
clan.WarScore = 0;
            }
            
Claim = false;
            
IsWar = true;
        }

        public static 
void Reset()
        {
            
Scores = new SafeDictionary<uint, Clan>(100);
            
Pole.Hitpoints = Pole.MaxHitpoints;

            foreach (
Clan clan in Kernel.Clans.Values)
            {
                
clan.WarScore = 0;
            }

            
IsWar = true;
        }

        public static 
void FinishRound()
        {
            
LastWin = Time32.Now;

            
FirstRound = false;
            
SortScores(out PoleKeeper);
            if (
PoleKeeper != null)
            {
                
KeeperID = PoleKeeper.ID;
                
Pole.Name = PoleKeeper.Name;
            }
            
Pole.Hitpoints = Pole.MaxHitpoints;
            
Kernel.SendWorldMessage(Pole, Program.Values, (ushort)1509);
            
Reset();
        }

        public static 
void End()
        {
            if (
PoleKeeper != null)
            {
                
Kernel.SendWorldMessage(new Message("The Union, " + PoleKeeper.Name + ", owned by " + PoleKeeper.LeaderName + " has won " + rates.Clanwarday + " cps!---Clan war has ended!", System.Drawing.Color.White, Message.Center), Program.Values);

                
PoleKeeper.PoleKeeper = true;
            }
            else
            {
                
Kernel.SendWorldMessage(new Message(" Union has ended and there was no winner ", System.Drawing.Color.Red, Message.Center), Program.Values);

            }
            
Claim = true;
            
IsWar = false;
            
UpdatePole(Pole);
        }

        public static 
void AddScore(uint addScore, Clan clan)
        {
            if (
clan != null)
            {
                
clan.WarScore += addScore;
                
changed = true;
                if (!
Scores.ContainsKey(clan.ID))
                    
Scores.Add(clan.ID, clan);
                if ((int)
Pole.Hitpoints <= 0)
                {
                    
FinishRound();

                    return;
                }
            }
        }

        public static 
void SendScores()
        {
            if (
scoreMessages == null)
                
scoreMessages = new string[0];
            if (
Scores.Count == 0)
                return;
            if (
changed)
                
SortScores(out CurrentTopLeader);

            for (
int c = 0; c < scoreMessages.Length; c++)
            {
                
Message msg = new Message(scoreMessages[c], System.Drawing.Color.Red, c == 0 ? Message.FirstRightCorner : Message.ContinueRightCorner);
                
Kernel.SendWorldMessage(msg, Program.Values, (ushort)1510);
            }
        }

        private static 
void SortScores(out Clan winner)
        {
            
winner = null;
            List<
string> ret = new List<string>();
            
int Place = 0;
            foreach (
Clan clan in Scores.Values.OrderByDescending((p) => p.WarScore))
            {
                if (
Place == 0)
                    
winner = clan;
                
string str = "No  " + (Place + 1).ToString() + ": " + clan.Name + "(" + clan.WarScore + ")";
                
ret.Add(str);
                
Place++;
                if (
Place == 4)
                    break;
            }

            
changed = false;
            
scoreMessages = ret.ToArray();
        }

        private static 
void UpdatePole(SobNpcSpawn pole)
        {
            new 
Database.MySqlCommand(Mr_ZeZo.Database.MySqlCommandType.UPDATE)
            .
Update("sobnpcs").Set("name", pole.Name).Set("life", Pole.Hitpoints).Where("id", pole.UID).Execute();
        }
    }
    public class 
UnionWar
    
{
        public static 
SobNpcSpawn Pole;
        public static 
SafeDictionary<uint, Mr_ZeZo.Network.GamePackets.Union.UnionClass> Scores = new SafeDictionary<uint, Mr_ZeZo.Network.GamePackets.Union.UnionClass>(100);
        public static 
bool IsWar = false, FirstRound = false;
        public static 
Time32 ScoreSendStamp, LastWin;
        public static 
Mr_ZeZo.Network.GamePackets.Union.UnionClass PoleKeeper, CurrentTopLeader;
        private static 
string[] scoreMessages;
        public static 
DateTime StartTime;
        public static 
bool Claim
        
{
            
get { return Program.Vars["uwclaim"]; }
            
set { Program.Vars["uwclaim"] = value; }
        }
        public static 
uint KeeperID
        
{
            
get { return Program.Vars["uwkeeperid"]; }
            
set { Program.Vars["uwkeeperid"] = value; }
        }
        public static 
void Initiate()
        {
            
Database.DMaps.LoadMap(1510);
            var 
Map = Kernel.Maps[1510];
            
Pole = (SobNpcSpawn)Map.Npcs[817];
        }
        public static 
void Start()
        {
            
Scores = new SafeDictionary<uint, Mr_ZeZo.Network.GamePackets.Union.UnionClass>(100);
            
StartTime = DateTime.Now;
            
Kernel.SendWorldMessage(new Message("Union war has began!", System.Drawing.Color.Red, Message.Center), Program.Values);
            
FirstRound = true;
            foreach (
Mr_ZeZo.Network.GamePackets.Union.UnionClass clan in Kernel.Unions.Values)
            {
                
clan.WarScore = 0;
            }
            
Claim = false;
            
IsWar = true;
        }

        public static 
void Reset()
        {
            
Scores = new SafeDictionary<uint, Mr_ZeZo.Network.GamePackets.Union.UnionClass>(100);
            
Pole.Hitpoints = Pole.MaxHitpoints;

            foreach (
Mr_ZeZo.Network.GamePackets.Union.UnionClass clan in Kernel.Unions.Values)
            {
                
clan.WarScore = 0;
            }

            
IsWar = true;
        }

        public static 
void FinishRound()
        {
            
LastWin = Time32.Now;

            
FirstRound = false;
            
SortScores(out PoleKeeper);
            if (
PoleKeeper != null)
            {
                
KeeperID = PoleKeeper.ID;
                
Kernel.SendWorldMessage(new Message("The Union, " + PoleKeeper.Name + ", owned by " + PoleKeeper.LeaderName + " has won this Union war round", System.Drawing.Color.Red, Message.Center), Program.Values);

                
Pole.Name = PoleKeeper.Name;
            }
            
Pole.Hitpoints = Pole.MaxHitpoints;
            
SendScreen(Pole.ToArray());
            
Kernel.SendWorldMessage(Pole, Program.Values, (ushort)1510);
            
Reset();
        }

        public static 
void End()
        {
            if (
PoleKeeper != null)
            {
                
Mr_ZeZo.Kernel.SendWorldMessage(new Message(" The Union " + PoleKeeper.Name + " claimed the prize [250.000] ConquerPoints for winning the UnionWar ", System.Drawing.Color.Black, Message.Center), Program.Values);
                
PoleKeeper.PoleKeeper = true;
            }
            else
            {
                
Kernel.SendWorldMessage(new Message(" Union war has ended and there was no winner ", System.Drawing.Color.Red, Message.Center), Program.Values);

            }
            
Claim = true;
            
IsWar = false;
            
UpdatePole(Pole);
        }
        public static 
void SendScreen(byte[] buffer)
        {
            foreach (
Client.GameState client in Program.Values)
            {

                if (
client != null)
                {
                    if (
client.Player != null)
                    {
                        {
                            if (
Kernel.GetDistance(client.Player.X, client.Player.Y, Pole.X, Pole.Y) > 18 && client.Player.MapID == 1510)
                            {
                                continue;
                            }
                            
client.Send(buffer);
                        }
                    }
                }
            }
        }
        public static 
void AddScore(uint addScore, Mr_ZeZo.Network.GamePackets.Union.UnionClass clan)
        {
            if (
clan != null)
            {
                
clan.WarScore += addScore;
                if (!
Scores.ContainsKey(clan.ID))
                    
Scores.Add(clan.ID, clan);
                
SendScores();
                if ((int)
Pole.Hitpoints <= 0)
                {
                    
FinishRound();

                    return;
                }
            }
        }
     
        public static 
void SendScores()
        {
            if (
scoreMessages == null)
                
scoreMessages = new string[0];
            if (
Scores.Count == 0)
                return;
            for (
int c = 0; c < scoreMessages.Length; c++)
            {
                
Message msg = new Message(scoreMessages[c], System.Drawing.Color.Red, c == 0 ? Message.FirstRightCorner : Message.ContinueRightCorner);
                
Kernel.SendWorldMessage(msg, Program.Values, (ushort)1510);
            }
        }

        private static 
void SortScores(out Mr_ZeZo.Network.GamePackets.Union.UnionClass winner)
        {
            
winner = null;
            List<
string> ret = new List<string>();
            
int Place = 0;
            foreach (
Mr_ZeZo.Network.GamePackets.Union.UnionClass clan in Scores.Values.OrderByDescending((p) => p.WarScore))
            {
                if (
Place == 0)
                    
winner = clan;
                
string str = "No  " + (Place + 1).ToString() + ": " + clan.Name + "(" + clan.WarScore + ")";
                
ret.Add(str);
                
Place++;
                if (
Place == 4)
                    break;
            }

            
scoreMessages = ret.ToArray();
        }

        private static 
void UpdatePole(SobNpcSpawn pole)
        {
            new 
Database.MySqlCommand(Mr_ZeZo.Database.MySqlCommandType.UPDATE)
            .
Update("sobnpcs").Set("name", pole.Name).Set("life", Pole.Hitpoints).Where("id", pole.UID).Execute();
        }
    }
} 


قديم 2019-12-09, 03:44 PM
المشاركة 4
Alaa Ghanem
.:: عضو نشيط ::.
الإجابات المقدمة: 4
  • غير متواجد
افتراضي رد: مشكلة في السورس الي نزلو Mr_ZeZo
تمام الله ينور يا صحبي الايرور اتشال 100%
بس في مشكلة تاني في البوله مهما تضرب في البوله مبتضربش

قديم 2019-12-10, 06:47 PM
المشاركة 5
Mawdo3jded
.:: عضو مميز ::.
الإجابات المقدمة: 13
  • غير متواجد
افتراضي رد: مشكلة في السورس الي نزلو Mr_ZeZo
انا جربت الحل و الارور متشلش ؟

قديم 2019-12-10, 06:54 PM
المشاركة 6
Mawdo3jded
.:: عضو مميز ::.
الإجابات المقدمة: 13
  • غير متواجد
افتراضي رد: مشكلة في السورس الي نزلو Mr_ZeZo
هريحك خالص علشان ميجيش ارور تاني لما تمسح ملف الكلان وار ال بيجي من الورد ابعت عن ملف UnoinWar.cs هتمسح كل ال فيه وهضيف دول وكل سنه وانت طيب خلاص كده المشكله


كود:
// * Created by ZeZoOo
// * Copyright © 2020
// * All rights reserved Mr.ZeZoOo - Project
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mr_ZeZo.Network.GamePackets;
using Mr_ZeZo.Database;

namespace 
Mr_ZeZo.Game
{
    public class 
ClanWar
    
{
        public static 
SobNpcSpawn Pole;
        public static 
SafeDictionary<uint, Clan> Scores = new SafeDictionary<uint, Clan>(100);
        public static 
bool IsWar = false, FirstRound = false;
        public static 
Time32 ScoreSendStamp, LastWin;
        public static 
Clan PoleKeeper, CurrentTopLeader;
        private static 
bool changed = false;
        private static 
string[] scoreMessages;
        public static 
DateTime StartTime;
        public static 
bool Claim
        
{
            
get { return Program.Vars["cwclaim"]; }
            
set { Program.Vars["cwclaim"] = value; }
        }
        public static 
uint KeeperID
        
{
            
get { return Program.Vars["cwkeeperid"]; }
            
set { Program.Vars["cwkeeperid"] = value; }
        }
        public static 
void Initiate()
        {
            
Database.DMaps.LoadMap(1509);
            var 
Map = Kernel.Maps[1509];
            
Pole = (SobNpcSpawn)Map.Npcs[812];
        }
        public static 
void Start()
        {
            
Scores = new SafeDictionary<uint, Clan>(100);
            
StartTime = DateTime.Now;
            
FirstRound = true;
            foreach (
Clan clan in Kernel.Clans.Values)
            {
                
clan.WarScore = 0;
            }
            
Claim = false;
            
IsWar = true;
        }

        public static 
void Reset()
        {
            
Scores = new SafeDictionary<uint, Clan>(100);
            
Pole.Hitpoints = Pole.MaxHitpoints;

            foreach (
Clan clan in Kernel.Clans.Values)
            {
                
clan.WarScore = 0;
            }

            
IsWar = true;
        }

        public static 
void FinishRound()
        {
            
LastWin = Time32.Now;

            
FirstRound = false;
            
SortScores(out PoleKeeper);
            if (
PoleKeeper != null)
            {
                
KeeperID = PoleKeeper.ID;
                
Pole.Name = PoleKeeper.Name;
            }
            
Pole.Hitpoints = Pole.MaxHitpoints;
            
Kernel.SendWorldMessage(Pole, Program.Values, (ushort)1509);
            
Reset();
        }

        public static 
void End()
        {
            if (
PoleKeeper != null)
            {
                
Kernel.SendWorldMessage(new Message("The Union, " + PoleKeeper.Name + ", owned by " + PoleKeeper.LeaderName + " has won " + rates.Clanwarday + " cps!---Clan war has ended!", System.Drawing.Color.White, Message.Center), Program.Values);

                
PoleKeeper.PoleKeeper = true;
            }
            else
            {
                
Kernel.SendWorldMessage(new Message(" Union has ended and there was no winner ", System.Drawing.Color.Red, Message.Center), Program.Values);

            }
            
Claim = true;
            
IsWar = false;
            
UpdatePole(Pole);
        }

        public static 
void AddScore(uint addScore, Clan clan)
        {
            if (
clan != null)
            {
                
clan.WarScore += addScore;
                
changed = true;
                if (!
Scores.ContainsKey(clan.ID))
                    
Scores.Add(clan.ID, clan);
                if ((int)
Pole.Hitpoints <= 0)
                {
                    
FinishRound();

                    return;
                }
            }
        }

        public static 
void SendScores()
        {
            if (
scoreMessages == null)
                
scoreMessages = new string[0];
            if (
Scores.Count == 0)
                return;
            if (
changed)
                
SortScores(out CurrentTopLeader);

            for (
int c = 0; c < scoreMessages.Length; c++)
            {
                
Message msg = new Message(scoreMessages[c], System.Drawing.Color.Red, c == 0 ? Message.FirstRightCorner : Message.ContinueRightCorner);
                
Kernel.SendWorldMessage(msg, Program.Values, (ushort)1510);
            }
        }

        private static 
void SortScores(out Clan winner)
        {
            
winner = null;
            List<
string> ret = new List<string>();
            
int Place = 0;
            foreach (
Clan clan in Scores.Values.OrderByDescending((p) => p.WarScore))
            {
                if (
Place == 0)
                    
winner = clan;
                
string str = "No  " + (Place + 1).ToString() + ": " + clan.Name + "(" + clan.WarScore + ")";
                
ret.Add(str);
                
Place++;
                if (
Place == 4)
                    break;
            }

            
changed = false;
            
scoreMessages = ret.ToArray();
        }

        private static 
void UpdatePole(SobNpcSpawn pole)
        {
            new 
Database.MySqlCommand(Mr_ZeZo.Database.MySqlCommandType.UPDATE)
            .
Update("sobnpcs").Set("name", pole.Name).Set("life", Pole.Hitpoints).Where("id", pole.UID).Execute();
        }
    }
    public class 
UnionWar
    
{
        public static 
SobNpcSpawn Pole;
        public static 
SafeDictionary<uint, Mr_ZeZo.Network.GamePackets.Union.UnionClass> Scores = new SafeDictionary<uint, Mr_ZeZo.Network.GamePackets.Union.UnionClass>(100);
        public static 
bool IsWar = false, FirstRound = false;
        public static 
Time32 ScoreSendStamp, LastWin;
        public static 
Mr_ZeZo.Network.GamePackets.Union.UnionClass PoleKeeper, CurrentTopLeader;
        private static 
string[] scoreMessages;
        public static 
DateTime StartTime;
        public static 
bool Claim
        
{
            
get { return Program.Vars["uwclaim"]; }
            
set { Program.Vars["uwclaim"] = value; }
        }
        public static 
uint KeeperID
        
{
            
get { return Program.Vars["uwkeeperid"]; }
            
set { Program.Vars["uwkeeperid"] = value; }
        }
        public static 
void Initiate()
        {
            
Database.DMaps.LoadMap(1510);
            var 
Map = Kernel.Maps[1510];
            
Pole = (SobNpcSpawn)Map.Npcs[817];
        }
        public static 
void Start()
        {
            
Scores = new SafeDictionary<uint, Mr_ZeZo.Network.GamePackets.Union.UnionClass>(100);
            
StartTime = DateTime.Now;
            
Kernel.SendWorldMessage(new Message("Union war has began!", System.Drawing.Color.Red, Message.Center), Program.Values);
            
FirstRound = true;
            foreach (
Mr_ZeZo.Network.GamePackets.Union.UnionClass clan in Kernel.Unions.Values)
            {
                
clan.WarScore = 0;
            }
            
Claim = false;
            
IsWar = true;
        }

        public static 
void Reset()
        {
            
Scores = new SafeDictionary<uint, Mr_ZeZo.Network.GamePackets.Union.UnionClass>(100);
            
Pole.Hitpoints = Pole.MaxHitpoints;

            foreach (
Mr_ZeZo.Network.GamePackets.Union.UnionClass clan in Kernel.Unions.Values)
            {
                
clan.WarScore = 0;
            }

            
IsWar = true;
        }

        public static 
void FinishRound()
        {
            
LastWin = Time32.Now;

            
FirstRound = false;
            
SortScores(out PoleKeeper);
            if (
PoleKeeper != null)
            {
                
KeeperID = PoleKeeper.ID;
                
Kernel.SendWorldMessage(new Message("The Union, " + PoleKeeper.Name + ", owned by " + PoleKeeper.LeaderName + " has won this Union war round", System.Drawing.Color.Red, Message.Center), Program.Values);

                
Pole.Name = PoleKeeper.Name;
            }
            
Pole.Hitpoints = Pole.MaxHitpoints;
            
SendScreen(Pole.ToArray());
            
Kernel.SendWorldMessage(Pole, Program.Values, (ushort)1510);
            
Reset();
        }

        public static 
void End()
        {
            if (
PoleKeeper != null)
            {
                
Mr_ZeZo.Kernel.SendWorldMessage(new Message(" The Union " + PoleKeeper.Name + " claimed the prize [250.000] ConquerPoints for winning the UnionWar ", System.Drawing.Color.Black, Message.Center), Program.Values);
                
PoleKeeper.PoleKeeper = true;
            }
            else
            {
                
Kernel.SendWorldMessage(new Message(" Union war has ended and there was no winner ", System.Drawing.Color.Red, Message.Center), Program.Values);

            }
            
Claim = true;
            
IsWar = false;
            
UpdatePole(Pole);
        }
        public static 
void SendScreen(byte[] buffer)
        {
            foreach (
Client.GameState client in Program.Values)
            {

                if (
client != null)
                {
                    if (
client.Player != null)
                    {
                        {
                            if (
Kernel.GetDistance(client.Player.X, client.Player.Y, Pole.X, Pole.Y) > 18 && client.Player.MapID == 1510)
                            {
                                continue;
                            }
                            
client.Send(buffer);
                        }
                    }
                }
            }
        }
        public static 
void AddScore(uint addScore, Mr_ZeZo.Network.GamePackets.Union.UnionClass clan)
        {
            if (
clan != null)
            {
                
clan.WarScore += addScore;
                if (!
Scores.ContainsKey(clan.ID))
                    
Scores.Add(clan.ID, clan);
                
SendScores();
                if ((int)
Pole.Hitpoints <= 0)
                {
                    
FinishRound();

                    return;
                }
            }
        }
     
        public static 
void SendScores()
        {
            if (
scoreMessages == null)
                
scoreMessages = new string[0];
            if (
Scores.Count == 0)
                return;
            for (
int c = 0; c < scoreMessages.Length; c++)
            {
                
Message msg = new Message(scoreMessages[c], System.Drawing.Color.Red, c == 0 ? Message.FirstRightCorner : Message.ContinueRightCorner);
                
Kernel.SendWorldMessage(msg, Program.Values, (ushort)1510);
            }
        }

        private static 
void SortScores(out Mr_ZeZo.Network.GamePackets.Union.UnionClass winner)
        {
            
winner = null;
            List<
string> ret = new List<string>();
            
int Place = 0;
            foreach (
Mr_ZeZo.Network.GamePackets.Union.UnionClass clan in Scores.Values.OrderByDescending((p) => p.WarScore))
            {
                if (
Place == 0)
                    
winner = clan;
                
string str = "No  " + (Place + 1).ToString() + ": " + clan.Name + "(" + clan.WarScore + ")";
                
ret.Add(str);
                
Place++;
                if (
Place == 4)
                    break;
            }

            
scoreMessages = ret.ToArray();
        }

        private static 
void UpdatePole(SobNpcSpawn pole)
        {
            new 
Database.MySqlCommand(Mr_ZeZo.Database.MySqlCommandType.UPDATE)
            .
Update("sobnpcs").Set("name", pole.Name).Set("life", Pole.Hitpoints).Where("id", pole.UID).Execute();
        }
    }
} 

نفس المشكله عندي بس انا ممسحتش الكلان وار ؟ وجربت اعمل الحل الي بتقول عليه امسح كل ال في كلاس الuoinwar
وحتيط الاكود الي فوق وبردو بيجي الاور بس انا ممسحش الكلان واره ؟ هوه الكلان وار مش شغال ؟ امسحو ليه انا مش عاوز امسحو وعاوز احل الارور ؟


العلامات المرجعية



الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1)
 

الانتقال السريع

المواضيع المتشابهه للموضوع: مشكلة في السورس الي نزلو Mr_ZeZo
الموضوع كاتب الموضوع المنتدى مشاركات آخر مشاركة
احسن وافضل سورس ع موقع النت كلها اقسم بالله ما هتشوف زي السورس ده Source Mr_ZeZo ليكم zezonever سورسات كونكر 318 2026-10-30 03:14 PM
مشكلة محدش عارف يحلها لما نشوف اخرتها السورس الي نزلو MrZezo Alaa Ghanem مشكلات السيرفيرات كونكر الشخصيه 6 2019-12-15 06:08 PM
مشكلة الاسامى المزخرفة فى السورس بتبقي ؟ MaNGaWy مشكلات السيرفيرات كونكر الشخصيه 5 2019-12-10 04:48 PM
مشكلة فى تشغيل السورس MeGoo مشكلات السيرفيرات كونكر الشخصيه 6 2019-08-06 07:37 PM
حل مشكلة اختفاء اي شيء في السورس لما تفتح الاكونت Hazem تطوير سيرفرات كونكر 1 2019-06-19 10:16 PM


الساعة الآن 11:43 PM