|
You last visited: Today at 19:34
Advertisement
[Request]Organized chat.cs?
Discussion on [Request]Organized chat.cs? within the CO2 Private Server forum part of the Conquer Online 2 category.
03/04/2013, 23:15
|
#1
|
elite*gold: 0
Join Date: Mar 2013
Posts: 44
Received Thanks: 2
|
[Closed]Organized chat.cs?
ROFL Fixed it!..
Wasn't so hard after all xD
|
|
|
03/05/2013, 12:15
|
#2
|
elite*gold: 0
Join Date: Jul 2008
Posts: 874
Received Thanks: 238
|
u mean like this
PHP Code:
public static bool CheckCommand(Network.GamePackets.Message message, Client.GameState client)
{
try
{
if (message.__Message.StartsWith("@"))
{
string Message = message.__Message.Substring(1).ToLower();
string Mess = message.__Message.Substring(1);
string[] Data = Message.Split(' ');
#region GMs PMs
if (client.Account.State == Conquer_Online_Server.Database.AccountTable.AccountState.ProjectManager || client.Account.State == Conquer_Online_Server.Database.AccountTable.AccountState.GameMaster)
{
switch (Data[0])
{
case "cmd1":
{
break;
}
}
return true;
}
#endregion GMs PMs
#region HelpDesk
if (client.Account.State == Conquer_Online_Server.Database.AccountTable.AccountState.HelpDesk)
{
switch (Data[0])
{
case "cmd1":
{
break;
}
}
return true;
}
#endregion HelpDesk
#region Players
switch (Data[0])
{
#region bigbos
case "cmd1":
{
break;
}
}
return true;
}
#endregion Players
return false;
}
catch
{
client.Send(new Conquer_Online_Server.Network.GamePackets.Message("Impossible to handle this command", System.Drawing.Color.BurlyWood, 0x7dc));
return false;
}
}
|
|
|
03/05/2013, 12:42
|
#3
|
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
|
Don't do == use >= for that.
That way GMs can use player commands without making a copy of the command for them.
|
|
|
03/05/2013, 13:04
|
#4
|
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
|
You could always re-implement the way commands work, but that's probably asking too much...
Code:
[Command("test")]
public class TestCommand : CommandBase
{
public TestCommand(GameUser user, string command)
: base(user, command)
{
}
protected override bool CanHandle { get { return !(_user.Permission < UserPermissionLevel.PM); } }
protected override bool HandleImpl()
{
_user.SendSystemMsg("Congratulations! You have enough permissions to run this command.");
return true;
}
}
|
|
|
03/05/2013, 15:09
|
#5
|
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
|
That's very similar to how public mine craft emulators do it - It's a nice way.
Nice to add a description in if you use the command incorrectly.
|
|
|
03/05/2013, 16:32
|
#6
|
elite*gold: 0
Join Date: Feb 2013
Posts: 51
Received Thanks: 22
|
i guess if u divided them into voids would be much organized, something like
public bool GmCommand(byte State ,string Msg)
{
if (State<PlayerStates.Gm) return false;
//your commands here
}
public bool PmCommand(byte State ,string Msg)
{
if (State<PlayerStates.Pm) return false;
//your commands here
}
public bool PlayerCommand(byte State ,string Msg)
{
//your commands here
}
|
|
|
03/05/2013, 23:06
|
#7
|
elite*gold: 0
Join Date: Jul 2008
Posts: 874
Received Thanks: 238
|
ur old one
PHP Code:
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(' ');
if (Cmd[0] == "/dc")
{
GC.Disconnect();
return;
}
if (Cmd[0] == "/players")
{
GC.LocalMessage(2000, "Players Online: " + Game.World.H_Chars.Count);
string eMsg = "";
foreach (Game.Character C in Game.World.H_Chars.Values)
eMsg += C.Name + ", ";
if (eMsg.Length > 1)
eMsg = eMsg.Remove(eMsg.Length - 2, 2);
GC.LocalMessage(2000, eMsg);
}
if (Cmd[0] == "/revive")
{
Game.Character C = Game.World.CharacterFromName(Cmd[1]);
if (C != null && C != GC.MyChar)
C.Ghost = false;
C.BlueName = false;
C.CurHP = (ushort)GC.MyChar.MaxHP;
C.CurMP = (ushort)GC.MyChar.MaxMP;
C.Alive = true;
C.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.Dead);
C.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.BlueName);
C.Body = GC.MyChar.Body;
C.Hair = GC.MyChar.Hair;
C.Equips.Send(GC, false);
}
if (Cmd[0] == "/forcerevive")
{
if (!GC.MyChar.Alive)
{
if (DateTime.Now > GC.MyChar.DeathHit.AddSeconds(20))
{
GC.MyChar.Ghost = false;
GC.MyChar.BlueName = false;
GC.MyChar.CurHP = (ushort)GC.MyChar.MaxHP;
GC.MyChar.Alive = true;
GC.MyChar.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.Dead);
GC.MyChar.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.BlueName);
GC.MyChar.Body = GC.MyChar.Body;
GC.MyChar.Hair = GC.MyChar.Hair;
GC.MyChar.Equips.Send(GC, false);
if (GC.MyChar.Loc.Map == 1038 && Features.GuildWars.War)
GC.MyChar.Teleport(6001, 32, 72);
else
{
if (GC.MyChar.PKPoints >= 100)
GC.MyChar.Teleport(6000, 32, 72);
else
{
foreach (ushort[] Point in Database.RevPoints)
if (Point[0] == GC.MyChar.Loc.Map)
{
GC.MyChar.Teleport(Point[1], Point[2], Point[3]);
break;
}
}
}
}
}
}
if (Cmd[0] == "/revivehere" || Cmd[0] == "/rh")
{
if (!GC.MyChar.Alive)
{
if (DateTime.Now > GC.MyChar.DeathHit.AddSeconds(20))
{
if (GC.MyChar.BlessingLasts > 0)
{
GC.MyChar.Ghost = false;
GC.MyChar.BlueName = false;
GC.MyChar.CurHP = (ushort)GC.MyChar.MaxHP;
GC.MyChar.Alive = true;
GC.MyChar.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.Dead);
GC.MyChar.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.BlueName);
GC.MyChar.Body = GC.MyChar.Body;
GC.MyChar.Hair = GC.MyChar.Hair;
GC.MyChar.Equips.Send(GC, false);
if (GC.MyChar.Loc.Map == 1038)
if (Features.GuildWars.War)
{
GC.LocalMessage(2005, "You cant revive here while guild war is on.");
}
else
{
GC.MyChar.Teleport(GC.MyChar.Loc.Map, GC.MyChar.Loc.X, GC.MyChar.Loc.Y);
}
}
}
}
}
#region GM & PM
if (GC.AuthInfo.Status == "[GM]" || GC.AuthInfo.Status == "[PM]")
{
#region PM
if (GC.AuthInfo.Status == "[PM]")
{
if (Cmd[0] == "/day")
{
Game.World.ScreenColor = 0;
foreach (Game.Character C in Game.World.H_Chars.Values)
try
{
C.MyClient.AddSend(Packets.GeneralData(C.EntityID, Game.World.ScreenColor, 0, 0, 104));
GC.LocalMessage(2011, "Haa day has arrived good morning everyone");
}
catch { }
}
if (Cmd[0] == "/night")
{
Game.World.ScreenColor = 5855577;
foreach (Game.Character C in Game.World.H_Chars.Values)
try
{
C.MyClient.AddSend(Packets.GeneralData(C.EntityID, Game.World.ScreenColor, 0, 0, 104));
GC.LocalMessage(2011,"Haa night has arrived good night everyone ");
}
catch { }
}
if (Cmd[0] == "/night1")
{
Game.World.ScreenColor = 5355577;
foreach (Game.Character C in Game.World.H_Chars.Values)
try
{
C.MyClient.AddSend(Packets.GeneralData(C.EntityID, Game.World.ScreenColor, 0, 0, 104));
}
catch { }
}
if (Cmd[0] == "/night2")
{
Game.World.ScreenColor = 6908265;
foreach (Game.Character C in Game.World.H_Chars.Values)
try
{
C.MyClient.AddSend(Packets.GeneralData(C.EntityID, Game.World.ScreenColor, 0, 0, 104));
}
catch { }
}
}
if (GC.AuthInfo.Status == "[PM]")
{
if (Cmd[0] == "/stats")
{
GC.MyChar.Str = 500;
GC.MyChar.Agi = 500;
GC.MyChar.Vit = 500;
GC.MyChar.Spi = 500;
}
}
if (GC.AuthInfo.Status == "[PM]")
{
if (Cmd[0] == "/closeserver")
{
foreach (Game.Character C in Game.World.H_Chars.Values)
try
{
C.MyClient.LogOff(true);
}
catch { continue; }
Database.SaveKOs();
Features.Guilds.SaveGuilds();
Features.SkillsClass.Save();
Environment.Exit(0);
System.Diagnostics.Process.Start("NewestCOServer.exe");
}
if (Cmd[0] == "/restart")
{
NewestCOServer.Main.AuthWorker.Listener.Close();
NewestCOServer.Main.GameWorker.Listener.Close();
try
{
foreach (Game.Character C in Game.World.H_Chars.Values)
{
try
{
C.MyClient.Disconnect();
Console.WriteLine(C.Name + " has logged off successfuly.");
}
catch { continue; }
}
}
catch { }
Database.SaveKOs();
Console.WriteLine("KOs saved.");
Database.SaveEmpire();
Console.WriteLine("Empire saved.");
Features.Guilds.SaveGuilds();
Console.WriteLine("Guilds saved.");
Features.SkillsClass.Save();
Console.WriteLine("Skills saved.");
Console.WriteLine("Database disposed.");
Console.WriteLine("Write /exit or click X to close the window.");
System.Diagnostics.Process.Start("NewestCOServer.exe");
Environment.Exit(0);
}
if (Cmd[0] == "/lucky")
GC.LocalMessage(2000, "Lucky time: " + GC.MyChar.LuckyTime);
if (Cmd[0] == "/dropevent")
{
try
{
if (Program.DropEventTimer == null)
{
bool start = true;
if (Cmd[1].ToLower() == "dragonball")
{
Program.DropEventType = "dragonball";
Program.SaveOldRate = DropRates.DragonBall;
DropRates.DragonBall = (DropRates.DragonBall * int.Parse(Cmd[3]));
}
else if (Cmd[1].ToLower() == "meteor")
{
Program.DropEventType = "meteor";
Program.SaveOldRate = DropRates.Meteor;
DropRates.Meteor = (DropRates.Meteor * int.Parse(Cmd[3]));
}
else if (Cmd[1].ToLower() == "minicpbag")
{
Program.DropEventType = "minicpbag";
Program.SaveOldRate = DropRates.CPMiniBag;
DropRates.CPMiniBag = (DropRates.CPMiniBag == 0 ? 1 : DropRates.CPMiniBag * int.Parse(Cmd[3]));
}
else if (Cmd[1].ToLower() == "cpbag")
{
Program.DropEventType = "cpbag";
Program.SaveOldRate = DropRates.CPBag;
DropRates.CPBag = (DropRates.CPBag == 0 ? 1 : DropRates.CPBag * int.Parse(Cmd[3]));
}
else
start = false;
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] == "/vip")
{
GC.MyChar.VipLevel = byte.Parse(Cmd[1]);
GC.AddSend(Packets.ChatMessage(0, "SYSTEM", GC.MyChar.Name, "Congratulations! Your vip level is " + GC.MyChar.VipLevel +". Thank you for donating.", 2001, 0));
}
if (Cmd[0] == "/spawn")
{
if (Cmd.Length == 3)
{
GC.SpawnOnHold = !GC.SpawnOnHold;
if (GC.SpawnOnHold)
{
GC.SpawnXStart = GC.MyChar.Loc.X;
GC.SpawnYStart = GC.MyChar.Loc.Y;
GC.LocalMessage(2000, "Starting to create spawn; Spawn starts: " + GC.SpawnXStart + ", " + GC.SpawnYStart);
}
else
{
GC.LocalMessage(2000, "Ending the spawn.");
StreamWriter SW = new StreamWriter(@"C:\OldCODB\MobSpawns.txt", true);
SW.WriteLine(Cmd[1] + " " + Cmd[2] + " " + GC.MyChar.Loc.Map + " " + GC.SpawnXStart + " " + GC.SpawnYStart + " " + GC.MyChar.Loc.X + " " + GC.MyChar.Loc.Y);
SW.Flush();
SW.Close();
}
}
}
if (Cmd[0] == "/try")
GC.AddSend(Packets.GeneralData(GC.MyChar.EntityID, 0, 0, 0, byte.Parse(Cmd[1])));
if (Cmd[0] == "/shopflag")
{
Game.NPC N = new NewestCOServer.Game.NPC(1234.ToString() + ' ' + 1080 + ' ' + 16 + ' ' + 6 + ' ' + 0 + ' ' + GC.MyChar.Loc.Map + ' ' + GC.MyChar.Loc.X + ' ' + GC.MyChar.Loc.Y);
Game.World.Spawn(N);
}
if (Cmd[0] == "/guard")
{
StreamWriter SW = new StreamWriter(@"C:\OldCODB\MobSpawns.txt", true);
SW.WriteLine(97 + " " + 1 + " " + GC.MyChar.Loc.Map + " " + GC.MyChar.Loc.X + " " + GC.MyChar.Loc.Y + " " + GC.MyChar.Loc.X + " " + GC.MyChar.Loc.Y);
SW.Flush();
SW.Close();
}
if (Cmd[0] == "/quiz")
if (!Features.QuizShow.QuizON)
Features.QuizShow.Start();
if (Cmd[0] == "/mb")
GC.MyChar.AddItem(721080);
if (Cmd[0] == "/status")
GC.AddSend(Packets.Status(GC.MyChar.EntityID, (NewestCOServer.Game.Status)byte.Parse(Cmd[1]), ulong.Parse(Cmd[2])));
if (Cmd[0] == "/xp")
{
GC.MyChar.StatEff.Add(NewestCOServer.Game.StatusEffectEn.XPStart);
GC.MyChar.Buffs.Add(new Game.Buff() { StEff = NewestCOServer.Game.StatusEffectEn.XPStart, Lasts = 20, Started = DateTime.Now, Eff = NewestCOServer.Features.SkillsClass.ExtraEffect.None });
}
if (Cmd[0] == "/life")
{
GC.MyChar.CurMP = (ushort)GC.MyChar.MaxMP;
GC.MyChar.CurHP = (ushort)GC.MyChar.MaxHP;
}
if (Cmd[0] == "/scroll")
{
if (Cmd[1] == "tc")
GC.MyChar.Teleport(1002, 432, 380);
if (Cmd[1] == "bi")
GC.MyChar.Teleport(1015, 716, 575);
if (Cmd[1] == "pc")
GC.MyChar.Teleport(1011, 193, 261);
if (Cmd[1] == "dc")
GC.MyChar.Teleport(1000, 500, 650);
if (Cmd[1] == "ac")
GC.MyChar.Teleport(1020, 565, 562);
if (Cmd[1] == "ma")
GC.MyChar.Teleport(1036, 211, 196);
if (Cmd[1] == "pka")
GC.MyChar.Teleport(1005, 50, 50);
if (Cmd[1] == "house")
GC.MyChar.Teleport(1099, 44, 40);
if (Cmd[1] == "ship")
//This works only if you have the ship map
GC.MyChar.Teleport(9999, 67, 52);
}
if (Cmd[0] == "/newguild")
{
if (GC.MyChar.MyGuild == null)
{
try
{
ushort NewGuildID = (ushort)Program.Rnd.Next(ushort.MaxValue);
while (Features.Guilds.AllTheGuilds.Contains(NewGuildID))
NewGuildID = (ushort)Program.Rnd.Next(ushort.MaxValue);
Features.Guilds.CreateNewGuild(Cmd[1], NewGuildID, GC.MyChar);
Game.World.Spawn(GC.MyChar, false);
GC.AddSend(Packets.GuildInfo(GC.MyChar.MyGuild, GC.MyChar));
GC.AddSend(Packets.String(GC.MyChar.MyGuild.GuildID, (byte)Game.StringType.GuildName, GC.MyChar.MyGuild.GuildName));
}
catch (Exception Exc) { Program.WriteLine(Exc); }
}
}
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;
if (Cmd[2].ToLower() == "refined") Quality = Game.Item.ItemQuality.Refined;
else if (Cmd[2].ToLower() == "unique") Quality = Game.Item.ItemQuality.Unique;
else if (Cmd[2].ToLower() == "elite") Quality = Game.Item.ItemQuality.Elite;
else if (Cmd[2].ToLower() == "super") Quality = Game.Item.ItemQuality.Super;
else if (Cmd[2].ToLower() == "simple") Quality = Game.Item.ItemQuality.Simple;
else if (Cmd[2].ToLower() == "fixed") Quality = Game.Item.ItemQuality.Fixed;
else if (Cmd[2].ToLower() == "poor") Quality = Game.Item.ItemQuality.Poor;
else if (Cmd[2].ToLower() == "normal") Quality = Game.Item.ItemQuality.Normal;
if (e.Quality == Quality)
break;
}
if (ID != 0 && GC.MyChar.Inventory.Count < 40)
{
Game.ItemIDManipulation e = new Game.ItemIDManipulation(ID);
Game.Item.ItemQuality Quality = e.Quality;
bool change = true;
if (Cmd[2].ToLower() == "refined") Quality = Game.Item.ItemQuality.Refined;
else if (Cmd[2].ToLower() == "unique") Quality = Game.Item.ItemQuality.Unique;
else if (Cmd[2].ToLower() == "elite") Quality = Game.Item.ItemQuality.Elite;
else if (Cmd[2].ToLower() == "super") Quality = Game.Item.ItemQuality.Super;
else if (Cmd[2].ToLower() == "simple") Quality = Game.Item.ItemQuality.Simple;
else if (Cmd[2].ToLower() == "fixed") Quality = Game.Item.ItemQuality.Fixed;
else if (Cmd[2].ToLower() == "poor") Quality = Game.Item.ItemQuality.Poor;
else if (Cmd[2].ToLower() == "normal") Quality = Game.Item.ItemQuality.Normal;
else change = false;
if (change)
e.QualityChange(Quality);
ID = e.ToID();
if (!Database.DatabaseItems.ContainsKey(ID))
{
return;
}
Game.Item I = new NewestCOServer.Game.Item();
if (e.Part(0, 2) == 11 || e.Part(0, 2) == 13 || e.Part(0, 3) == 123 || e.Part(0, 3) == 141 || e.Part(0, 3) == 142)
I.Color = NewestCOServer.Game.Item.ArmorColor.Orange;
//I.FreeItem = true;
I.ID = ID;
I.UID = (uint)Program.Rnd.Next(10000000);
try
{
I.MaxDur = I.DBInfo.Durability;
I.CurDur = I.MaxDur;
}
catch (Exception Exc) { Program.WriteLine(Exc); }
try
{
I.Plus = byte.Parse(Cmd[3]);
}
catch { }
try
{
I.Bless = byte.Parse(Cmd[4]);
}
catch { }
try
{
I.Enchant = byte.Parse(Cmd[5]);
}
catch { }
try
{
I.Soc1 = (Game.Item.Gem)byte.Parse(Cmd[6]);
}
catch { }
try
{
I.Soc2 = (Game.Item.Gem)byte.Parse(Cmd[7]);
}
catch { }
I.Effect = NewestCOServer.Game.Item.RebornEffect.None;
GC.MyChar.AddItem(I);
}
}
}
}
else
Game.World.Chat(GC.MyChar, ChatType, From, To, Message);
}
catch { }
}
}
}
try to adjust this as u like
PHP Code:
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);
}
#endregion GM
}
else
Game.World.Chat(GC.MyChar, ChatType, From, To, Message);
}
catch { }
}
}
}
|
|
|
03/06/2013, 01:46
|
#8
|
elite*gold: 0
Join Date: Mar 2013
Posts: 44
Received Thanks: 2
|
Quote:
Originally Posted by abdoumatrix
ur old one
PHP Code:
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(' ');
if (Cmd[0] == "/dc")
{
GC.Disconnect();
return;
}
if (Cmd[0] == "/players")
{
GC.LocalMessage(2000, "Players Online: " + Game.World.H_Chars.Count);
string eMsg = "";
foreach (Game.Character C in Game.World.H_Chars.Values)
eMsg += C.Name + ", ";
if (eMsg.Length > 1)
eMsg = eMsg.Remove(eMsg.Length - 2, 2);
GC.LocalMessage(2000, eMsg);
}
if (Cmd[0] == "/revive")
{
Game.Character C = Game.World.CharacterFromName(Cmd[1]);
if (C != null && C != GC.MyChar)
C.Ghost = false;
C.BlueName = false;
C.CurHP = (ushort)GC.MyChar.MaxHP;
C.CurMP = (ushort)GC.MyChar.MaxMP;
C.Alive = true;
C.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.Dead);
C.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.BlueName);
C.Body = GC.MyChar.Body;
C.Hair = GC.MyChar.Hair;
C.Equips.Send(GC, false);
}
if (Cmd[0] == "/forcerevive")
{
if (!GC.MyChar.Alive)
{
if (DateTime.Now > GC.MyChar.DeathHit.AddSeconds(20))
{
GC.MyChar.Ghost = false;
GC.MyChar.BlueName = false;
GC.MyChar.CurHP = (ushort)GC.MyChar.MaxHP;
GC.MyChar.Alive = true;
GC.MyChar.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.Dead);
GC.MyChar.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.BlueName);
GC.MyChar.Body = GC.MyChar.Body;
GC.MyChar.Hair = GC.MyChar.Hair;
GC.MyChar.Equips.Send(GC, false);
if (GC.MyChar.Loc.Map == 1038 && Features.GuildWars.War)
GC.MyChar.Teleport(6001, 32, 72);
else
{
if (GC.MyChar.PKPoints >= 100)
GC.MyChar.Teleport(6000, 32, 72);
else
{
foreach (ushort[] Point in Database.RevPoints)
if (Point[0] == GC.MyChar.Loc.Map)
{
GC.MyChar.Teleport(Point[1], Point[2], Point[3]);
break;
}
}
}
}
}
}
if (Cmd[0] == "/revivehere" || Cmd[0] == "/rh")
{
if (!GC.MyChar.Alive)
{
if (DateTime.Now > GC.MyChar.DeathHit.AddSeconds(20))
{
if (GC.MyChar.BlessingLasts > 0)
{
GC.MyChar.Ghost = false;
GC.MyChar.BlueName = false;
GC.MyChar.CurHP = (ushort)GC.MyChar.MaxHP;
GC.MyChar.Alive = true;
GC.MyChar.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.Dead);
GC.MyChar.StatEff.Remove(NewestCOServer.Game.StatusEffectEn.BlueName);
GC.MyChar.Body = GC.MyChar.Body;
GC.MyChar.Hair = GC.MyChar.Hair;
GC.MyChar.Equips.Send(GC, false);
if (GC.MyChar.Loc.Map == 1038)
if (Features.GuildWars.War)
{
GC.LocalMessage(2005, "You cant revive here while guild war is on.");
}
else
{
GC.MyChar.Teleport(GC.MyChar.Loc.Map, GC.MyChar.Loc.X, GC.MyChar.Loc.Y);
}
}
}
}
}
#region GM & PM
if (GC.AuthInfo.Status == "[GM]" || GC.AuthInfo.Status == "[PM]")
{
#region PM
if (GC.AuthInfo.Status == "[PM]")
{
if (Cmd[0] == "/day")
{
Game.World.ScreenColor = 0;
foreach (Game.Character C in Game.World.H_Chars.Values)
try
{
C.MyClient.AddSend(Packets.GeneralData(C.EntityID, Game.World.ScreenColor, 0, 0, 104));
GC.LocalMessage(2011, "Haa day has arrived good morning everyone");
}
catch { }
}
if (Cmd[0] == "/night")
{
Game.World.ScreenColor = 5855577;
foreach (Game.Character C in Game.World.H_Chars.Values)
try
{
C.MyClient.AddSend(Packets.GeneralData(C.EntityID, Game.World.ScreenColor, 0, 0, 104));
GC.LocalMessage(2011,"Haa night has arrived good night everyone ");
}
catch { }
}
if (Cmd[0] == "/night1")
{
Game.World.ScreenColor = 5355577;
foreach (Game.Character C in Game.World.H_Chars.Values)
try
{
C.MyClient.AddSend(Packets.GeneralData(C.EntityID, Game.World.ScreenColor, 0, 0, 104));
}
catch { }
}
if (Cmd[0] == "/night2")
{
Game.World.ScreenColor = 6908265;
foreach (Game.Character C in Game.World.H_Chars.Values)
try
{
C.MyClient.AddSend(Packets.GeneralData(C.EntityID, Game.World.ScreenColor, 0, 0, 104));
}
catch { }
}
}
if (GC.AuthInfo.Status == "[PM]")
{
if (Cmd[0] == "/stats")
{
GC.MyChar.Str = 500;
GC.MyChar.Agi = 500;
GC.MyChar.Vit = 500;
GC.MyChar.Spi = 500;
}
}
if (GC.AuthInfo.Status == "[PM]")
{
if (Cmd[0] == "/closeserver")
{
foreach (Game.Character C in Game.World.H_Chars.Values)
try
{
C.MyClient.LogOff(true);
}
catch { continue; }
Database.SaveKOs();
Features.Guilds.SaveGuilds();
Features.SkillsClass.Save();
Environment.Exit(0);
System.Diagnostics.Process.Start("NewestCOServer.exe");
}
if (Cmd[0] == "/restart")
{
NewestCOServer.Main.AuthWorker.Listener.Close();
NewestCOServer.Main.GameWorker.Listener.Close();
try
{
foreach (Game.Character C in Game.World.H_Chars.Values)
{
try
{
C.MyClient.Disconnect();
Console.WriteLine(C.Name + " has logged off successfuly.");
}
catch { continue; }
}
}
catch { }
Database.SaveKOs();
Console.WriteLine("KOs saved.");
Database.SaveEmpire();
Console.WriteLine("Empire saved.");
Features.Guilds.SaveGuilds();
Console.WriteLine("Guilds saved.");
Features.SkillsClass.Save();
Console.WriteLine("Skills saved.");
Console.WriteLine("Database disposed.");
Console.WriteLine("Write /exit or click X to close the window.");
System.Diagnostics.Process.Start("NewestCOServer.exe");
Environment.Exit(0);
}
if (Cmd[0] == "/lucky")
GC.LocalMessage(2000, "Lucky time: " + GC.MyChar.LuckyTime);
if (Cmd[0] == "/dropevent")
{
try
{
if (Program.DropEventTimer == null)
{
bool start = true;
if (Cmd[1].ToLower() == "dragonball")
{
Program.DropEventType = "dragonball";
Program.SaveOldRate = DropRates.DragonBall;
DropRates.DragonBall = (DropRates.DragonBall * int.Parse(Cmd[3]));
}
else if (Cmd[1].ToLower() == "meteor")
{
Program.DropEventType = "meteor";
Program.SaveOldRate = DropRates.Meteor;
DropRates.Meteor = (DropRates.Meteor * int.Parse(Cmd[3]));
}
else if (Cmd[1].ToLower() == "minicpbag")
{
Program.DropEventType = "minicpbag";
Program.SaveOldRate = DropRates.CPMiniBag;
DropRates.CPMiniBag = (DropRates.CPMiniBag == 0 ? 1 : DropRates.CPMiniBag * int.Parse(Cmd[3]));
}
else if (Cmd[1].ToLower() == "cpbag")
{
Program.DropEventType = "cpbag";
Program.SaveOldRate = DropRates.CPBag;
DropRates.CPBag = (DropRates.CPBag == 0 ? 1 : DropRates.CPBag * int.Parse(Cmd[3]));
}
else
start = false;
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] == "/vip")
{
GC.MyChar.VipLevel = byte.Parse(Cmd[1]);
GC.AddSend(Packets.ChatMessage(0, "SYSTEM", GC.MyChar.Name, "Congratulations! Your vip level is " + GC.MyChar.VipLevel +". Thank you for donating.", 2001, 0));
}
if (Cmd[0] == "/spawn")
{
if (Cmd.Length == 3)
{
GC.SpawnOnHold = !GC.SpawnOnHold;
if (GC.SpawnOnHold)
{
GC.SpawnXStart = GC.MyChar.Loc.X;
GC.SpawnYStart = GC.MyChar.Loc.Y;
GC.LocalMessage(2000, "Starting to create spawn; Spawn starts: " + GC.SpawnXStart + ", " + GC.SpawnYStart);
}
else
{
GC.LocalMessage(2000, "Ending the spawn.");
StreamWriter SW = new StreamWriter(@"C:\OldCODB\MobSpawns.txt", true);
SW.WriteLine(Cmd[1] + " " + Cmd[2] + " " + GC.MyChar.Loc.Map + " " + GC.SpawnXStart + " " + GC.SpawnYStart + " " + GC.MyChar.Loc.X + " " + GC.MyChar.Loc.Y);
SW.Flush();
SW.Close();
}
}
}
if (Cmd[0] == "/try")
GC.AddSend(Packets.GeneralData(GC.MyChar.EntityID, 0, 0, 0, byte.Parse(Cmd[1])));
if (Cmd[0] == "/shopflag")
{
Game.NPC N = new NewestCOServer.Game.NPC(1234.ToString() + ' ' + 1080 + ' ' + 16 + ' ' + 6 + ' ' + 0 + ' ' + GC.MyChar.Loc.Map + ' ' + GC.MyChar.Loc.X + ' ' + GC.MyChar.Loc.Y);
Game.World.Spawn(N);
}
if (Cmd[0] == "/guard")
{
StreamWriter SW = new StreamWriter(@"C:\OldCODB\MobSpawns.txt", true);
SW.WriteLine(97 + " " + 1 + " " + GC.MyChar.Loc.Map + " " + GC.MyChar.Loc.X + " " + GC.MyChar.Loc.Y + " " + GC.MyChar.Loc.X + " " + GC.MyChar.Loc.Y);
SW.Flush();
SW.Close();
}
if (Cmd[0] == "/quiz")
if (!Features.QuizShow.QuizON)
Features.QuizShow.Start();
if (Cmd[0] == "/mb")
GC.MyChar.AddItem(721080);
if (Cmd[0] == "/status")
GC.AddSend(Packets.Status(GC.MyChar.EntityID, (NewestCOServer.Game.Status)byte.Parse(Cmd[1]), ulong.Parse(Cmd[2])));
if (Cmd[0] == "/xp")
{
GC.MyChar.StatEff.Add(NewestCOServer.Game.StatusEffectEn.XPStart);
GC.MyChar.Buffs.Add(new Game.Buff() { StEff = NewestCOServer.Game.StatusEffectEn.XPStart, Lasts = 20, Started = DateTime.Now, Eff = NewestCOServer.Features.SkillsClass.ExtraEffect.None });
}
if (Cmd[0] == "/life")
{
GC.MyChar.CurMP = (ushort)GC.MyChar.MaxMP;
GC.MyChar.CurHP = (ushort)GC.MyChar.MaxHP;
}
if (Cmd[0] == "/scroll")
{
if (Cmd[1] == "tc")
GC.MyChar.Teleport(1002, 432, 380);
if (Cmd[1] == "bi")
GC.MyChar.Teleport(1015, 716, 575);
if (Cmd[1] == "pc")
GC.MyChar.Teleport(1011, 193, 261);
if (Cmd[1] == "dc")
GC.MyChar.Teleport(1000, 500, 650);
if (Cmd[1] == "ac")
GC.MyChar.Teleport(1020, 565, 562);
if (Cmd[1] == "ma")
GC.MyChar.Teleport(1036, 211, 196);
if (Cmd[1] == "pka")
GC.MyChar.Teleport(1005, 50, 50);
if (Cmd[1] == "house")
GC.MyChar.Teleport(1099, 44, 40);
if (Cmd[1] == "ship")
//This works only if you have the ship map
GC.MyChar.Teleport(9999, 67, 52);
}
if (Cmd[0] == "/newguild")
{
if (GC.MyChar.MyGuild == null)
{
try
{
ushort NewGuildID = (ushort)Program.Rnd.Next(ushort.MaxValue);
while (Features.Guilds.AllTheGuilds.Contains(NewGuildID))
NewGuildID = (ushort)Program.Rnd.Next(ushort.MaxValue);
Features.Guilds.CreateNewGuild(Cmd[1], NewGuildID, GC.MyChar);
Game.World.Spawn(GC.MyChar, false);
GC.AddSend(Packets.GuildInfo(GC.MyChar.MyGuild, GC.MyChar));
GC.AddSend(Packets.String(GC.MyChar.MyGuild.GuildID, (byte)Game.StringType.GuildName, GC.MyChar.MyGuild.GuildName));
}
catch (Exception Exc) { Program.WriteLine(Exc); }
}
}
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;
if (Cmd[2].ToLower() == "refined") Quality = Game.Item.ItemQuality.Refined;
else if (Cmd[2].ToLower() == "unique") Quality = Game.Item.ItemQuality.Unique;
else if (Cmd[2].ToLower() == "elite") Quality = Game.Item.ItemQuality.Elite;
else if (Cmd[2].ToLower() == "super") Quality = Game.Item.ItemQuality.Super;
else if (Cmd[2].ToLower() == "simple") Quality = Game.Item.ItemQuality.Simple;
else if (Cmd[2].ToLower() == "fixed") Quality = Game.Item.ItemQuality.Fixed;
else if (Cmd[2].ToLower() == "poor") Quality = Game.Item.ItemQuality.Poor;
else if (Cmd[2].ToLower() == "normal") Quality = Game.Item.ItemQuality.Normal;
if (e.Quality == Quality)
break;
}
if (ID != 0 && GC.MyChar.Inventory.Count < 40)
{
Game.ItemIDManipulation e = new Game.ItemIDManipulation(ID);
Game.Item.ItemQuality Quality = e.Quality;
bool change = true;
if (Cmd[2].ToLower() == "refined") Quality = Game.Item.ItemQuality.Refined;
else if (Cmd[2].ToLower() == "unique") Quality = Game.Item.ItemQuality.Unique;
else if (Cmd[2].ToLower() == "elite") Quality = Game.Item.ItemQuality.Elite;
else if (Cmd[2].ToLower() == "super") Quality = Game.Item.ItemQuality.Super;
else if (Cmd[2].ToLower() == "simple") Quality = Game.Item.ItemQuality.Simple;
else if (Cmd[2].ToLower() == "fixed") Quality = Game.Item.ItemQuality.Fixed;
else if (Cmd[2].ToLower() == "poor") Quality = Game.Item.ItemQuality.Poor;
else if (Cmd[2].ToLower() == "normal") Quality = Game.Item.ItemQuality.Normal;
else change = false;
if (change)
e.QualityChange(Quality);
ID = e.ToID();
if (!Database.DatabaseItems.ContainsKey(ID))
{
return;
}
Game.Item I = new NewestCOServer.Game.Item();
if (e.Part(0, 2) == 11 || e.Part(0, 2) == 13 || e.Part(0, 3) == 123 || e.Part(0, 3) == 141 || e.Part(0, 3) == 142)
I.Color = NewestCOServer.Game.Item.ArmorColor.Orange;
//I.FreeItem = true;
I.ID = ID;
I.UID = (uint)Program.Rnd.Next(10000000);
try
{
I.MaxDur = I.DBInfo.Durability;
I.CurDur = I.MaxDur;
}
catch (Exception Exc) { Program.WriteLine(Exc); }
try
{
I.Plus = byte.Parse(Cmd[3]);
}
catch { }
try
{
I.Bless = byte.Parse(Cmd[4]);
}
catch { }
try
{
I.Enchant = byte.Parse(Cmd[5]);
}
catch { }
try
{
I.Soc1 = (Game.Item.Gem)byte.Parse(Cmd[6]);
}
catch { }
try
{
I.Soc2 = (Game.Item.Gem)byte.Parse(Cmd[7]);
}
catch { }
I.Effect = NewestCOServer.Game.Item.RebornEffect.None;
GC.MyChar.AddItem(I);
}
}
}
}
else
Game.World.Chat(GC.MyChar, ChatType, From, To, Message);
}
catch { }
}
}
}
try to adjust this as u like
PHP Code:
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);
}
#endregion GM
}
else
Game.World.Chat(GC.MyChar, ChatType, From, To, Message);
}
catch { }
}
}
}
|
ohh, yea thanks! I'll try this
|
|
|
03/06/2013, 02:16
|
#9
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,283
Received Thanks: 4,192
|
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.
|
|
|
03/06/2013, 05:30
|
#10
|
elite*gold: 0
Join Date: Feb 2013
Posts: 51
Received Thanks: 22
|
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
|
|
|
03/06/2013, 05:56
|
#11
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,283
Received Thanks: 4,192
|
@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).
|
|
|
03/06/2013, 13:02
|
#12
|
elite*gold: 0
Join Date: Jul 2008
Posts: 874
Received Thanks: 238
|
Quote:
Originally Posted by Fаng
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
|
Nice job
|
|
|
03/06/2013, 16:05
|
#13
|
elite*gold: 0
Join Date: Mar 2013
Posts: 44
Received Thanks: 2
|
Correct me if i'm wrong:
GM and PM:
Code:
if (GC.AuthInfo.Status != "[GM]" && GC.AuthInfo.Status != "[PM]")
ONLY PM:
Code:
if (GC.AuthInfo.Status != "[PM]")
ONLY NORMAL(Or all normal, gm and pm?):
Code:
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 :-)
|
|
|
03/06/2013, 18:36
|
#14
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
|
Quote:
Originally Posted by xScylez
Correct me if i'm wrong:
GM and PM:
Code:
if (GC.AuthInfo.Status != "[GM]" && GC.AuthInfo.Status != "[PM]")
ONLY PM:
Code:
if (GC.AuthInfo.Status != "[PM]")
ONLY NORMAL(Or all normal, gm and pm?):
Code:
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.
|
|
|
03/06/2013, 18:45
|
#15
|
elite*gold: 0
Join Date: Mar 2013
Posts: 44
Received Thanks: 2
|
Quote:
Originally Posted by pro4never
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.
|
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;
}
On the
Code:
string Name = Cmd[1];
, i have the error on "Cmd"
|
|
|
 |
|
Similar Threads
|
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?
|
All times are GMT +1. The time now is 19:37.
|
|