First add a new .cs file in Structures/features folder and name it what ever u want.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using WorldServer.Networking;
using WorldServer.Packets;
using WorldServer.Handlers;
namespace WorldServer.Structures
{
public partial class Struct
{
public class _1v1
{
public static bool IsOn = false;
public static int CharID1 = 0;
public static int CharID2 = 0;
public static bool IsReady1 = false;
public static bool IsReady2 = false;
public static Thread EventTimer;
public static void Start()//Starts the Event
{
if (World.ClientPool.ContainsKey(CharID1) && World.ClientPool.ContainsKey(CharID2))
{
IsOn = true;
ClientSocket CSocket1 = World.ClientPool[CharID1];
ClientSocket CSocket2 = World.ClientPool[CharID2];
CSocket1.Client.Invincible = true;
CSocket2.Client.Invincible = true;
EventTimer = new Thread(EventThread);
EventTimer.Start();
}
}
public static void End(int WinnerID)//Stops and awards prize to winner then resets event
{
ClientSocket CSocket = World.ClientPool[WinnerID];
ClientSocket CSocket2 = null;
if(WinnerID == Struct._1v1.CharID1)
CSocket2 = World.ClientPool[Struct._1v1.CharID2];
else
CSocket2 = World.ClientPool[Struct._1v1.CharID1];
Handler.CPs(10000, CSocket);
Handler.Teleport(1002, 430, 380, 0, CSocket);
Handler.Teleport(1002, 430, 380, 0, CSocket2);
CoPacket.ToServer(CoPacket.Chat(0, "SYSTEM", "ALLUSERS", "Congrats to "+World.ClientPool[WinnerID].Client.Name+" he/she has won the 1v1 Pk Event and is rewarded 10k CPs", ChatType.Center), 0);
Database.EventLog("1v1 Pk Event", CSocket);
CSocket.Client.PreviousMap = 1002;
CSocket2.Client.PreviousMap = 1002;
IsOn = false;
IsReady1 = false;
IsReady2 = false;
CharID1 = 0;
CharID2 = 0;
}
public static void EventThread(object state)//thread to handle event
{
while (true)
{
if (IsOn)
{
ClientSocket CSocket1 = World.ClientPool[CharID1];
ClientSocket CSocket2 = World.ClientPool[CharID2];
if (CSocket1.Client.dead)
{
End(CSocket2.Client.ID);
Thread.CurrentThread.Abort();
return;
}
else if (CSocket2.Client.dead)
{
End(CSocket1.Client.ID);
Thread.CurrentThread.Abort();
return;
}
Thread.Sleep(100);
}
else
{
Thread.CurrentThread.Abort();
}
}
}
}
}
}
Code:
#region 1v1 Pk Event
case 420000:
{
if (Struct._1v1.CharID1 == CSocket.Client.ID || Struct._1v1.CharID2 == CSocket.Client.ID)
{
if (LinkBack == 0)
{
Text("Are you ready to start the 1v1 Pk Event?", CSocket);
Link("Yes", 1, CSocket);
Link("Give me another Minute.", 2, CSocket);
//Face(255, CSocket);
End(CSocket);
}
else if (LinkBack == 1)
{
if (Struct._1v1.CharID1 == CSocket.Client.ID)
{
Struct._1v1.IsReady1 = true;
}
else if (Struct._1v1.CharID2 == CSocket.Client.ID)
{
Struct._1v1.IsReady2 = true;
}
if (Struct._1v1.IsReady1 && Struct._1v1.IsReady2)
{
ClientSocket CSocket1 = World.ClientPool[Struct._1v1.CharID1];
ClientSocket CSocket2 = World.ClientPool[Struct._1v1.CharID2];
Handler.Teleport(1507, 92, 116, 0, CSocket1);
Handler.Teleport(1507, 99, 110, 0, CSocket2);
Struct._1v1.Start();
}
}
else if (LinkBack == 2)
{
System.Timers.Timer T = new System.Timers.Timer();
T.Interval = 60000;
T.AutoReset = false;
T.Elapsed += delegate
{
if (World.ClientPool.ContainsKey(CSocket.Client.ID))
{
CSocket.Client.LastNPC = 420000;
Text("Are you ready to start the 1v1 Pk Event?", CSocket);
Link("Yes", 1, CSocket);
Link("Give me another Minute.", 2, CSocket);
//Face(255, CSocket);
End(CSocket);
ClientSocket CSocket1 = null;
if (Struct._1v1.CharID1 == CSocket.Client.ID)
CSocket1 = World.ClientPool[Struct._1v1.CharID2];
else
CSocket1 = World.ClientPool[Struct._1v1.CharID1];
CSocket1.Send(CoPacket.Chat(0, "SYSTEM", "ALLUSERS", "Your oppenent for the 1v1 Pk Event is taking another minute to get ready!", Struct.ChatType.Center));
}
};
T.Start();
}
}
break;
}
#endregion
Code:
#region GeneralBravery
case 31:
{
if (LinkBack == 0)
{
Text("Welcome "+CSocket.Client.Name+", I manage all of the Pk Events.", CSocket);
Text("Which Event would u like to know about?", CSocket);
Link("1 v 1", 10, CSocket);
Link("Just passing by.", 255, CSocket);
Face(7, CSocket);
End(CSocket);
}
else if (LinkBack == 10)
{
Text("The 1v1 Events is an Event where any 2 Players can enter the Event and", CSocket);
Text("the winner of the event will be rewarded Cps.", CSocket);
if (Struct._1v1.CharID1 != 0 && Struct._1v1.CharID2 != 0)
{
Text("There is currently a Match Going On", CSocket);
Link("Tell me the Rules", 11, CSocket);
Link("Never Mind", 255, CSocket);
Face(7, CSocket);
End(CSocket);
}
else
{
if (Struct._1v1.CharID1 == 0)
Text("Player 1:", CSocket);
else
Text("Player 1: "+World.ClientPool[Struct._1v1.CharID1].Client.Name+"", CSocket);
if (Struct._1v1.CharID2 == 0)
Text("Player 2:", CSocket);
else
Text("Player 2: " + World.ClientPool[Struct._1v1.CharID2].Client.Name + "", CSocket);
if (Struct._1v1.CharID1 != CSocket.Client.ID && Struct._1v1.CharID2 != CSocket.Client.ID)
Link("Sign Me Up.", 12, CSocket);
else
Link("Take me off list", 13, CSocket);
Link("Never Mind", 255, CSocket);
Face(7, CSocket);
End(CSocket);
}
}
else if (LinkBack == 11)
{
Text("The rules of the 1v1 are simple. So please obey them.", CSocket);
Text("Rule 1: Not allowed to use any Items while Match is Live.", CSocket);
Text("Rule 2: Any weapon skill and magic skill is allowed.", CSocket);
Text("Rule 3: No AimBots, SpeedHacks, or Bots", CSocket);
Text("If you Disconnect or Jump threw portal you will forfiet and the oppenent wins", CSocket);
Link("Ok Thanks.", 255, CSocket);
Face(7, CSocket);
End(CSocket);
}
else if (LinkBack == 12)
{
if (Struct._1v1.CharID1 == 0)
{
Struct._1v1.CharID1 = CSocket.Client.ID;
CoPacket.ToServer(CoPacket.Chat(0, "SYSTEM", "ALLUSERS", CSocket.Client.Name +" has signed up for the 1v1 Pk Event and needs a component. Sign Up at GeneralBravery in TwinCity", Struct.ChatType.Center), 0);
}
else if (Struct._1v1.CharID2 == 0)
{
if (CSocket.IPAdress == World.ClientPool[Struct._1v1.CharID1].IPAdress)
{
ErrorMsg("You cannot have multiple clients in this event!", CSocket);
}
else
{
Struct._1v1.CharID2 = CSocket.Client.ID;
CoPacket.ToServer(CoPacket.Chat(0, "SYSTEM", "ALLUSERS", CSocket.Client.Name + " has accepted " + World.ClientPool[Struct._1v1.CharID1].Client.Name + "'s 1v1 Challenge", Struct.ChatType.Center), 0);
}
}
if (Struct._1v1.CharID1 != 0 && Struct._1v1.CharID2 != 0)
{
ClientSocket CSocket1 = World.ClientPool[Struct._1v1.CharID1];
ClientSocket CSocket2 = World.ClientPool[Struct._1v1.CharID2];
CSocket1.Client.LastNPC = 420000;
CSocket2.Client.LastNPC = 420000;
Handler.NpcTalk(CSocket1, 420000, 0, null);
Handler.NpcTalk(CSocket2, 420000, 0, null);
}
}
else if (LinkBack == 13)
{
if(Struct._1v1.CharID2 == 0)
{
Struct._1v1.CharID1 = 0;
Text("You have removed yourself from the 1v1 Event.", CSocket);
Link("Ok Thanks.", 255, CSocket);
Face(7, CSocket);
End(CSocket);
CoPacket.ToServer(CoPacket.Chat(0, "SYSTEM", "ALLUSERS", CSocket.Client.Name + " has removed them self from the 1v1 Pk Event.", Struct.ChatType.Center), 0);
}
}
break;
}
#endregion
Code:
if (Struct._1v1.IsOn && Struct._1v1.CharID1 == CSocket.Client.ID || Struct._1v1.CharID2 == CSocket.Client.ID)
{
Delete = false;
goto Jump;
}






