1: ItemBuying: when I try to buy an item it discounts the money from me but doesn't give me the item, wtf? I fixed the ItemBuy.cs but still nothing.
2: ItemSelling: same for item buying just that I can't get any item or sell it lol...
3: Commands: my commands for 5095 do not want to work somehow...I do
/item ConquestArmor Super 12 7 255 13 13(yes, that's the correct way) and it says "unable to spawn item. Error!" and all of my commands work...
Here's my ItemBuy.cs
Code:
/*
* Created by SharpDevelop.
* User: sams
* Date: 3/28/2009
* Time: 12:46 AM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using CoEmu_v2_GameServer;
using CoEmu_v2_GameServer.Connections;
using CoEmu_v2_GameServer.Entities;
using CoEmu_v2_GameServer.Structs;
using CoEmu_v2_GameServer.Packets;
using CoEmu_v2_GameServer.Calculations;
using CoEmu_v2_GameServer.Database;
namespace CoEmu_v2_GameServer.Handlers
{
public partial class Handler
{
public static bool itemexist(string find, string where)
{
int Begin = where.IndexOf(find);
int End = where.LastIndexOf(find);
if (Begin >= 0 && End >= 0)
return true;
else
return false;
}
public static void ItemBuy(byte[] Data, ClientSocket CSocket)
{
int ID = PacketProcessor.ReadLong(Data, 8);
byte Amount = Data[20];
uint ShopID = BitConverter.ToUInt32(Data, 4);
if (ShopID != 2888 && ID / 10000 == 106)
{ PortalBuy(ID, CSocket); return; }
if (CSocket.Client.Inventory.Count == 40)
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Your inventory is full.", Struct.ChatType.Top));
return;
}
string Shop = System.IO.File.ReadAllText("Shop.dat");
if (itemexist(Convert.ToString(ID), Shop))
{
Struct.ItemInfo Item = new Struct.ItemInfo();
if (Nano.Items.ContainsKey(ID))
{
Struct.ItemData NewItem = Nano.Items[ID];
Item = NewItem;
if (NewItem.CPCost > 0)
{
if (CSocket.Client.CPs >= NewItem.CPCost * Amount)
{
for (byte x = 0; x < Amount; x++)
{
Item = new Struct.ItemInfo();
Item = NewItem;
Item.Color = new Random().Next(3, 9);
Handler.CPs(NewItem.CPCost * -1, CSocket);
Item.ItemID = NewItem.ID;
Item.UID = Database.Database.ItemUID;
int Plus = 0;
if (Item.ItemID >= 730001 && Item.ItemID <= 730009)
Plus = Item.ItemID % 10;
Item.Plus = Plus;
bool created = Database.Database.NewItem(Item, CSocket);
CSocket.Client.Inventory.Add(Item.UID, Item);
CSocket.Send(ConquerPacket.ItemInfo(Item.UID, Item.ItemID, Plus, 0, 0, 0, 0, Item.MaxDura, Item.MaxDura, 0, 0, 0, 0, 0, 0, Item.Color));
}
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " You do not have enough CPs.", Struct.ChatType.Top));
}
}
else if (NewItem.Cost > 0)
{
if (CSocket.Client.Money >= NewItem.Cost)
{
Handler.Money(NewItem.Cost * -1, CSocket);
Item.ItemID = NewItem.ID;
Item.UID = Database.Database.ItemUID;
bool created = Database.Database.NewItem(Item, CSocket);
CSocket.Client.Inventory.Add(Item.UID, Item);
CSocket.Send(ConquerPacket.ItemInfo(Item.UID, Item.ItemID, 0, 0, 0, 0, 0, Item.MaxDura, Item.MaxDura, 0, 0, 0, 0, 0, 0, Item.Color));
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " You do not have enough money.", Struct.ChatType.Top));
}
}
else
{
Item.ItemID = NewItem.ID;
Item.UID = Database.Database.ItemUID;
bool created = Database.Database.NewItem(Item, CSocket);
CSocket.Client.Inventory.Add(Item.UID, Item);
CSocket.Send(ConquerPacket.ItemInfo(Item.UID, Item.ItemID, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
}
}
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Item does not exist in Shop.dat", Struct.ChatType.Top));
}
}
static void PortalBuy(int ID, ClientSocket CSocket)
{
Struct.ItemData NewItem = Nano.Items[ID];
Struct.ItemInfo Item = NewItem;
if (CSocket.Client.Money >= 200)
{
Item = new Struct.ItemInfo();
Item = NewItem;
Item.Color = new Random().Next(3, 9);
Handler.Money(200 * -1, CSocket);
Item.ItemID = NewItem.ID;
Item.UID = Database.Database.ItemUID;
int Plus = 0;
if (Item.ItemID >= 730001 && Item.ItemID <= 730009)
Plus = Item.ItemID % 10;
Item.Plus = Plus;
bool created = Database.Database.NewItem(Item, CSocket);
CSocket.Client.Inventory.Add(Item.UID, Item);
CSocket.Send(ConquerPacket.ItemInfo(Item.UID, Item.ItemID, Plus, 0, 0, 0, 0, Item.MaxDura, Item.MaxDura, 0, 0, 0, 0, 0, 0, Item.Color));
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " You do not have enough money.", Struct.ChatType.Top));
}
}
}
}
Code:
/*
* Created by SharpDevelop.
* User: sams
* Date: 3/29/2009
* Time: 12:57 AM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using CoEmu_v2_GameServer.Connections;
using CoEmu_v2_GameServer.Entities;
using CoEmu_v2_GameServer.Structs;
using CoEmu_v2_GameServer.Packets;
using CoEmu_v2_GameServer.Calculations;
using CoEmu_v2_GameServer.Database;
namespace CoEmu_v2_GameServer.Handlers
{
public partial class Handler
{
public static void ItemSell(byte[] Data, ClientSocket CSocket)
{
int ItemUID = PacketProcessor.ReadLong(Data, 8);
if(CSocket.Client.Inventory.ContainsKey(ItemUID))
{
Struct.ItemInfo Item = new Struct.ItemInfo();
Item = CSocket.Client.Inventory[ItemUID];
if(Nano.Items.ContainsKey(Item.ItemID))
{
Struct.ItemData iData = Nano.Items[Item.ItemID];
int Money = iData.Cost/3;
if(Money > 0)
{
CSocket.Client.Money += Money;
CSocket.Client.Inventory.Remove(Item.UID);
CSocket.Send(ConquerPacket.ItemUsage(Item.UID, 255, Struct.ItemUsage.RemoveItem));
Database.Database.DeleteItem(Item.UID);
CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Money, Struct.StatusTypes.InvMoney));
}
}
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] You do not have that item..", Struct.ChatType.Top));
}
}
}
}
Code:
/*
* Created by SharpDevelop.
* User: sams
* Date: 3/11/2009
* Time: 12:08 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using CoEmu_v2_GameServer.Connections;
using CoEmu_v2_GameServer.Database;
using CoEmu_v2_GameServer.Entities;
using CoEmu_v2_GameServer.Structs;
using CoEmu_v2_GameServer.Packets;
using CoEmu_v2_GameServer.Calculations;
using System.Runtime.InteropServices;
namespace CoEmu_v2_GameServer.Handlers
{
/// <summary>
/// Handles chatting in the CoEmu world.
/// </summary>
public partial class Handler
{
static int x = 0;
public static void Chat(byte[] Data, ClientSocket CSocket)
{
Struct.ChatType Type = (Struct.ChatType)((Data[9] << 8) + Data[8]);
int Position = 26;
int Len = 0;
string From = "";
string To = "";
string Message = "";
for (int C = 0; C < Data[25]; C++)
{
From += Convert.ToChar(Data[Position]);
Position++;
}
Len = Data[Position];
Position++;
for (int C = 0; C < Len; C++)
{
To += Convert.ToChar(Data[Position]);
Position++;
}
Position++;
Len = Data[Position];
Position++;
for (int C = 0; C < Len; C++)
{
Message += Convert.ToChar(Data[Position]);
Position++;
}
try
{
if (Message.StartsWith("/"))
{
#region Commands
string[] Command = Message.Substring(1).Split(' ');
switch (Command[0].ToLower())
{
case "a":
{
ulong val = 0;
switch (x)
{
case 0:
val = 0x400000000; break;
case 1:
val = 0x800000000; break;
case 2:
val = 0x1000000000; break;
case 3:
val = 0x2000000000; break;
case 4:
val = 0x4000000000; break;
case 5:
val = 0x8000000000; break;
case 6:
val = 0x10000000000; break;
case 7:
val = 0x20000000000; break;
case 8:
val = 0x40000000000; break;
case 9:
val = 0x80000000000; break;
case 10:
val = 0x800000000000; break;
case 11:
val = 0x400000000000; break;
default:
val = 0x1000000000000; break;
}
x++;
CSocket.Send(ConquerPacket.Status(CSocket, 0, val, Struct.StatusTypes.StatusEffect));
} break;
case "counter":
{
if (Command[1] == "on")
{
if (CSocket.Client.isGM)
{
CSocket.Client.CounterKillOn = true;
CSocket.Client.CounterKillRate = 100;
CSocket.Client.CounterKillTime = 0;
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "Counter kill activated", Struct.ChatType.Top));
ConquerPacket.ToServer(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", CSocket.Client.Name + " Has become invincible! All attackers will be punished", Struct.ChatType.Center), 0);
}
}
else
{
CSocket.Client.CounterKillOn = false;
CSocket.Client.CounterKillRate = 0;
CSocket.Client.CounterKillTime = 1000;
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Counter kill deactivated!", Struct.ChatType.Top));
}
break;
}
case "dc":
{
CSocket.Disconnect();
break;
}
case "kick":
{
if (CSocket.Client.isGM || CSocket.Client.isPM)
{
if (Command.Length < 2)
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Command example: /kick (name)", Struct.ChatType.Talk));
break;
}
bool kicked = false;
//lock(Nano.ClientPool)
//{
try
{
Monitor.Enter(Nano.ClientPool);
foreach (KeyValuePair<int, ClientSocket> Player in Nano.ClientPool)
{
if (Player.Value.Client.Name.ToLower() == Command[1].ToLower())
{
if (Player.Value.Client.isPM && !CSocket.Client.isPM)
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "GMs cannot kick PMs, sorry!", Struct.ChatType.Top));
else
{
ConquerPacket.ToServer(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", Player.Value.Client.Name + " has been kicked from the server", Struct.ChatType.Center), 0);
Player.Value.Disconnect();
kicked = true;
}
break;
}
}
//}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
Monitor.Exit(Nano.ClientPool);
}
if (!kicked)
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Cannot kick player.", Struct.ChatType.Talk));
}
}
break;
}
case "ban":
{
if (CSocket.Client.isPM)
{
if (Command.Length < 2)
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Command example: /ban (name)", Struct.ChatType.Talk));
break;
}
bool kicked = false;
Database.Database.BanPlayer(Command[1]);
//lock(Nano.ClientPool)
//{
try
{
Monitor.Enter(Nano.ClientPool);
foreach (KeyValuePair<int, ClientSocket> Player in Nano.ClientPool)
{
if (Player.Value.Client.Name.ToLower() == Command[1].ToLower())
{
ConquerPacket.ToServer(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", Player.Value.Client.Name + " has been kicked & banned from the server.", Struct.ChatType.Center), 0);
Player.Value.Disconnect();
kicked = true;
break;
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
Monitor.Exit(Nano.ClientPool);
}
//}
if (!kicked)
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Cannot ban player.", Struct.ChatType.Talk));
}
}
break;
}
case "save":
{
Database.Database.SaveCharacter(CSocket.Client);
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[GameServer] Saved " + CSocket.Client.Name, Struct.ChatType.Top));
break;
}
case "reload":
{
if (Command.Length == 2 && CSocket.Client.isGM || CSocket.Client.isPM)
{
switch (Command[1].ToLower())
{
case "portals":
{
Nano.Portals.Clear();
Struct.LoadPortals();
break;
}
case "monsters":
{
Nano.BaseMonsters.Clear();
Nano.MonsterSpawns.Clear();
Nano.Monsters.Clear();
Struct.LoadMonsters();
break;
}
case "npcs":
{
Nano.Npcs.Clear();
Struct.LoadNpcs();
break;
}
case "tnpcs":
{
Nano.TerrainNpcs.Clear();
Struct.LoadTNpcs();
break;
}
}
}
break;
}
case "quiztest":
CSocket.Send(ConquerPacket.QuizShowStart());
CSocket.Send(ConquerPacket.QuizQuestion(253, 125, 6000, 1, 5, "Is Dany the best?", "Nope", "Yeah", "I dont know", "Sure"));
CSocket.Send(ConquerPacket.QuizShowInfo(32, 10, 500));
CSocket.Send(ConquerPacket.QuizQuestion(254, 126, 6001, 2, 6, "Is Dany the bestsss?", "Nope", "Yeah", "I dont know", "Sure"));
CSocket.Send(ConquerPacket.QuizShowInfo(32, 10, 500));
break;
case "xptest":
{
CSocket.Client.XPSkillList = true;
CSocket.Send(ConquerPacket.Status(CSocket, 501, 50, Struct.StatusTypes.StatusEffect));
break;
}
case "scroll":
{
if (Command.Length == 2)
{
switch (Command[1].ToLower())
{
case "tc":
{
Handler.Teleport(1002, 438, 377, 0, CSocket);
break;
}
case "pc":
{
Handler.Teleport(1011, 232, 260, 0, CSocket);
break;
}
case "ac":
{
Handler.Teleport(1020, 565, 565, 0, CSocket);
break;
}
case "am":
{
Handler.Teleport(1020, 565, 565, 0, CSocket);
break;
}
case "bi":
{
Handler.Teleport(1015, 723, 573, 0, CSocket);
break;
}
case "dc":
{
Handler.Teleport(1000, 496, 649, 0, CSocket);
break;
}
case "ma":
{
Handler.Teleport(1036, 211, 196, 0, CSocket);
break;
}
case "pka":
{
Handler.Teleport(1005, 50, 71, 0, CSocket);
break;
}
case "ja":
{
Handler.Teleport(6000, 28, 71, 0, CSocket);
break;
}
case "gw":
{
Handler.Teleport(1038, 353, 343, 0, CSocket);
break;
}
default:
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Unknown scroll location. Example: /scroll tc,pc,ac,am,bi,dc,ma,pka,ja,gw", Struct.ChatType.Talk));
break;
}
}
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " /scroll tc,pc,ac,am,bi,dc,ma,pka,ja,gw", Struct.ChatType.Talk));
}
break;
}
case "i":
{
if (CSocket.Client.isGM || CSocket.Client.isPM)
{
if (!CSocket.Client.Invincibility)
{
CSocket.Client.Invincibility = true;
ConquerPacket.ToLocal(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", CSocket.Client.Name + " has just become even more godly!", Struct.ChatType.Center), CSocket.Client.X, CSocket.Client.Y, (int)CSocket.Client.Map, 0, 0);
}
else
{
CSocket.Client.Invincibility = false;
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "You are no longer flagged as invincible.", Struct.ChatType.Top));
}
ConquerPacket.ToLocal(ConquerPacket.General(CSocket.Client.ID, CSocket.Client.X, CSocket.Client.Y, 0, 0, 0, Struct.DataType.EntityRemove), CSocket.Client.X, CSocket.Client.Y, (int)CSocket.Client.Map, 0, CSocket.Client.ID);
ConquerPacket.ToLocal(ConquerPacket.SpawnCharacter(CSocket), CSocket.Client.X, CSocket.Client.Y, (int)CSocket.Client.Map, 0, 0);
}
break;
}
case "money":
{
if (Command.Length == 2 && CSocket.Client.isPM || CSocket.Client.isGM)
{
int Money = Convert.ToInt32(Command[1]);
CSocket.Client.Money += Money;
CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Money, Struct.StatusTypes.InvMoney));
}
break;
}
case "cps":
{
if (Command.Length == 2 && CSocket.Client.isPM || CSocket.Client.isGM)
{
int Cps = Convert.ToInt32(Command[1]);
CSocket.Client.CPs += Cps;
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "You now have " + CSocket.Client.CPs + " CPs.", Struct.ChatType.Top));
CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.CPs, Struct.StatusTypes.InvCPoints));
}
break;
}
case "hair":
{
if (Command.Length == 2)
{
int Hair = Convert.ToInt32(Command[1]);
CSocket.Client.Hair = Hair;
CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Hair, Struct.StatusTypes.HairStyle));
}
break;
}
case "etest":
{
if (Command.Length == 2)
{
CSocket.Client.Test = Convert.ToInt32(Command[1]);
}
break;
}
case "dropitem":
{
if (CSocket.Client.isPM || CSocket.Client.isGM)
{
if (Calculation.PercentSuccess(30))
{
int Level = 137;
int Times = 1;
if (Calculation.PercentSuccess(15))
{
Times = Nano.Rand.Next(1, 6);
}
for (int i = 0; i < Times; i++)
{
int Money = Nano.Rand.Next(1, 10);
if (Calculation.PercentSuccess(90))
Money = Nano.Rand.Next(2, 240);
if (Calculation.PercentSuccess(70))
Money = Nano.Rand.Next(60, 3000);
if (Calculation.PercentSuccess(50))
Money = Nano.Rand.Next(200, 4000);
if (Calculation.PercentSuccess(30))
Money = Nano.Rand.Next(1000, 30000);
if (Calculation.PercentSuccess(100))
Money = Nano.Rand.Next(2000, 50000);
Money = Money / ((138 - Level) * 10);
if (Money < 1)
Money = 1;
Struct.ItemGround IG = new Struct.ItemGround();
IG.Money = Money;
if (Money < 10)
IG.ItemID = 1090000;
else if (Money < 100)
IG.ItemID = 1090010;
else if (Money < 1000)
IG.ItemID = 1090020;
else if (Money < 3000)
IG.ItemID = 1091000;
else if (Money < 10000)
IG.ItemID = 1091010;
else
IG.ItemID = 1091020;
IG.UID = Nano.DropItemUID;
IG.X = CSocket.Client.X;
IG.Y = CSocket.Client.Y;
if (!IG.SelectCoordonates(CSocket.Client.X, CSocket.Client.Y))
return;
IG.OwnerOnly = new System.Timers.Timer();
IG.Map = (int)CSocket.Client.Map;
IG.Dispose = new System.Timers.Timer();
IG.Dispose.Interval = 60000;
IG.Dispose.AutoReset = false;
IG.Dispose.Elapsed += delegate { IG.Disappear(); };
IG.Dispose.Start();
Nano.ItemFloor.Add(IG.UID, IG);
ConquerPacket.ToLocal(ConquerPacket.DropItem(IG.UID, IG.ItemID, IG.X, IG.Y, 4), IG.X, IG.Y, IG.Map, 0, 0);
}
}
else
{
if (Calculation.PercentSuccess(5))
{
Struct.ItemGround IG = new Struct.ItemGround();
IG.ItemID = 1088001;
IG.X = CSocket.Client.X;
IG.Y = CSocket.Client.Y;
if (!IG.SelectCoordonates(CSocket.Client.X, CSocket.Client.Y))
return;
IG.Map = (int)CSocket.Client.Map;
IG.OwnerOnly = new System.Timers.Timer();
IG.UID = Nano.DropItemUID;
IG.Dispose.Interval = 10000;
IG.Dispose.AutoReset = false;
IG.Dispose.Elapsed += delegate { IG.Disappear(); };
IG.Dispose.Start();
Nano.ItemFloor.Add(IG.UID, IG);
ConquerPacket.ToLocal(ConquerPacket.DropItem(IG.UID, IG.ItemID, IG.X, IG.Y, IG.Color), IG.X, IG.Y, IG.Map, 0, 0);
}
else if (Calculation.PercentSuccess(3))
{
Struct.ItemGround IG = new Struct.ItemGround();
IG.ItemID = 1088000;
IG.X = CSocket.Client.X;
IG.Y = CSocket.Client.Y;
if (!IG.SelectCoordonates(CSocket.Client.X, CSocket.Client.Y))
return;
IG.Map = (int)CSocket.Client.Map;
IG.OwnerOnly = new System.Timers.Timer();
IG.UID = Nano.DropItemUID;
IG.Dispose.Interval = 10000;
IG.Dispose.AutoReset = false;
IG.Dispose.Elapsed += delegate { IG.Disappear(); };
IG.Dispose.Start();
Nano.ItemFloor.Add(IG.UID, IG);
ConquerPacket.ToLocal(ConquerPacket.DropItem(IG.UID, IG.ItemID, IG.X, IG.Y, IG.Color), IG.X, IG.Y, IG.Map, 0, 0);
}
}
}
break;
}
case "call":
{
if (CSocket.Client.isPM || CSocket.Client.isGM)
{
if (Command.Length == 2)
{
ClientSocket Target = null;
try
{
Monitor.Enter(Nano.ClientPool);
foreach (KeyValuePair<int, ClientSocket> Clients in Nano.ClientPool)
{
if (Clients.Value.Client.Name == Command[1])
{
Target = Clients.Value;
break;
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
Monitor.Exit(Nano.ClientPool);
}
if (Target != null)
{
Handler.Teleport((int)CSocket.Client.Map, CSocket.Client.X, CSocket.Client.Y, 0, Target);
Target.Send(ConquerPacket.Chat(0, "SYSTEM", Target.Client.Name, "You have been summoned by " + CSocket.Client.Name, Struct.ChatType.Top));
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Player not found!", Struct.ChatType.Top));
}
}
}
break;
}
case "goto":
{
if (CSocket.Client.isPM || CSocket.Client.isGM)
{
if (Command.Length == 2)
{
ClientSocket Target = null;
try
{
Monitor.Enter(Nano.ClientPool);
foreach (KeyValuePair<int, ClientSocket> Clients in Nano.ClientPool)
{
if (Clients.Value.Client.Name == Command[1])
{
Target = Clients.Value;
break;
}
}
//}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
Monitor.Exit(Nano.ClientPool);
}
if (Target != null)
{
Handler.Teleport((int)Target.Client.Map, Target.Client.X, Target.Client.Y, 0, CSocket);
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "Teleported to " + Target.Client.Name, Struct.ChatType.Top));
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Player not found!", Struct.ChatType.Top));
}
}
}
break;
}
case "bc":
{
if (CSocket.Client.isPM || CSocket.Client.isGM)
{
ConquerPacket.ToServer(ConquerPacket.Chat(0, CSocket.Client.Name, "ALLUSERS", Message.Substring(2 + Command[0].Length), Struct.ChatType.NewBroadcast), 0);
}
break;
}
case "gm":
{
if (CSocket.Client.isPM || CSocket.Client.isGM)
{
ConquerPacket.ToServer(ConquerPacket.Chat(0, CSocket.Client.Name, "ALLUSERS", Message.Substring(2 + Command[0].Length), Struct.ChatType.Center), 0);
}
break;
}
case "item":
{
if (CSocket.Client.isPM || CSocket.Client.isGM)
{
if (CSocket.Client.Inventory.Count >= 40)
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Your inventory is full.", Struct.ChatType.Top));
break;
}
Struct.ItemData Item = null;
int NewItemID = 0;
foreach (KeyValuePair<int, Struct.ItemData> Items in Nano.Items)
{
if (Items.Value.Name.ToLower() == Command[1].ToLower())
{
Item = Items.Value;
int l = int.Parse(Item.ID.ToString().Remove(0, Item.ID.ToString().Length - 1));
string Version = Command[2].ToLower();
int version = 9;
switch (Version)
{
case "free": version = 20; break;
case "super": version = 9; break;
case "elite": version = 8; break;
case "unique": version = 7; break;
case "refined": version = 6; break;
case "normal": version = 2; break;
case "normalv1": version = 3; break;
case "normalv2": version = 4; break;
case "normalv3": version = 5; break;
}
if (l == version)
{ NewItemID = Item.ID; break; }
else
continue;
}
}
if (Item != null)
{
string ItemID = Item.ID.ToString();
Struct.ItemInfo NewItem = new Struct.ItemInfo();
NewItem.Bless = 0;
NewItem.Dura = Item.MaxDura;
NewItem.Enchant = 0;
if (!Nano.Items.ContainsKey(Convert.ToInt32(ItemID))) { throw new Exception("Invalid quality. Could not create the it."); }
NewItem.ItemID = NewItemID = Convert.ToInt32(ItemID);
NewItem.MaxDura = Item.MaxDura;
NewItem.Plus = 0;
NewItem.Position = 0;
NewItem.Soc1 = 0;
NewItem.Soc2 = 0;
NewItem.Color = new Random().Next(2, 9);
NewItem.UID = Database.Database.ItemUID;
if (Command.Length > 3)
{
NewItem.Plus = Math.Min(12, int.Parse(Command[3]));
if (Command.Length > 4)
{
NewItem.Bless = Math.Min(7, int.Parse(Command[4]));
if (Command.Length > 5)
{
NewItem.Enchant = Math.Min(255, int.Parse(Command[5]));
if (Command.Length > 6)
{
NewItem.Soc1 = Math.Min(255, int.Parse(Command[6]));
if (Command.Length > 7)
{
NewItem.Soc2 = Math.Min(255, int.Parse(Command[7]));
}
}
}
}
}
bool created = Database.Database.NewItem(NewItem, CSocket);
CSocket.Client.Inventory.Add(NewItem.UID, NewItem);
CSocket.Send(ConquerPacket.ItemInfo(NewItem.UID, NewItem.ItemID, NewItem.Plus, NewItem.Bless, NewItem.Enchant, NewItem.Soc1, NewItem.Soc2, NewItem.Dura, NewItem.MaxDura, NewItem.Suspicious, NewItem.Free, NewItem.Locked, NewItem.Progress, NewItem.SocketProgress, NewItem.Position, NewItem.Color));
break;
}
else
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Invalid item name. Could not create it.", Struct.ChatType.Top));
}
break;
}
case "effect":
{
if (CSocket.Client.isPM || CSocket.Client.isGM)
{
if (Command.Length == 2)
{
ConquerPacket.ToLocal(ConquerPacket.Effect(CSocket.Client.ID, Command[1]), CSocket.Client.X, CSocket.Client.Y, (int)CSocket.Client.Map, 0, 0);
}
}
break;
}
case "job":
{
if (Command.Length == 2)
{
try
{
CSocket.Client.Class = (Struct.ClassType)Convert.ToInt32(Command[1]);
CSocket.Send(ConquerPacket.Status(CSocket, 2, (int)CSocket.Client.Class, Struct.StatusTypes.Job));
Database.Database.UpdateStats(CSocket);
Calculation.Vitals(CSocket, false);
}
catch
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Invalid job.", Struct.ChatType.Top));
}
}
break;
}
case "level":
{
if (CSocket.Client.isPM || CSocket.Client.isGM)
if (Command.Length == 2)
{
int NewLevel = Convert.ToInt32(Command[1]);
if (NewLevel <= 137)
{
CSocket.Client.Level = NewLevel;
CSocket.Client.Exp = 0;
CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Level, Struct.StatusTypes.Level));
CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Exp, Struct.StatusTypes.Exp));
ConquerPacket.ToLocal(ConquerPacket.Effect(CSocket.Client.ID, "LevelUp"), CSocket.Client.X, CSocket.Client.Y, (int)CSocket.Client.Map, 0, 0);
Database.Database.UpdateStats(CSocket);
ConquerPacket.ToLocal(ConquerPacket.General(CSocket.Client.ID, 0, 0, 0, 0, 0, Struct.DataType.Leveled), CSocket.Client.X, CSocket.Client.Y, (int)CSocket.Client.Map, 0, 0);
Calculation.Vitals(CSocket, false);
}
}
break;
}
case "dex":
{
if (Command.Length == 2)
{
int Dex = Convert.ToInt32(Command[1]);
CSocket.Client.Dexterity = Dex;
CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Dexterity, Struct.StatusTypes.DexterityStatPoints));
Calculation.Vitals(CSocket, false);
}
break;
}
case "spi":
{
if (Command.Length == 2)
{
int Spi = Convert.ToInt32(Command[1]);
CSocket.Client.Spirit = Spi;
CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Spirit, Struct.StatusTypes.ManaStatPoints));
Calculation.Vitals(CSocket, false);
}
break;
}
case "vit":
{
if (Command.Length == 2)
{
int Vit = Convert.ToInt32(Command[1]);
CSocket.Client.Vitality = Vit;
CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Vitality, Struct.StatusTypes.VitalityStatPoints));
Calculation.Vitals(CSocket, false);
}
break;
}
case "str":
{
if (Command.Length == 2)
{
int Str = Convert.ToInt32(Command[1]);
CSocket.Client.Strength = Str;
CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Strength, Struct.StatusTypes.StrengthStatPoints));
Calculation.Vitals(CSocket, false);
}
break;
}
case "reborn":
{
if (CSocket.Client.isPM || CSocket.Client.isGM)
{
CSocket.Client.Reborn = 1;
ConquerPacket.ToServer(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "CONGRATULATIONS! " + CSocket.Client.Name + " has just been reborn! Good job!", Struct.ChatType.Center), 0);
for (int i = 1; i < 9; i++)
{
if (i != 7)
{
if (CSocket.Client.Equipment.ContainsKey(i))
{
CSocket.Client.Equipment[i].ItemID =
Calculation.DownLevel(CSocket.Client.Equipment[i].ItemID);
Database.Database.UpdateItem(CSocket.Client.Equipment[i]);
CSocket.Send(ConquerPacket.ItemInfo(
CSocket.Client.Equipment[i].UID,
CSocket.Client.Equipment[i].ItemID,
CSocket.Client.Equipment[i].Plus,
CSocket.Client.Equipment[i].Bless,
CSocket.Client.Equipment[i].Enchant,
CSocket.Client.Equipment[i].Soc1,
CSocket.Client.Equipment[i].Soc2,
CSocket.Client.Equipment[i].Dura,
CSocket.Client.Equipment[i].MaxDura,
CSocket.Client.Equipment[i].Suspicious,
CSocket.Client.Equipment[i].Free,
CSocket.Client.Equipment[i].Locked,
CSocket.Client.Equipment[i].Progress,
CSocket.Client.Equipment[i].SocketProgress,
i,
CSocket.Client.Equipment[i].Color));
}
}
}
}
break;
}
case "2ndreborn":
{
if (CSocket.Client.isPM || CSocket.Client.isGM)
{
CSocket.Client.Reborn = 2;
ConquerPacket.ToServer(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "CONGRATULATIONS! " + CSocket.Client.Name + " has just been second reborn! Good job!", Struct.ChatType.Center), 0);
}
break;
}
case "prof":
{
if (CSocket.Client.isPM || CSocket.Client.isGM)
{
if (Command.Length == 3)
{
int ID = Convert.ToInt32(Command[1]);
int Level = Convert.ToInt32(Command[2]);
if (Level > 20)
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " Max level is 20.", Struct.ChatType.Talk));
break;
}
if (CSocket.Client.Profs.ContainsKey(ID))
{
Struct.CharProf Prof = CSocket.Client.Profs[ID];
Prof.Level = Level;
Prof.Exp = 0;
Database.Database.UpdateProf(Prof.ID, Prof.Level, Prof.Exp, CSocket.Client.ID);
}
else
{
Struct.CharProf Prof = new Struct.CharProf();
Prof.Level = Level;
Prof.ID = ID;
CSocket.Client.Profs.Add(Prof.ID, Prof);
Database.Database.NewProf(ID, Level, 0, CSocket.Client.ID);
}
CSocket.Send(ConquerPacket.Prof(ID, Level, 0));
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " /prof ID Level.", Struct.ChatType.Talk));
}
}
break;
}
case "skill":
{
if (CSocket.Client.isPM || CSocket.Client.isGM)
{
if (Command.Length == 3)
{
int ID = Convert.ToInt32(Command[1]);
int Level = Convert.ToInt32(Command[2]);
if (CSocket.Client.Skills.ContainsKey(ID))
{
Struct.CharSkill Skill = CSocket.Client.Skills[ID];
Skill.Level = Level;
Skill.Exp = 0;
Database.Database.SetSkill(Skill.ID, Skill.Level, Skill.Exp, CSocket.Client.ID, true);
}
else
{
Struct.CharSkill Skill = new Struct.CharSkill();
Skill.Level = Level;
Skill.ID = ID;
CSocket.Client.Skills.Add(Skill.ID, Skill);
Database.Database.SetSkill(ID, Level, 0, CSocket.Client.ID, false);
}
CSocket.Send(ConquerPacket.Skill(ID, Level, 0));
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, " /skill ID Level.", Struct.ChatType.Talk));
}
}
break;
}
case "status":
{
if (CSocket.Client.isPM || CSocket.Client.isGM)
{
CSocket.Send(ConquerPacket.Chat(0, "", "", "", Struct.ChatType.ClearTopRight));
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "Players online: " + Nano.ClientPool.Count, Struct.ChatType.TopRight));
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "Monsters spawned: " + Nano.Monsters.Count, Struct.ChatType.TopRight));
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "Exp/Prof/Skill Rates: " + Nano.EXP_MULTIPLER + "/" + Nano.PROF_MULTIPLER + "/" + Nano.SKILL_MULTIPLER, Struct.ChatType.TopRight));
}
break;
}
case "teleport":
{
if (Command.Length == 4)
{
Handler.Teleport(Convert.ToInt32(Command[1]), Convert.ToInt32(Command[2]), Convert.ToInt32(Command[3]), 0, CSocket);
}
break;
}
}
#endregion
}
else
{
#region Chats
{
switch (Type)
{
case Struct.ChatType.Talk:
{
ConquerPacket.ToLocal(ConquerPacket.Chat(0, CSocket.Client.Name, To, Message, Type), CSocket.Client.X, CSocket.Client.Y, (int)CSocket.Client.Map, 0, CSocket.Client.ID);
break;
}
case Struct.ChatType.Team:
{
if (CSocket.Client.Team != null)
{
if (Nano.ClientPool.ContainsKey(CSocket.Client.Team.LeaderID))
{
ClientSocket Leader = Nano.ClientPool[CSocket.Client.Team.LeaderID];
foreach (KeyValuePair<int, ClientSocket> Member in Leader.Client.Team.Members)
{
if (Member.Value.Client.ID != CSocket.Client.ID)
Member.Value.Send(ConquerPacket.Chat(0, CSocket.Client.Name, To, Message, Type));
}
}
}
break;
}
case Struct.ChatType.Ghost:
{
ConquerPacket.ToLocal(ConquerPacket.Chat(0, CSocket.Client.Name, To, Message, Type), CSocket.Client.X, CSocket.Client.Y, (int)CSocket.Client.Map, 0, CSocket.Client.ID);
break;
}
case Struct.ChatType.Whisper:
{
bool online = false;
//lock(Nano.ClientPool)
//{
try
{
Monitor.Enter(Nano.ClientPool);
foreach (KeyValuePair<int, ClientSocket> Player in Nano.ClientPool)
{
if (Player.Value.Client.Name == To)
{
Player.Value.Send(ConquerPacket.Chat(0, CSocket.Client.Name, To, Message, Type));
online = true;
break;
}
}
//}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
Monitor.Exit(Nano.ClientPool);
}
//}
if (!online)
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "[ERROR] Player not found.", Struct.ChatType.Talk));
break;
}
case Struct.ChatType.Friend:
{
ConquerPacket.ToServer(ConquerPacket.Chat(0, From, To, Message, Struct.ChatType.Friend), CSocket.Client.ID);
break;
}
default:
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] Chat type not coded.", Struct.ChatType.Talk));
break;
}
}
}
#endregion
}
}
catch (Exception Except)
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] Please report: Exception thrown during command parsing/message handling.", Struct.ChatType.Top));
Console.WriteLine(Except.ToString());
}
}






