منتدي اكواد

منتدي اكواد (https://code.vpscairo.com/index.php)
-   تطوير سيرفرات كونكر (https://code.vpscairo.com/forumdisplay.php?f=11)
-   -   اضافه حرب ClanWar لمن يعاني في مشاكل عنده (https://code.vpscairo.com/showthread.php?t=3267)

Hassan Emprator 2019-12-09 09:12 PM

اضافه حرب ClanWar لمن يعاني في مشاكل عنده
 

اولا كدا سيبك من اي اضافه عندك بعيد عن كلاس UnionWar دي اضافه مظبوطه وهنضيفها كامله انشاء الله


اعمل كلاس وسميه ClanWar2

وضيف فيه

كود PHP:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EmpratorServer.Network.GamePackets;
using EmpratorServer.Database;

namespace 
EmpratorServer.Game
{
    public class 
ClanWar
    
{
        public static 
SobNpcSpawn Pole;
        public static 
SafeDictionary<uintClanScores = new SafeDictionary<uintClan>(100);
        public static 
bool IsWar falseFirstRound false;
        public static 
Time32 ScoreSendStampLastWin;
        public static 
Clan PoleKeeperCurrentTopLeader;
        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()
        {
            var 
Map Kernel.Maps[1509];
            
Pole = (SobNpcSpawn)Map.Npcs[812];
        }
        public static 
void Start()
        {
            
Scores = new SafeDictionary<uintClan>(100);
            
StartTime DateTime.Now;
            
Kernel.SendWorldMessage(new Message("Clan war has began!"System.Drawing.Color.RedMessage.Center), Program.Values);
            
FirstRound true;
            foreach (
Clan clan in Kernel.Clans.Values)
            {
                
clan.WarScore 0;
            }
            
Claim false;
            
IsWar true;
        }

        public static 
void Reset()
        {
            
Scores = new SafeDictionary<uintClan>(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;
                
Kernel.SendWorldMessage(new Message("The Clan, " PoleKeeper.Name ", owned by " PoleKeeper.LeaderName " has won this Clan war round!"System.Drawing.Color.RedMessage.Center), Program.Values);

                
Pole.Name PoleKeeper.Name;
            }
            
Pole.Hitpoints Pole.MaxHitpoints;
            
Kernel.SendWorldMessage(PoleProgram.Values, (ushort)1509);
            
Reset();
        }

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

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

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

        public static 
void AddScore(uint addScoreClan clan)
        {
            if (
clan != null)
            {
                
clan.WarScore += addScore;
                
changed true;
                if (!
Scores.ContainsKey(clan.ID))
                    
Scores.Add(clan.IDclan);
                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 0scoreMessages.Lengthc++)
            {
                
Message msg = new Message(scoreMessages[c], System.Drawing.Color.Red== Message.FirstRightCorner Message.ContinueRightCorner);
                
Kernel.SendWorldMessage(msgProgram.Values, (ushort)1509);
            }
        }

        private static 
void SortScores(out Clan winner)
        {
            
winner null;
            List<
stringret = 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(EmpratorServer.Database.MySqlCommandType.UPDATE)
            .
Update("sobnpcs").Set("name"pole.Name).Set("life"Pole.Hitpoints).Where("id"pole.UID).Execute();
        }
    }


كلاس Handel

ضيف

تخت

كود PHP:

 if (attacker.MapID == 2075


كود PHP:

            if (attacker.MapID == 1509)
            {
                if (
attacked.UID == 812)
                {
                    
Clan clan attacker.GetClan;
                    if (
Game.ClanWar.PoleKeeper == clan)
                        return;
                    if (
attacked.Hitpoints <= damage)
                        
attacked.Hitpoints 0;
                    
Game.ClanWar.AddScore(damageclan);
                }
            } 

ابحث عن

كود بلغة HTML:

if (attacker.MapID == 2075)
ضيف

كود PHP:

            if (attacker.MapID == 1509)
            {
                if (
attacker.ClanId == || !Game.ClanWar.IsWar)
                {
                    if (
attacked.UID == 812)
                    {
                        return 
false;
                    }
                }
                if (
Game.ClanWar.PoleKeeper != null)
                {
                    if (
Game.ClanWar.PoleKeeper == attacker.GetClan)
                    {
                        if (
attacked.UID == 812)
                        {
                            return 
false;
                        }
                    }
                }
            } 


الانبي سي

كود PHP:

#region CLANWAR
                
case 48116:
                    {
                        switch (
npcRequest.OptionID)
                        {
                            case 
0:
                                {
                                    
dialog.Text("Hello there. Do you want to Join The ClanWar?.");
                                    
dialog.Option("Yes Please."1);
                                    
dialog.Option("Claim Prize."2);
                                    
dialog.Option("Just Passing By!"255);
                                    
dialog.Send();
                                    break;
                                }
                            case 
1:
                                {
                                    if (
ClanWar.IsWar)
                                    {
                                        
client.Entity.Teleport(150982118);
                                        
client.Entity.PKMode Game.Enums.PKMode.PK;
                                        
client.Send(new Data(true) { UID client.Entity.UIDID Data.ChangePKModedwParam = (uint)client.Entity.PKMode });
                                    }
                                    else
                                    {
                                        
dialog.Text("The War Has Not Started Start At [8.00] And [20.00]");
                                        
dialog.Option("Aww ok!"255);
                                        
dialog.Send();
                                    }
                                    break;
                                }
                            case 
2:
                                {
                                    if (
ClanWar.KeeperID != && !ClanWar.IsWar && ClanWar.Claim && client.Entity.ClanId == ClanWar.KeeperID && client.Entity.ClanRank == Clan.Ranks.ClanLeader)
                                    {

                                        
Program.AddWarLog("ClanWar"" . "client.Entity.Name);
                                        
ClanWar.Claim false;
                                        
ClanWar.KeeperID 0;
                                        
client.Entity.ConquerPoints += ServerRates.Clan;

                                        
client.Entity.killerpoints += 100;
                                        
client.Entity.AddTopStatus(Update.Flags2.Top8Archer2DateTime.Now.AddDays(1));
                                        
EmpratorServer.Kernel.SendWorldMessage(new Message("Congratulations! " client.Entity.Name " Leader of " client.Entity.ClanName " The winner Clan has Claimed Clan War Prize " ServerRates.Clan " cps + 100 Vip point's !"System.Drawing.Color.WhiteMessage.TopLeft), Program.Values);
                                    }
                                    else
                                    {
                                        
dialog.Text("Sorry you dont have Any Prize to claim only CL of the winner CLAN can claim Prize After CW");
                                        
dialog.Option("Ahh."255);
                                        
dialog.Send();
                                    }

                                    break;
                                }
                        }
                        break;
                    }
                case 
4482115:
                    {
                        switch (
npcRequest.OptionID)
                        {
                            case 
0:
                                {
                                    
dialog.Text("Hello there. Do you want to Teleport To Twincity.");
                                    
dialog.Option(" Send Me There. "1);
                                    
dialog.Option("Just Passing By!"255);
                                    
dialog.Send();
                                    break;
                                }
                            case 
1:
                                {
                                    
client.Entity.Teleport(1002300266);
                                    break;
                                }
                        }
                        break;
                    }
                
#endregion 

بعدين سيرش عا

كود PHP:

public static readonly System.Collections.Generic.List<ushortPKFreeMaps = new System.Collections.Generic.List<ushort>() 


وضيف

كود PHP:

1509

ودا الانبي سي بتاع الخروج

وابححث عن

كود PHP:

public class Start 

وضيف

كود PHP:

public static bool ClanWar
            
{
                
get
                
{
                    return 
now.Hour == 14 || now.Hour == 2;
                }
            } 

ولو جالك ايرور في GetClan

ضيف في Entity

كود PHP:

public Clan GetClan
        
{
            
get
            
{
                
Clan cl;
                
Kernel.Clans.TryGetValue(ClanIdout cl);
                return 
cl;
            }
        }
        
string clan ""

ودا الاوتو انفنت

كود PHP:

#region Clan War
                
if ((Now64.Hour == 20 || Now64.Hour == 8) && Now64.Minute == 00 && Now64.Second == && !ClanWar.IsWar)
                {
                    
Game.ClanWar.Start();
                    
ClanWarAI false;
                    if (
Now64.Hour != 8)
                    {
                        
ClanWarAI Now64.Hour != 8;
                        foreach (var 
client in Program.Values)
                            if (
client.Entity.GuildID != 0)
                                
client.MessageBox("ClanWar Has Begun! Would You Like To Join This War ...?",
                                    
=> { p.Entity.Teleport(1002284146); }, null);
                    }
                }
                if (
Now64.Hour == && Now64.Minute == 10 && !ClanWarAI)
                {
                    
ClanWarAI true;
                    foreach (var 
client in Program.Values)
                        if (
client.Entity.GuildID != 0)
                            
client.MessageBox("ClanWar Has Begun! Would You Like To Join This War ...?",
                                
=> { p.Entity.Teleport(1002284146); }, null);
                }
                if ((
Now64.Hour == 21 || Now64.Hour == 9) && Now64.Minute == 00 && ClanWar.IsWar)
                {
                    
Game.ClanWar.End();
                }
                if (
Game.ClanWar.IsWar)
                {
                    if (
Time32.Now Game.ClanWar.ScoreSendStamp.AddSeconds(3))
                    {
                        
Game.ClanWar.ScoreSendStamp Time32.Now;
                        
Game.ClanWar.SendScores();
                    }
                
            }
            
#endregion 



وحمل الملاف دا في bin/debug/database


كود PHP:

https://up.top4top.net/downloadf-1438rax941-rar.html 

وبكدا لااضافه كامله انشاء الله والسلام عليكم ورحمه الله

محمد ياسر 2019-12-09 11:55 PM

رد: اضافه حرب ClanWar لمن يعاني في مشاكل عنده
 
عاش ياض

Hassan Emprator 2019-12-10 12:08 AM

رد: اضافه حرب ClanWar لمن يعاني في مشاكل عنده
 
اقتباس:

المشاركة الأصلية كتبت بواسطة Hazem (المشاركة 24664)
عاش ياض

قلبي <3

Hassan Emprator 2019-12-10 09:22 PM

رد: اضافه حرب ClanWar لمن يعاني في مشاكل عنده
 
;)
اقتباس:

المشاركة الأصلية كتبت بواسطة Hazem (المشاركة 24664)
عاش ياض


Alaa Ghanem 2019-12-13 12:49 AM

رد: اضافه حرب ClanWar لمن يعاني في مشاكل عنده
 
الله ينور يا عم حسن شكراً جداً بس لسه بتواجهني مشكله صغيره
لينك الموضوع
عفواً لايمكن عرض الروابط إلا بعد الرد على الموضوع

تفريباً المشكله في SobNpcSpawn Pole بس مش عارف اوصل لحل

abdocoder 2020-04-01 07:23 PM

رد: اضافه حرب ClanWar لمن يعاني في مشاكل عنده
 
شكرا


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

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