if (start)
{
Program.DropEventTimer = new System.Timers.Timer();
Program.DropEventTimer.Interval = (int.Parse(Cmd[2]) * 60000);
Program.DropEventTimer.Elapsed += new System.Timers.ElapsedEventHandler(Program.QuestDropDone);
Program.DropEventTimer.Start();
Game.World.SendMsgToAll("Server", "[Event] Server will drop " + Cmd[1] + "s " + Cmd[3] + "x for " + Cmd[2] + " minutes.", 2011, 0);
}
else
GC.LocalMessage(2001, "Item name is not a dropevent!");
}
else
GC.LocalMessage(2001, "There is a running event, you must wait it end to start a new!");
}
catch { GC.LocalMessage(2001, "Wrongs values!"); GC.LocalMessage(2001, "Format: /questdrop ItemName Minutes Timers"); GC.LocalMessage(2001, "Example: /questdrop dragonball 15 1000 its in up the rates to 1000x in 15 minutos."); }
}
if (Cmd[0] == "/itemtest")
{
Game.Item I = new NewestCOServer.Game.Item();
I.Effect = NewestCOServer.Game.Item.RebornEffect.Shield;
I.ID = 410329;
I.Plus = 12;
I.Soc1 = NewestCOServer.Game.Item.Gem.SuperDragonGem;
I.Soc2 = NewestCOServer.Game.Item.Gem.SuperRainbowGem;
I.Bless = 5;
I.Enchant = 200;
I.UID = (uint)Program.Rnd.Next(10000000);
GC.AddSend(Packets.AddItem(I, 0));
}
if (Cmd[0] == "/drop")
{
uint DropID = 0;
Random Rnd = new Random();
string DropWhat = Cmd[1].ToLower();
byte HowMany = (byte)Math.Min(ushort.Parse(Cmd[2]), (ushort)255);
switch (DropWhat)
{
case "dragonball": DropID = 1088000; break;
case "meteor": DropID = 1088001; break;
case "pointcard": DropID = 780000; break;
case "moonbox": DropID = 721080; break;
case "bag": DropID = 729910; break;
case "ball": DropID = 723834; break;
}
Game.DroppedItem DI = new Game.DroppedItem();
DI.DropTime = DateTime.Now;
DI.UID = (uint)Rnd.Next(10000000);
DI.Loc = new Game.Location();
DI.Loc.Map = GC.MyChar.Loc.Map;
DI.Info = new Game.Item();
DI.Info.ID = DropID;
DI.Info.UID = (uint)Rnd.Next(10000000);
for (int x = 0; x < HowMany; x++)
{
DI.Loc.X = (ushort)(GC.MyChar.Loc.X + Rnd.Next(15) - Rnd.Next(15));
DI.Loc.Y = (ushort)(GC.MyChar.Loc.Y + Rnd.Next(15) - Rnd.Next(15));
if (!DI.FindPlace((Hashtable)Game.World.H_Items[GC.MyChar.Loc.Map])) continue;
DI.Drop();
}
}
if (Cmd[0] == "/robot")
{
string Account = "";
string Name = Cmd[1];
if (Game.World.CharacterFromName(Name) == null)
{
Game.Robot R = Database.LoadAsRobot(Name, ref Account);
if (R != null)
R.Init(Account);
}
}
}
if (Cmd[0] == "/robot1")
{
string Account = "";
string Name = Cmd[1];
Game.Robot R = Database.LoadAsRobot(Name, ref Account);
if (R != null)
R.Init(Account);
}
if (Cmd[0] == "/reborn")
{
GC.MyChar.Reborns = byte.Parse(Cmd[1]);
}
if (Cmd[0] == "/gw" && !Features.GuildWars.War)
Features.GuildWars.StartWar();
if (Cmd[0] == "/gems")
{
if (GC.MyChar.Inventory.Count <= 32)
{
GC.MyChar.AddItem(700001);
GC.MyChar.AddItem(700011);
GC.MyChar.AddItem(700021);
GC.MyChar.AddItem(700031);
GC.MyChar.AddItem(700041);
GC.MyChar.AddItem(700051);
GC.MyChar.AddItem(700061);
GC.MyChar.AddItem(700071);
GC.MyChar.AddItem(700101);
GC.MyChar.AddItem(700121);
}
}
if (Cmd[0] == "/eqlow")
{
for (byte i = 1; i < 9; i++)
if (i != 7)
{
Game.Item I = GC.MyChar.Equips.Get(i);
if (I.ID != 0)
{
Game.ItemIDManipulation IDM = new NewestCOServer.Game.ItemIDManipulation(I.ID);
IDM.LowestLevel(i);
I.ID = IDM.ToID();
GC.AddSend(Packets.AddItem(I, i));
}
}
}
if(Cmd[0] == "/appr")
GC.AddSend(Packets.MentorApprenticePacket(GC.MyChar.EntityID, (uint)Program.Rnd.Next(1000001, 19999999), Cmd[1], byte.Parse(Cmd[2]), 1));
if (Cmd[0] == "/protect")
GC.MyChar.Protection = !GC.MyChar.Protection;
if (Cmd[0] == "/effect")
GC.AddSend(Packets.String(GC.MyChar.EntityID, 10, Cmd[1]));
if (Cmd[0] == "/exp")
GC.MyChar.Experience = ulong.Parse(Cmd[1]);
if (Cmd[0] == "/pkp")
GC.MyChar.PKPoints = ushort.Parse(Cmd[1]);
if (Cmd[0] == "/atk")
GC.AddSend(Packets.AttackPacket(GC.MyChar.EntityID, GC.MyChar.EntityID, GC.MyChar.Loc.X, GC.MyChar.Loc.Y, 9999, byte.Parse(Cmd[1])));
if (Cmd[0] == "/recall")
{
if (Cmd[1] != "all")
{
if (GC.AuthInfo.Status == "[PM]")
{
Game.Character C = Game.World.CharacterFromName(Cmd[1]);
if (C != null && C != GC.MyChar)
C.Teleport(GC.MyChar.Loc.Map, GC.MyChar.Loc.X, GC.MyChar.Loc.Y);
}
}
else
{
foreach (Game.Character C in Game.World.H_Chars.Values)
C.Teleport(GC.MyChar.Loc.Map, GC.MyChar.Loc.X, GC.MyChar.Loc.Y);
}
}
if (Cmd[0] == "/c")
{
Game.World.SendMsgToAll(GC.MyChar.Name, GC.MyChar.Name + ": " + Message.Remove(0, 3), 2011, 0);
}
if (Cmd[0] == "/try")
{
GC.AddSend(Packets.GeneralData(GC.MyChar.EntityID, 1, GC.MyChar.Loc.X, GC.MyChar.Loc.Y, byte.Parse(Cmd[1])));
}
if (Cmd[0] == "/steed")
{
Game.Item I = new NewestCOServer.Game.Item();
I.ID = 300000;
I.Plus = byte.Parse(Cmd[1]);
I.MaxDur = I.DBInfo.Durability;
I.CurDur = I.MaxDur;
I.Effect = NewestCOServer.Game.Item.RebornEffect.Horsie;
I.TalismanProgress = BitConverter.ToUInt32(new byte[4] {byte.Parse(Cmd[4]), byte.Parse(Cmd[3]), byte.Parse(Cmd[2]),0},0);
I.UID = (uint)Program.Rnd.Next(10000000);
GC.MyChar.AddItem(I);
}
if (Cmd[0] == "/ctele")
{
Game.Character C = Game.World.CharacterFromName(Cmd[1]);
if (C != null)
GC.MyChar.Teleport(C.Loc.Map, C.Loc.X, C.Loc.Y);
}
if (Cmd[0] == "/seff")
GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.Effect, ulong.Parse(Cmd[1])));
if (Cmd[0] == "/tryatk")
GC.AddSend(Packets.AttackPacket(GC.MyChar.EntityID,GC.MyChar.EntityID,GC.MyChar.Loc.X,GC.MyChar.Loc.Y,300,byte.Parse(Cmd[1])));
if (Cmd[0] == "/skill")
GC.MyChar.RWSkill(new Game.Skill() { ID = ushort.Parse(Cmd[1]), Lvl = byte.Parse(Cmd[2]), Exp = 0 });
if (Cmd[0] == "/prof")
GC.MyChar.RWProf(new Game.Prof() { ID = ushort.Parse(Cmd[1]), Lvl = byte.Parse(Cmd[2]), Exp = 0 });
if (Cmd[0] == "/blue")
GC.MyChar.BlueName = !GC.MyChar.BlueName;
if (Cmd[0] == "/level")
{
GC.MyChar.Experience = 0;
GC.MyChar.Level = byte.Parse(Cmd[1]);
}
if (Cmd[0].ToLower() == "/kick" || Cmd[0].ToLower() == "/k")
{
Game.Character C = Game.World.CharacterFromName(Cmd[1]);
if (C != null)
C.MyClient.Disconnect();
}
if (Cmd[0] == "/vp")
GC.LocalMessage(2000, "You have " + GC.MyChar.VP + " virtue points.");
if (Cmd[0] == "/map")
GC.LocalMessage(2000, "The ID of the map you are on is " + GC.MyChar.Loc.Map);
if (Cmd[0] == "/job")
GC.MyChar.Job = byte.Parse(Cmd[1]);
if (Cmd[0] == "/silvers")
GC.MyChar.Silvers = uint.Parse(Cmd[1]);
if (Cmd[0] == "/cps")
GC.MyChar.CPs = uint.Parse(Cmd[1]);
if (Cmd[0] == "/tele")
GC.MyChar.Teleport(ushort.Parse(Cmd[1]), ushort.Parse(Cmd[2]), ushort.Parse(Cmd[3]));
if (Cmd[0] == "/item")
{
uint ID = 0;
foreach (DatabaseItem DI in Database.DatabaseItems.Values)
if (DI.Name == Cmd[1])
{
ID = DI.ID;
Game.ItemIDManipulation e = new Game.ItemIDManipulation(ID);
Game.Item.ItemQuality Quality = e.Quality;
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.IO;
namespace NewestCOServer.PacketHandling
{
public class Chat
{
public static void Handle(Main.GameClient GC, byte[] Data)
{
MemoryStream MS = new MemoryStream(Data);
BinaryReader BR = new BinaryReader(MS);
BR.ReadBytes(8);
ushort ChatType = (ushort)BR.ReadUInt32();
BR.ReadBytes(13);
string From = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
string To = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
BR.ReadByte();
string Message = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
BR.Close();
MS.Close();
#region BadWords
Message = Message.Replace("damn", "****");
Message = Message.Replace("fuck", "****");
Message = Message.Replace("shit", "****");
Message = Message.Replace("stupid", "******");
Message = Message.Replace("wtf", "***");
Message = Message.Replace("idiot", "*****");
Message = Message.Replace("fucker", "******");
#endregion
if (ChatType == 2104 && GC.MyChar.MyShop != null)
GC.MyChar.MyShop.Hawk = Message;
try
{
if (Message[0] == '/')
{
string[] Cmd = Message.Split(' ');
#region player
if (Cmd[0] == "/vp")
GC.LocalMessage(2000, "You have " + GC.MyChar.VP + " virtue points.");
if (Cmd[0] == "/map")
GC.LocalMessage(2000, "The ID of the map you are on is " + GC.MyChar.Loc.Map);
#endregion player
#region GM PM
if (GC.AuthInfo.Status == "[GM]" || GC.AuthInfo.Status == "[PM]")
{
if (Cmd[0] == "/vp")
GC.LocalMessage(2000, "You have " + GC.MyChar.VP + " virtue points.");
if (Cmd[0] == "/map")
GC.LocalMessage(2000, "The ID of the map you are on is " + GC.MyChar.Loc.Map);
}
#endregion GM PM
#region PM
if (GC.AuthInfo.Status == "[PM]")
{
if (Cmd[0] == "/vp")
GC.LocalMessage(2000, "You have " + GC.MyChar.VP + " virtue points.");
if (Cmd[0] == "/map")
GC.LocalMessage(2000, "The ID of the map you are on is " + GC.MyChar.Loc.Map);
}
#endregion PM
#region GM
if (GC.AuthInfo.Status == "[GM]")
{
if (Cmd[0] == "/vp")
GC.LocalMessage(2000, "You have " + GC.MyChar.VP + " virtue points.");
if (Cmd[0] == "/map")
GC.LocalMessage(2000, "The ID of the map you are on is " + GC.MyChar.Loc.Map);
if (start)
{
Program.DropEventTimer = new System.Timers.Timer();
Program.DropEventTimer.Interval = (int.Parse(Cmd[2]) * 60000);
Program.DropEventTimer.Elapsed += new System.Timers.ElapsedEventHandler(Program.QuestDropDone);
Program.DropEventTimer.Start();
Game.World.SendMsgToAll("Server", "[Event] Server will drop " + Cmd[1] + "s " + Cmd[3] + "x for " + Cmd[2] + " minutes.", 2011, 0);
}
else
GC.LocalMessage(2001, "Item name is not a dropevent!");
}
else
GC.LocalMessage(2001, "There is a running event, you must wait it end to start a new!");
}
catch { GC.LocalMessage(2001, "Wrongs values!"); GC.LocalMessage(2001, "Format: /questdrop ItemName Minutes Timers"); GC.LocalMessage(2001, "Example: /questdrop dragonball 15 1000 its in up the rates to 1000x in 15 minutos."); }
}
if (Cmd[0] == "/itemtest")
{
Game.Item I = new NewestCOServer.Game.Item();
I.Effect = NewestCOServer.Game.Item.RebornEffect.Shield;
I.ID = 410329;
I.Plus = 12;
I.Soc1 = NewestCOServer.Game.Item.Gem.SuperDragonGem;
I.Soc2 = NewestCOServer.Game.Item.Gem.SuperRainbowGem;
I.Bless = 5;
I.Enchant = 200;
I.UID = (uint)Program.Rnd.Next(10000000);
GC.AddSend(Packets.AddItem(I, 0));
}
if (Cmd[0] == "/drop")
{
uint DropID = 0;
Random Rnd = new Random();
string DropWhat = Cmd[1].ToLower();
byte HowMany = (byte)Math.Min(ushort.Parse(Cmd[2]), (ushort)255);
switch (DropWhat)
{
case "dragonball": DropID = 1088000; break;
case "meteor": DropID = 1088001; break;
case "pointcard": DropID = 780000; break;
case "moonbox": DropID = 721080; break;
case "bag": DropID = 729910; break;
case "ball": DropID = 723834; break;
}
Game.DroppedItem DI = new Game.DroppedItem();
DI.DropTime = DateTime.Now;
DI.UID = (uint)Rnd.Next(10000000);
DI.Loc = new Game.Location();
DI.Loc.Map = GC.MyChar.Loc.Map;
DI.Info = new Game.Item();
DI.Info.ID = DropID;
DI.Info.UID = (uint)Rnd.Next(10000000);
for (int x = 0; x < HowMany; x++)
{
DI.Loc.X = (ushort)(GC.MyChar.Loc.X + Rnd.Next(15) - Rnd.Next(15));
DI.Loc.Y = (ushort)(GC.MyChar.Loc.Y + Rnd.Next(15) - Rnd.Next(15));
if (!DI.FindPlace((Hashtable)Game.World.H_Items[GC.MyChar.Loc.Map])) continue;
DI.Drop();
}
}
if (Cmd[0] == "/robot")
{
string Account = "";
string Name = Cmd[1];
if (Game.World.CharacterFromName(Name) == null)
{
Game.Robot R = Database.LoadAsRobot(Name, ref Account);
if (R != null)
R.Init(Account);
}
}
}
if (Cmd[0] == "/robot1")
{
string Account = "";
string Name = Cmd[1];
Game.Robot R = Database.LoadAsRobot(Name, ref Account);
if (R != null)
R.Init(Account);
}
if (Cmd[0] == "/reborn")
{
GC.MyChar.Reborns = byte.Parse(Cmd[1]);
}
if (Cmd[0] == "/gw" && !Features.GuildWars.War)
Features.GuildWars.StartWar();
if (Cmd[0] == "/gems")
{
if (GC.MyChar.Inventory.Count <= 32)
{
GC.MyChar.AddItem(700001);
GC.MyChar.AddItem(700011);
GC.MyChar.AddItem(700021);
GC.MyChar.AddItem(700031);
GC.MyChar.AddItem(700041);
GC.MyChar.AddItem(700051);
GC.MyChar.AddItem(700061);
GC.MyChar.AddItem(700071);
GC.MyChar.AddItem(700101);
GC.MyChar.AddItem(700121);
}
}
if (Cmd[0] == "/eqlow")
{
for (byte i = 1; i < 9; i++)
if (i != 7)
{
Game.Item I = GC.MyChar.Equips.Get(i);
if (I.ID != 0)
{
Game.ItemIDManipulation IDM = new NewestCOServer.Game.ItemIDManipulation(I.ID);
IDM.LowestLevel(i);
I.ID = IDM.ToID();
GC.AddSend(Packets.AddItem(I, i));
}
}
}
if(Cmd[0] == "/appr")
GC.AddSend(Packets.MentorApprenticePacket(GC.MyChar.EntityID, (uint)Program.Rnd.Next(1000001, 19999999), Cmd[1], byte.Parse(Cmd[2]), 1));
if (Cmd[0] == "/protect")
GC.MyChar.Protection = !GC.MyChar.Protection;
if (Cmd[0] == "/effect")
GC.AddSend(Packets.String(GC.MyChar.EntityID, 10, Cmd[1]));
if (Cmd[0] == "/exp")
GC.MyChar.Experience = ulong.Parse(Cmd[1]);
if (Cmd[0] == "/pkp")
GC.MyChar.PKPoints = ushort.Parse(Cmd[1]);
if (Cmd[0] == "/atk")
GC.AddSend(Packets.AttackPacket(GC.MyChar.EntityID, GC.MyChar.EntityID, GC.MyChar.Loc.X, GC.MyChar.Loc.Y, 9999, byte.Parse(Cmd[1])));
if (Cmd[0] == "/recall")
{
if (Cmd[1] != "all")
{
if (GC.AuthInfo.Status == "[PM]")
{
Game.Character C = Game.World.CharacterFromName(Cmd[1]);
if (C != null && C != GC.MyChar)
C.Teleport(GC.MyChar.Loc.Map, GC.MyChar.Loc.X, GC.MyChar.Loc.Y);
}
}
else
{
foreach (Game.Character C in Game.World.H_Chars.Values)
C.Teleport(GC.MyChar.Loc.Map, GC.MyChar.Loc.X, GC.MyChar.Loc.Y);
}
}
if (Cmd[0] == "/c")
{
Game.World.SendMsgToAll(GC.MyChar.Name, GC.MyChar.Name + ": " + Message.Remove(0, 3), 2011, 0);
}
if (Cmd[0] == "/try")
{
GC.AddSend(Packets.GeneralData(GC.MyChar.EntityID, 1, GC.MyChar.Loc.X, GC.MyChar.Loc.Y, byte.Parse(Cmd[1])));
}
if (Cmd[0] == "/steed")
{
Game.Item I = new NewestCOServer.Game.Item();
I.ID = 300000;
I.Plus = byte.Parse(Cmd[1]);
I.MaxDur = I.DBInfo.Durability;
I.CurDur = I.MaxDur;
I.Effect = NewestCOServer.Game.Item.RebornEffect.Horsie;
I.TalismanProgress = BitConverter.ToUInt32(new byte[4] {byte.Parse(Cmd[4]), byte.Parse(Cmd[3]), byte.Parse(Cmd[2]),0},0);
I.UID = (uint)Program.Rnd.Next(10000000);
GC.MyChar.AddItem(I);
}
if (Cmd[0] == "/ctele")
{
Game.Character C = Game.World.CharacterFromName(Cmd[1]);
if (C != null)
GC.MyChar.Teleport(C.Loc.Map, C.Loc.X, C.Loc.Y);
}
if (Cmd[0] == "/seff")
GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.Effect, ulong.Parse(Cmd[1])));
if (Cmd[0] == "/tryatk")
GC.AddSend(Packets.AttackPacket(GC.MyChar.EntityID,GC.MyChar.EntityID,GC.MyChar.Loc.X,GC.MyChar.Loc.Y,300,byte.Parse(Cmd[1])));
if (Cmd[0] == "/skill")
GC.MyChar.RWSkill(new Game.Skill() { ID = ushort.Parse(Cmd[1]), Lvl = byte.Parse(Cmd[2]), Exp = 0 });
if (Cmd[0] == "/prof")
GC.MyChar.RWProf(new Game.Prof() { ID = ushort.Parse(Cmd[1]), Lvl = byte.Parse(Cmd[2]), Exp = 0 });
if (Cmd[0] == "/blue")
GC.MyChar.BlueName = !GC.MyChar.BlueName;
if (Cmd[0] == "/level")
{
GC.MyChar.Experience = 0;
GC.MyChar.Level = byte.Parse(Cmd[1]);
}
if (Cmd[0].ToLower() == "/kick" || Cmd[0].ToLower() == "/k")
{
Game.Character C = Game.World.CharacterFromName(Cmd[1]);
if (C != null)
C.MyClient.Disconnect();
}
if (Cmd[0] == "/vp")
GC.LocalMessage(2000, "You have " + GC.MyChar.VP + " virtue points.");
if (Cmd[0] == "/map")
GC.LocalMessage(2000, "The ID of the map you are on is " + GC.MyChar.Loc.Map);
if (Cmd[0] == "/job")
GC.MyChar.Job = byte.Parse(Cmd[1]);
if (Cmd[0] == "/silvers")
GC.MyChar.Silvers = uint.Parse(Cmd[1]);
if (Cmd[0] == "/cps")
GC.MyChar.CPs = uint.Parse(Cmd[1]);
if (Cmd[0] == "/tele")
GC.MyChar.Teleport(ushort.Parse(Cmd[1]), ushort.Parse(Cmd[2]), ushort.Parse(Cmd[3]));
if (Cmd[0] == "/item")
{
uint ID = 0;
foreach (DatabaseItem DI in Database.DatabaseItems.Values)
if (DI.Name == Cmd[1])
{
ID = DI.ID;
Game.ItemIDManipulation e = new Game.ItemIDManipulation(ID);
Game.Item.ItemQuality Quality = e.Quality;
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.IO;
namespace NewestCOServer.PacketHandling
{
public class Chat
{
public static void Handle(Main.GameClient GC, byte[] Data)
{
MemoryStream MS = new MemoryStream(Data);
BinaryReader BR = new BinaryReader(MS);
BR.ReadBytes(8);
ushort ChatType = (ushort)BR.ReadUInt32();
BR.ReadBytes(13);
string From = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
string To = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
BR.ReadByte();
string Message = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
BR.Close();
MS.Close();
#region BadWords
Message = Message.Replace("damn", "****");
Message = Message.Replace("fuck", "****");
Message = Message.Replace("shit", "****");
Message = Message.Replace("stupid", "******");
Message = Message.Replace("wtf", "***");
Message = Message.Replace("idiot", "*****");
Message = Message.Replace("fucker", "******");
#endregion
if (ChatType == 2104 && GC.MyChar.MyShop != null)
GC.MyChar.MyShop.Hawk = Message;
try
{
if (Message[0] == '/')
{
string[] Cmd = Message.Split(' ');
#region player
if (Cmd[0] == "/vp")
GC.LocalMessage(2000, "You have " + GC.MyChar.VP + " virtue points.");
if (Cmd[0] == "/map")
GC.LocalMessage(2000, "The ID of the map you are on is " + GC.MyChar.Loc.Map);
#endregion player
#region GM PM
if (GC.AuthInfo.Status == "[GM]" || GC.AuthInfo.Status == "[PM]")
{
if (Cmd[0] == "/vp")
GC.LocalMessage(2000, "You have " + GC.MyChar.VP + " virtue points.");
if (Cmd[0] == "/map")
GC.LocalMessage(2000, "The ID of the map you are on is " + GC.MyChar.Loc.Map);
}
#endregion GM PM
#region PM
if (GC.AuthInfo.Status == "[PM]")
{
if (Cmd[0] == "/vp")
GC.LocalMessage(2000, "You have " + GC.MyChar.VP + " virtue points.");
if (Cmd[0] == "/map")
GC.LocalMessage(2000, "The ID of the map you are on is " + GC.MyChar.Loc.Map);
}
#endregion PM
#region GM
if (GC.AuthInfo.Status == "[GM]")
{
if (Cmd[0] == "/vp")
GC.LocalMessage(2000, "You have " + GC.MyChar.VP + " virtue points.");
if (Cmd[0] == "/map")
GC.LocalMessage(2000, "The ID of the map you are on is " + GC.MyChar.Loc.Map);
I would just like to point out how horrible that snippet of code is.
Code:
if (Cmd[0] == "/vp")
GC.LocalMessage(2000, "You have " + GC.MyChar.VP + " virtue points.");
if (Cmd[0] == "/map")
GC.LocalMessage(2000, "The ID of the map you are on is " + GC.MyChar.Loc.Map);
If you continue programming like that, you'll be executing a lot of code per command (increasing your cpu significantly more than it would be executing a command normally). Right now, you're checking if the command is "/vp", and if it is, it'll check for if the command is "/map" (and every single command you have under that) anyways. That's an issue. You need to have each command in a switch statement or at least have "else if" for every command after the first comparison.
I would also have the types of commands in different functions so if the command is found as a GM function, it will return true and not try to find the command in the PM region... Not that you two care what-so-*******-ever. You both probably don't have a clue on how to program (especially since you learn conditionals in the first week of learning programming and what you have shown above is a MAJOR mistake).
PS: You are also repeating commands, and thus the commands are going to run twice (and so on). The code above is absolutely horrible, very bugged, and very costly. I tutor people in Computer Science every day as my job and I've never seen such major errors. This community continues to amaze me.
@EgyptianMano, yah - that's better. The only things wrong that I see with that are some very minor stylistic issues...
if (!GMCommand(GC, Cmd)) if (!PMCommand(GC, Cmd)) if (!PlayerCommand(GC, Cmd))
should be... (stylistically)
if (!PMCommand(GC, Cmd) && !GMCommand(GC, Cmd) && !PlayerCommand(GC, Cmd))
...and a few logic errors with duplicate commands. Much better. Btw, PM is better than GM. The PM is the project manager (like the administrator) and a GM is a game master (like a moderator).
I would just like to point out how horrible that snippet of code is.
Code:
if (Cmd[0] == "/vp")
GC.LocalMessage(2000, "You have " + GC.MyChar.VP + " virtue points.");
if (Cmd[0] == "/map")
GC.LocalMessage(2000, "The ID of the map you are on is " + GC.MyChar.Loc.Map);
If you continue programming like that, you'll be executing a lot of code per command (increasing your cpu significantly more than it would be executing a command normally). Right now, you're checking if the command is "/vp", and if it is, it'll check for if the command is "/map" (and every single command you have under that) anyways. That's an issue. You need to have each command in a switch statement or at least have "else if" for every command after the first comparison.
I would also have the types of commands in different functions so if the command is found as a GM function, it will return true and not try to find the command in the PM region... Not that you two care what-so-fucking-ever. You both probably don't have a clue on how to program (especially since you learn conditionals in the first week of learning programming and what you have shown above is a MAJOR mistake).
PS: You are also repeating commands, and thus the commands are going to run twice (and so on). The code above is absolutely horrible, very bugged, and very costly. I tutor people in Computer Science every day as my job and I've never seen such major errors. This community continues to amaze me.
i just show him the (fastest)easiest way(may be isn't right)
ty for info's and advise
Quote:
Originally Posted by EgyptianMano
i would do it like that
Code:
public class Chat
{
public static void Handle(Main.GameClient GC, byte[] Data)
{
MemoryStream MS = new MemoryStream(Data);
BinaryReader BR = new BinaryReader(MS);
BR.ReadBytes(8);
ushort ChatType = (ushort)BR.ReadUInt32();
BR.ReadBytes(13);
string From = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
string To = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
BR.ReadByte();
string Message = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
BR.Close();
MS.Close();
#region BadWords
Message = Message.Replace("damn", "****");
Message = Message.Replace("fuck", "****");
Message = Message.Replace("shit", "****");
Message = Message.Replace("stupid", "******");
Message = Message.Replace("wtf", "***");
Message = Message.Replace("idiot", "*****");
Message = Message.Replace("fucker", "******");
#endregion
if (ChatType == 2104 && GC.MyChar.MyShop != null)
GC.MyChar.MyShop.Hawk = Message;
try
{
if (Message[0] == '/')
{
string[] Cmd = Message.Split(' ');
if (!GMCommand(GC, Cmd)) if (!PMCommand(GC, Cmd)) if (!PlayerCommand(GC, Cmd))
Game.World.Chat(GC.MyChar, ChatType, From, To, Message);
//you can ofcourse use the && to merge that three conditions in one statement but i prefer it like that
}
else
Game.World.Chat(GC.MyChar, ChatType, From, To, Message);
}
catch { }
}
public static bool GMCommand(Main.GameClient GC, string[] Msg)
{
if (GC.AuthInfo.Status != "[GM]") return false;
switch (Msg[0])
{
case "/vp":
{
//do ur codes here
return true;
}
case "/map":
{
//do ur codes here
return true;
}
}
return false;
}
public static bool PMCommand(Main.GameClient GC, string[] Msg)
{
if (GC.AuthInfo.Status != "[GM]" && GC.AuthInfo.Status != "[PM]") return false;
switch (Msg[0])
{
case "/vp":
{
//do ur codes here
return true;
}
case "/map":
{
//do ur codes here
return true;
}
}
return false;
}
public static bool PlayerCommand(Main.GameClient GC, string[] Msg)
{
switch (Msg[0])
{
case "/vp":
{
//do ur codes here
return true;
}
case "/map":
{
//do ur codes here
return true;
}
}
return false;
}
}
that way u can add any commands anytime without needs to check the Gm and Pm again , just put the commands at the target bool function
public static bool PlayerCommand(Main.GameClient GC, string[] Msg)
{
switch (Msg[0])
{
case "/vp":
{
//do ur codes here
return true;
}
case "/map":
{
//do ur codes here
return true;
}
}
return false;
Thank you all for taking your time helping me out :-)
public static bool PlayerCommand(Main.GameClient GC, string[] Msg)
{
switch (Msg[0])
{
case "/vp":
{
//do ur codes here
return true;
}
case "/map":
{
//do ur codes here
return true;
}
}
return false;
Thank you all for taking your time helping me out :-)
This has always bothered me...
One cannot be 'both' a GM and a PM. PM outranked a GM and therefor already has all the permissions that a GM would have.
This is why you use a enumerated value for account permissions. Behind the scenes it's a number which you can then use simple operators on.
If you must be at least a Moderator to use a command then you do user.Permission >= PermissionType.Moderator and you can auto use the command if you're a moderator, GM or PM. It saves doing multiple checks like you're describing and has no legitimate drawbacks.
I cannot think of a single case where a higher permission account should not be able to use a lower permission command. This is why consistently naming your commands comes into play and should never pose a serious issue.
One cannot be 'both' a GM and a PM. PM outranked a GM and therefor already has all the permissions that a GM would have.
This is why you use a enumerated value for account permissions. Behind the scenes it's a number which you can then use simple operators on.
If you must be at least a Moderator to use a command then you do user.Permission >= PermissionType.Moderator and you can auto use the command if you're a moderator, GM or PM. It saves doing multiple checks like you're describing and has no legitimate drawbacks.
I cannot think of a single case where a higher permission account should not be able to use a lower permission command. This is why consistently naming your commands comes into play and should never pose a serious issue.
ohh, ok! I understand
1 More question: I have 94errors:
Code:
The name "Cmd" does not exist in the current context
Here is an example where the error comes:
Code:
case "/robot":
{
string Account = "";
string Name = Cmd[1];
if (Game.World.CharacterFromName(Name) == null)
{
Game.Robot R = Database.LoadAsRobot(Name, ref Account);
if (R != null)
R.Init(Account);
}
return true;
}
Get the Section organized. 07/14/2013 - Need for Speed World - 37 Replies Hello everyone.
I would like to ask you all, what do you think about getting the section divided in two; so that we could have a Main section, to discuss about the game, have general questions and so on, and a Hacks sub-section in which we can have just releases there?
I have been thinking about this, to get everything even more centralized, as well, we could avoid double posts/malware/spam in general.
So any comments, leave them below, and definitely, vote.
Elo boost service the best, fast and most organized 01/29/2013 - League of Legends Trading - 5 Replies Hi, we are 3 players from 2.3 , 2.1, and 2,05k elo we are starting to boost we already boosted not for money, just a few friends it worked now they are at 1600 elo.
First of all this are our prices are all negociable
0 -1250 10 € per 100 elo
1250-1400 15 € per 100 elo
1400-1600 20 € per 100 elo
(request) chat filter 12/01/2009 - GunZ - 0 Replies i've looked all over and all i want it just the chat filter. does anyone have just the chat filter?