• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[REL] Fix the shoppingmall in CoEmu v2

Junior Spellweaver
Joined
Jan 14, 2007
Messages
140
Reaction score
5
Go to Handlers, ItemBuy.cs
Copy And replace The Code...

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);
int Amount = PacketProcessor.ReadLong(Data, 20);
{
if (CSocket.Client.Inventory.Count == 40)
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] 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];
if (NewItem.CPCost > 0)
{
if (CSocket.Client.CPs >= NewItem.CPCost * Data[20])
{
for (byte x = 0; x < Data[20]; x++)
{
Struct.ItemInfo Item = new Struct.ItemInfo();
Item.Color = new Random().Next(3, 9);
Handler.CPs(NewItem.CPCost * -1, CSocket);
Item.ItemID = NewItem.ID;
Item.UID = Nano.Rand.Next(1, 9999999);

if (Item.ItemID == 730001)
Item.Plus = 1;
if (Item.ItemID == 730002)
Item.Plus = 2;
if (Item.ItemID == 730003)
Item.Plus = 3;
if (Item.ItemID == 730004)
Item.Plus = 4;
if (Item.ItemID == 730005)
Item.Plus = 5;
if (Item.ItemID == 730006)
Item.Plus = 6;
if (Item.ItemID == 730007)
Item.Plus = 7;

bool created = Database.Database.NewItem(Item, CSocket);
while (!created)
{
Item.UID = Nano.Rand.Next(1, 9999999);
created = Database.Database.NewItem(Item, CSocket);
}
CSocket.Client.Inventory.Add(Item.UID, Item);
CSocket.Send(ConquerPacket.ItemInfo(Item.UID, Item.ItemID, Item.Plus, 0, 0, 0, 0, Item.MaxDura, Item.MaxDura, 0, Item.Color));
}
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] You do not have enough CPs.", Struct.ChatType.Top));
}
}

else if (NewItem.Cost > 0)
{
if (CSocket.Client.Money >= NewItem.Cost)
{
Struct.ItemInfo Item = new Struct.ItemInfo();
Handler.Money(NewItem.Cost * -1, CSocket);
Item.ItemID = NewItem.ID;
Item.UID = Nano.Rand.Next(1, 9999999);
bool created = Database.Database.NewItem(Item, CSocket);
while (!created)
{
Item.UID = Nano.Rand.Next(1, 9999999);
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));
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] You do not have enough money.", Struct.ChatType.Top));
}
}
else
{
Struct.ItemInfo Item = new Struct.ItemInfo();
Item.ItemID = NewItem.ID;
Item.UID = Nano.Rand.Next(1, 9999999);
bool created = Database.Database.NewItem(Item, CSocket);
while (!created)
{
Item.UID = Nano.Rand.Next(1, 9999999);
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));
}
}
else
{
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] Item does not exist in Shop.dat", Struct.ChatType.Top));
}
}
}
}
}
}


Keep rz co section alive!
 
Back
Top