Okay i am working on Elite PK Tournament , and i am trying to make it like real co.
its select two players from each map group to fight , the winner will be sent to Waiting map , and the loser will be sent to Twin City .
so i created it like that .
but till now i have 2 problems .
first one is its selecting 2 players from all game maps not only which i added it in the code ..
second one when player 1 kill player 2 , or The contrary .
the killer dose not sent to waiting map , and who was killed is stay in the map till revive it.
here is my code of it:
had i forgot something ? anything error ? :handsdown:
# edit :
please any moderator edit my thread to " I need Help With This "
because its " Hep " O.o
its select two players from each map group to fight , the winner will be sent to Waiting map , and the loser will be sent to Twin City .
so i created it like that .
but till now i have 2 problems .
first one is its selecting 2 players from all game maps not only which i added it in the code ..
second one when player 1 kill player 2 , or The contrary .
the killer dose not sent to waiting map , and who was killed is stay in the map till revive it.
here is my code of it:
PHP Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Conquer_Online_Server.Database;
using Conquer_Online_Server.Client;
using Conquer_Online_Server.Network;
using System.IO;
using Conquer_Online_Server.Network.GamePackets;
using System.Threading;
namespace Conquer_Online_Server.Game.Tournaments
{
public class EliteTournament
{
public void Start()
{
foreach (Conquer_Online_Server.Client.GameState players in Conquer_Online_Server.ServerBase.Kernel.GamePool.Values)
if (players.Entity.MapID == 1631)
this.RandomSelect();
}
public static Map dynamicMap;
public Client.GameState Winner, Loser;
public Client.GameState pOne, pTwo;
public bool Done;
public bool CanEnd;
public Time32 DoneStamp;
public uint pOneDamage, pTwoDamage;
public static SafeDictionary<uint, GameState> PlayerList = new SafeDictionary<uint, GameState>(10000);
public void RandomSelect()
{
List<Client.GameState> players = new List<Client.GameState>();
foreach (Client.GameState p in ServerBase.Kernel.GamePool.Values)
players.Add(p);
Random rand = new Random();
Client.GameState pOne, pTwo;
int selectedIndex = rand.Next(players.Count);
pOne = players[selectedIndex];
players.RemoveAt(selectedIndex);
selectedIndex = rand.Next(players.Count);
pTwo = players[selectedIndex];
players.RemoveAt(selectedIndex);
if (!ServerBase.Kernel.Maps.ContainsKey(700))
new Map(700, Database.DMaps.MapPaths[700]);
Map origMap = ServerBase.Kernel.Maps[700];
dynamicMap = origMap.MakeDynamicMap();
pOne.Entity.Teleport(origMap.ID, dynamicMap.ID, (ushort)ServerBase.Kernel.Random.Next(35, 70), (ushort)ServerBase.Kernel.Random.Next(35, 70));
pTwo.Entity.Teleport(origMap.ID, dynamicMap.ID, (ushort)ServerBase.Kernel.Random.Next(35, 70), (ushort)ServerBase.Kernel.Random.Next(35, 70));
if (pOne.Map.ID == pTwo.Map.ID)
{
pOne.Entity.RemoveFlag(Network.GamePackets.Update.Flags.Ride);
pTwo.Entity.RemoveFlag(Network.GamePackets.Update.Flags.Ride);
pTwo.Entity.PKMode = pOne.Entity.PKMode;
pOne.Entity.PKMode = Conquer_Online_Server.Game.Enums.PKMode.PK;
pOne.Send(new Data(true) { UID = pOne.Entity.UID, ID = Data.ChangePKMode, dwParam = (uint)pOne.Entity.PKMode });
pOne.Entity.PKMode = pTwo.Entity.PKMode;
pTwo.Entity.PKMode = Conquer_Online_Server.Game.Enums.PKMode.PK;
pTwo.Send(new Data(true) { UID = pTwo.Entity.UID, ID = Data.ChangePKMode, dwParam = (uint)pTwo.Entity.PKMode });
Conquer_Online_Server.Network.PacketHandler.WorldMessage("" + pOne.Entity.Name + " Is Meeting " + pTwo.Entity.Name + " in the Elite Pk Tournament");
Client.GameState[] Clients = Conquer_Online_Server.ServerBase.Kernel.GamePool.Values.ToArray();
foreach (Client.GameState client in Clients)
this.End(client);
}
}
public void End(Client.GameState client)
{
if (pOneDamage > pTwoDamage)
{
Winner = pOne;
Loser = pTwo;
}
else
{
Winner = pTwo;
Loser = pOne;
}
Winner.Entity.Teleport(pOne.Entity.PreviousMapID, pOne.Entity.PrevX, pOne.Entity.PrevY);
Loser.Entity.Teleport(1002, 444, 444);
pTwo.Entity.PKMode = pOne.Entity.PKMode;
pOne.Entity.PKMode = Conquer_Online_Server.Game.Enums.PKMode.Capture;
pOne.Send(new Data(true) { UID = pOne.Entity.UID, ID = Data.ChangePKMode, dwParam = (uint)pOne.Entity.PKMode });
pOne.Entity.PKMode = pTwo.Entity.PKMode;
pTwo.Entity.PKMode = Conquer_Online_Server.Game.Enums.PKMode.Capture;
pTwo.Send(new Data(true) { UID = pTwo.Entity.UID, ID = Data.ChangePKMode, dwParam = (uint)pTwo.Entity.PKMode });
Done = true;
DoneStamp = Time32.Now;
CanEnd = true;
}
}
}
# edit :
please any moderator edit my thread to " I need Help With This "
because its " Hep " O.o