السلام عليكم وكل سنه وانتو طيبين وعيد سعيد عليكم جميعا
دي ارينا للجيلدات يعني الليدر بتاع الجيلد يخش يكلم الان بي سي ويحدد السي بي اس وسم الليدر بتاع الجيدل التانيه لو وافق رساله هتييجي لكل الي في الجيلدين يخشوا تحدي ولما يخشوا لو كل الي في جيلد معينه مات خلاص الجيلد التانيه بتفوز (ممكن تلغي الواتر عشان لو فيها وترات اللعبه هيكون صعب بس اشطا )
نبدا ع طول
كلاس جديد
كود:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Project_Terror_v2.Client;
using System.Drawing;
using Project_Terror_v2.Role.Instance;
using Project_Terror_v2.Game.MsgServer;
namespace Project_Terror_v2.Game
{
public class Guildarena
{
public GameClient Guildleader1;
public GameClient Guildleader2;
public Guild Guild1;
public Guild Guild2;
public uint Map = 1477;
public uint ValueFight;
public Guildarena(GameClient c1, GameClient c2)
{
Guildleader1 = c1;
Guildleader2 = c2;
Guild1 = Guildleader1.Player.MyGuild;
Guild2 = Guildleader2.Player.MyGuild;
}
public void import()
{
//if (!Kernel.Maps.ContainsKey(700))
// new Map(700, Database.DMaps.MapPaths[700]);
foreach (var Member in Guild1.Members.Values)
{
var import = Member.Client;
if (import != null)
{
if (CanFight(import))
{
import.Player.MessageBox("Your Guild Will Fight In Guild Arena For [" + ValueFight + "]CPS You Like To Join", p =>
{
p.Player.GuildArenaBattle = this;
//p.Player.SetPkMode(Role.Flags.PKMode.Guild);
Random R = new Random();
int Nr = R.Next(1, 4);
if (Nr == 1) p.Teleport(51, 73, 1477);
if (Nr == 2) p.Teleport(33, 34, 1477);
if (Nr == 3) p.Teleport(67, 34, 1477);
if (Nr == 4) p.Teleport(51, 73, 1477);
p.Player.RemoveFlag(MsgUpdate.Flags.Ride);
p.Player.SetPkMode(Project_Terror_v2.Role.Flags.PKMode.PK);
p.Player.GuildArenaBattleFight = this;
}, null);
}
}
}
foreach (var Member in Guild2.Members.Values)
{
var import = Member.Client;
if (import != null)
{
if (CanFight(import))
{
import.Player.MessageBox("Your Guild Will Fight In Guild Arena For [" + ValueFight + "]CPS You Like To Join", p =>
{
p.Player.GuildArenaBattle = this;
//p.Player.SetPkMode(Role.Flags.PKMode.Guild);
Random R = new Random();
int Nr = R.Next(1, 4);
if (Nr == 1) p.Teleport(51, 73, 1477);
if (Nr == 2) p.Teleport(33, 34, 1477);
if (Nr == 3) p.Teleport(67, 34, 1477);
if (Nr == 4) p.Teleport(51, 73, 1477);
p.Player.RemoveFlag(MsgUpdate.Flags.Ride);
p.Player.SetPkMode(Project_Terror_v2.Role.Flags.PKMode.PK);
p.Player.GuildArenaBattleFight = this;
}, null);
}
}
}
}
private bool CanFight(Client.GameClient client) // دي عشان تمنع الناس الي في اماكن معينه يجيلها الرساله
{
if (client.Player.ContainFlag(MsgUpdate.Flags.SoulShackle)) return false;
if (client.Map.BaseID == 1038) return false;
if (client.Map.BaseID == 700) return false;
if (client.Player.Map >= 1090 && client.Player.Map <= 1094) return false;
if (client.Player.Map >= 1505 && client.Player.Map <= 1509) return false;
if (client.Player.Map == 1081) return false;
return (!Program.FreePkMap.Contains(client.Map.ID) || client.Map.ID == 1005);
}
private void KickAll() // دي تطلع كل الناس من الارينا
{
var allinmap = Database.Server.GamePoll.Values.ToArray().Where(p => p.Player.Map == 1477).ToArray();
if (allinmap != null)
{
foreach (var p in allinmap)
p.Teleport(300, 279, 1002);
}
}
private void End(Guild winner, Guild Loser) // النهايه
{
if (winner == null || Loser == null)
KickAll();
if (winner.Members == null || Loser.Members == null)
KickAll();
if (winner.Members.Count == 0 || Loser.Members.Count == 0)
KickAll();
//var count = winner.Members.Values.Where(mem => mem.Client != null).Count(mem => !mem.Client.Player.Dead12 && mem.Client.Player.Map == Map.ID);
//count = Math.Max(1, count);
foreach (var mem in winner.Members.Values)
{
var Client = mem.Client;
if (Client != null)
{
if (Client.Player.GuildRank == Role.Flags.GuildMemberRank.GuildLeader)
{
Client.Player.ConquerPoints += ValueFight;
}
Client.Teleport(300, 279, 1002);
}
}
//foreach (var mem in Loser.Members.Values)
//{
// var Client = mem.Client;
// if (Client != null)
// {
// using (var rec = new ServerSockets.RecycledPacket())
// {
// var stream = rec.GetStream();
// Client.Player.Revive(stream);
// }
// //Client.Teleport(300, 279, 1002);
// }
//}
Program.RoomGuild = false;
}
public void CheakToEnd(GameClient gameClient, bool dc = false)
{
bool GuildSurive1 = false;
bool GuildSurive2 = false;
//if (dc && gameClient.Player.GuildRank == Role.Flags.GuildMemberRank.GuildLeader)
//{
// if (Guildleader1 == gameClient)
// End(Guild2, Guild1);
// else if (Guildleader2 == gameClient)
// End(Guild1, Guild2);
//}
GuildSurive1 = Guild1.Members.Values.Where(mem => mem.Client != null).Any(mem => !mem.Client.Player.Dead12 && mem.Client.Player.Map == 1477);
GuildSurive2 = Guild2.Members.Values.Where(mem => mem.Client != null).Any(mem => !mem.Client.Player.Dead12 && mem.Client.Player.Map == 1477);
if (!GuildSurive1 && GuildSurive2)
End(Guild2, Guild1);
else if (!GuildSurive2 && GuildSurive1)
End(Guild1, Guild2);
}
}
}
الان بي سي
كود:
[Npc(NpcID.GuildArena)]
public static void GuildArena(Client.GameClient client, ServerSockets.Packet stream, byte Option, string Input, uint id)
{
Dialog dialog = new Dialog(client, stream);
switch (Option)
{
case 0:
{
if (client.Player.MyGuild != null)
{
if (client.Player.GuildRank == Role.Flags.GuildMemberRank.GuildLeader)
{
dialog.Text("Hello Man i am GuildArena i can make a challange (GUild X Guild). \n")
.AddText("First you should be a Guild Leader to make a challange with anther Guild. \n")
.AddText("Then Give me challangeCps Finally give me the name of leader of the guild you want to challange it. \n")
.AddText("You should know that the smallest Cps to challange is [1,000,000]");
if (Program.RoomGuild)
dialog.AddOption("ChallangeGuild[Opened]", 1);
else
dialog.AddOption("ChallangeGuild[Closed]", 1);
dialog.FinalizeDialog();
}
else
{
client.CreateBoxDialog("Sorry man you are not a leader of a guild");
}
}
else
{
client.CreateBoxDialog("Sorry man you are not in a Guild");
}
break;
}
case 1:
{
if (Program.RoomGuild == false)
{
dialog.Text("Please write challangeCps Value ")
.AddInputWithLength("Cps Value", 7, 10)
.AddOption("Exit.", 0xff)
.FinalizeDialog();
}
else
client.CreateBoxDialog("Two Guild in the room now");
break;
}
case 7:
{
if (Program.RoomGuild == false)
{
try
{
string input = Input;
uint num3 = Convert.ToUInt32(Input);
if ((client.Player.ConquerPoints >= num3) && (num3 >= 1000000))
{
client.Player.GuildArenaCps = num3;
dialog.Text("You have add " + client.Player.GuildArenaCps + " To play")
.AddText("Please Enter Guild Leader Name You Wont To start challange .")
.AddInputWithLength("Leader Name", 10, 0x10)
.FinalizeDialog();
}
else
{
dialog.Text("You don't have " + num3 + " CPs. or Less Then 1,000,000 CPs")
.AddOption("Sorry.", 0xff)
.FinalizeDialog();
}
}
catch
{
dialog.Text("Please write the correct value.")
.AddOption("Try Again.", 1)
.AddOption("Quit.", 0xff)
.FinalizeDialog();
}
}
else
client.CreateBoxDialog("Two Guild in the room now");
break;
}
case 10:
{
if (Program.RoomGuild == false)
{
string NameOfDead = Input;
foreach (var a in Database.Server.GamePoll.Values)
{
if (a.Player.Name == NameOfDead)
{
if (a.Player.MyGuild == null)
{
client.CreateBoxDialog("This Player did't have a guild yet?");
return;
}
else
{
if (a.Player.MyGuild == client.Player.MyGuild)
{
client.CreateBoxDialog("Are you crazy this is the leader of your guild?");
return;
}
if (a.Player.ConquerPoints >= client.Player.GuildArenaCps)
{
a.Player.MessageBox(client.Player.Name + " Leader of Guild " + client.Player.MyGuild.GuildName + " Wont To Challange Your Guild In Guild Arena For " + client.Player.GuildArenaCps + " CPs Did You Accpet", t =>
{
Guildarena arena = new Guildarena(client, t);
arena.ValueFight = client.Player.GuildArenaCps * 2;
Task.Factory.StartNew(() => arena.import());
t.Player.ConquerPoints -= (uint)client.Player.GuildArenaCps;
client.Player.ConquerPoints -= (uint)client.Player.GuildArenaCps;
Program.RoomGuild = true;
}, null);
}
else
client.CreateBoxDialog("Sorry But " + NameOfDead + " Does't Have " + client.Player.GuildArenaCps + "");
}
}
}
}
else
client.CreateBoxDialog("Two Guild in the room now");
break;
}
}
}
هتخش ع بروجرام
بعد قوس بروجرام ع طول حط
كود:
public static bool RoomGuild = false;
public static ServerBase.Thread GHRooms = new ServerBase.Thread(1000);
في اللود بتاع بروجرام تحت لود البوكر مثلا هتحط دي
كود:
GHRooms.Execute += new Action(GHRooms_Execute);
GHRooms.Start();
بعد كده هتعمل void ده في بروجرام
كود:
public static void GHRooms_Execute()
{
if (RoomGuild == true)
{
foreach (var Player in MapPlayers4())
{
if (Player.Player.Alive == false)
{
using (var rec = new ServerSockets.RecycledPacket())
{
var stream = rec.GetStream();
Player.Player.Revive(stream);
}
Player.Teleport(300, 279, 1002, 0);
if (Player.Player.GuildArenaBattleFight != null)
Player.Player.GuildArenaBattleFight.CheakToEnd(Player);
}
}
}
}
كود:
public static Client.GameClient[] MapPlayers4()
{
var Map4 = Database.Server.ServerMaps[1477];
return Map4.Values.Where(p => p.Player.Map == Map4.ID).ToArray();
}
هتعمل كلاس جديد باسم thread
كود:
namespace Project_Terror_v2.ServerBase
{
using Project_Terror_v2;
using System;
using System.Runtime.CompilerServices;
using System.Threading;
public class Thread
{
private System.Threading.Thread base_thread;
private Action Executes;
private int Milliseconds;
public event Action Execute
{
add
{
Action action2;
Action execute = this.Executes;
do
{
action2 = execute;
Action action3 = (Action)Delegate.Combine(action2, value);
execute = Interlocked.CompareExchange<Action>(ref this.Executes, action3, action2);
}
while (execute != action2);
}
remove
{
Action action2;
Action execute = this.Executes;
do
{
action2 = execute;
Action action3 = (Action)Delegate.Remove(action2, value);
execute = Interlocked.CompareExchange<Action>(ref this.Executes, action3, action2);
}
while (execute != action2);
}
}
public Thread(int milliseconds)
{
this.Closed = false;
this.Milliseconds = milliseconds;
}
private void Loop()
{
this.Sleep(0x5dc);
while (true)
{
if (this.Closed)
{
return;
}
try
{
if (this.Executes != null)
{
this.Executes();
}
}
catch (Exception exception)
{
MyConsole.SaveException(exception);
Console.WriteLine(exception);
}
this.Sleep(this.Milliseconds);
}
}
public void Sleep(int ms)
{
System.Threading.Thread.Sleep(ms);
}
public void Start()
{
this.base_thread = new System.Threading.Thread(new ThreadStart(this.Loop));
this.base_thread.Start();
}
public bool Closed { get; set; }
}
}
في player
ضيف
كود:
public Guildarena GuildArenaBattle, GuildArenaBattleFight;
هتبحث عن
كود:
internal void EndQualifier()
هتحط فيها
كود:
if (Player.GuildArenaBattle != null)
Player.GuildArenaBattle.CheakToEnd(this);
هتبحث عن
كود:
if ((client.ClientFlag & Client.ServerFlag.Disconnect) == Client.ServerFlag.Disconnect)
في ServerDatabase
عشان لو الاكونت قفل
كود:
if (client.Player.GuildArenaBattleFight != null)
client.Player.GuildArenaBattleFight.CheakToEnd(client, true);
if (client.Player.Map == 1477)
{
if (Program.MapPlayers4().Length == 0)
Program.RoomGuild = false;
client.Player.Map = 1002;
client.Player.X = 301;
client.Player.Y = 278;
}
كده خلصت الحمد لله
اولا هتعملوا مابه 1477 في GameMap
وطبعا الان بي سي هتربطوا في كلاس Npcid
وتحطوا في القاعده