There is personalShop.cs but nothing in it related to sockets or something:Quote:
in myshop.cs or charactershop.cs or vendor.cs or something. not sure.
but is under features folder I think.
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoSX.Game;
namespace CoSX.Features
{
public class PersonalShops
{
public struct ItemValue
{
public byte MoneyType;
public uint Value;
}
public class Shop
{
public Character Owner;
public string Hawk = "";
public Hashtable Items;
public NPC NPCInfo;
public uint UID;
public Shop(Character C, uint Time)
{
Owner = C;
Items = new Hashtable();
NPCInfo = new NPC();
NPCInfo.EntityID = (uint)Program.Rnd.Next(102000, 106000);
while (World.H_NPCs.Contains(NPCInfo.EntityID) || World.H_PShops.Contains(NPCInfo.EntityID) || World.H_Chars.Contains(NPCInfo.EntityID))
NPCInfo.EntityID = (uint)Program.Rnd.Next(102000, 106000);
NPCInfo.Type = 400;
NPCInfo.Flags = 14;
NPCInfo.Loc = C.Loc;
NPCInfo.Loc.X++;
NPCInfo.Direction = 6;
NPCInfo.Avatar = 0;
UID = NPCInfo.EntityID;
ArrayList ePackets = new ArrayList();
C.MyClient.AddSend(Packets.SpawnNamedNPC2(NPCInfo, Name));
C.MyClient.AddSend(Packets.GeneralData(C.EntityID, UID, NPCInfo.Loc.X, NPCInfo.Loc.Y, 111, 6));
C.MyClient.EndSend();
World.H_PShops.Add(UID, this);
World.Spawn(this);
}
public void Close()
{
World.H_PShops.Remove(UID);
World.Action(Owner, Packets.GeneralData(UID, 0, 0, 0, 135).Get);
Owner.MyShop = null;
}
public bool AddItem(uint UID, uint Value, byte MoneyType)
{
Item I = Owner.FindInvItem(UID);
if (!I.FreeItem && I.UID == UID && !Items.Contains(UID))
{
Items.Add(UID, new ItemValue() { Value = Value, MoneyType = MoneyType });
return true;
}
return false;
}
public void Buy(uint UID, Character C)
{
if (Owner != C && Items.Contains(UID) && C.Inventory.Count < 40)
{
Item I = Owner.FindInvItem(UID);
if (I.ID != 0)
{
ItemValue Val = (ItemValue)Items[UID];
uint Costs = Val.Value;
if (Val.MoneyType == 1 && C.Silvers >= Costs)
{
C.Silvers -= Costs;
Owner.Silvers += Costs;
Owner.MyClient.LocalMessage(2005, C.Name + " has bought " + I.DBInfo.Name + " for " + Costs + " from you.");
C.AddItem(I);
RemoveItem(UID, Packets.ItemPacket(UID, this.UID, 23).Get);
Owner.RemoveItem(I);
}
else if (Val.MoneyType == 3 && C.CPs >= Costs)
{
C.CPs -= Costs;
Owner.CPs += Costs;
Owner.MyClient.LocalMessage(2005, C.Name + " has bought " + I.DBInfo.Name + " for " + Costs + " from you.");
C.AddItem(I);
RemoveItem(UID, Packets.ItemPacket(UID, this.UID, 23).Get);
Owner.RemoveItem(I);
}
}
}
}
public void RemoveItem(uint UID, byte[] Data)
{
if (Items.Contains(UID))
Items.Remove(UID);
foreach (Character C in World.H_Chars.Values)
if (C.Loc.Map == Owner.Loc.Map && MyMath.InBox(C.Loc.X, C.Loc.Y, Owner.Loc.X, Owner.Loc.Y, 18))
C.MyClient.AddSend(Data);
}
public void SendItems(Main.GameClient C)
{
foreach (DictionaryEntry DE in Items)
{
Item I = Owner.FindInvItem((uint)DE.Key);
if (I.ID != 0)
C.AddSend(Packets.AddStallItem(I, (ItemValue)DE.Value, UID));
}
}
public string Name
{
get
{
return Owner.Name;
}
}
}
}
}