private static void RequestClose(Player player, ref MsgTrade packet) { if (packet.UniqueId == 0) { return; } if (player.Trade == null) { return; } if (player.Trade.Owner.UniqueId == player.UniqueId) { (player.Trade.Partner as Player)?.Send(Create(player.UniqueId, TradeMode.CloseTradeWindowFail)); player.Send(Create(player.Trade.Partner.UniqueId, TradeMode.CloseTradeWindowFail)); player.Trade.Partner.Trade = null; player.Trade = null; } else { (player.Trade.Owner as Player)?.Send(Create(player.UniqueId, TradeMode.CloseTradeWindowFail)); player.Send(Create(player.Trade.Owner.UniqueId, TradeMode.CloseTradeWindowFail)); player.Trade.Owner.Trade = null; player.Trade = null; } }
private static void RequestTrade(Player player, ref MsgTrade packet) { if (packet.UniqueId == 0) { return; } if (!GameWorld.Maps[player.MapId].Entities.TryGetValue(packet.UniqueId, out var found)) { return; } if (found == null) { return; } if (!Position.CanSeeBig(player, found)) { return; } var target = found; player.Trade = target.Trade ?? new Trade(player, target); if (target.Trade != null) { player.Send(Create(target.UniqueId, TradeMode.ShowTradeWindow)); (target as Player)?.Send(Create(player.UniqueId, TradeMode.ShowTradeWindow)); } else { (target as Player)?.Send(Create(player.UniqueId, TradeMode.RequestNewTrade)); } }
private static void CreateTeam(Player player, ref MsgTeam packet) { if (GameWorld.Maps.TryGetValue(player.MapId, out var map)) { if (map.Flags.HasFlag(MapFlags.DisableTeams)) { player.GetMessage("SYSTEM", player.Name, "Team's are not allowed on this map.", MsgTextType.Action); return; } } TeamSystem.Teams.AddOrUpdate(player.UniqueId, new TeamSystem.TeamData(player)); player.Send(packet); }
private static void RequestFinish(Player player, ref MsgTrade packet) { if (packet.UniqueId == 0) { return; } if (player.Trade == null) { return; } if (player.Trade.Owner.UniqueId == player.UniqueId) { player.Trade.OwnerOk = true; (player.Trade.Partner as Player)?.Send(Create(player.UniqueId, TradeMode.RequestCompleteTrade)); if (player.Trade.Partner is Npc) { player.Trade.PartnerOk = true; } if (player.Trade.PartnerOk) { foreach (var item in player.Trade.PartnerItems) { player.Inventory.AddItem(item.Value); player.Trade.Partner.Inventory.RemoveItem(item.Value); } foreach (var item in player.Trade.OwnerItems) { if (player.Trade.Partner is Npc) { SelfContainedSystems.BoothSystem.Add(player.Trade.Partner, item.Value, item.Value.PriceBaseline); } else { player.Inventory.RemoveItem(item.Value); player.Trade.Partner.Inventory.AddItem(item.Value); } } player.Money += player.Trade.PartnerMoney; player.Trade.Partner.Money -= player.Trade.PartnerMoney; //player.Cps += player.Trade.PartnerCps; //player.Trade.Partner.Cps -= player.Trade.PartnerCps; player.Send(Create(player.Trade.Partner.UniqueId, TradeMode.CloseTradeWindowSuccess)); (player.Trade.Partner as Player)?.Send(Create(player.UniqueId, TradeMode.CloseTradeWindowSuccess)); player.Trade.Partner.Trade = null; player.Trade = null; } } else { player.Trade.PartnerOk = true; (player.Trade.Owner as Player)?.Send(Create(player.UniqueId, TradeMode.RequestCompleteTrade)); if (player.Trade.OwnerOk) { foreach (var item in player.Trade.OwnerItems) { player.Inventory.AddItem(item.Value); player.Trade.Owner.Inventory.RemoveItem(item.Value); } player.Money += player.Trade.OwnerMoney; player.Trade.Owner.Money -= player.Trade.OwnerMoney; //player.Cps += player.Trade.OwnerCps; //player.Trade.Owner.Cps -= player.Trade.OwnerCps; player.Send(Create(player.Trade.Partner.UniqueId, TradeMode.CloseTradeWindowSuccess)); (player.Trade.Owner as Player)?.Send(Create(player.UniqueId, TradeMode.CloseTradeWindowSuccess)); player.Trade.Owner.Trade = null; player.Trade = null; } } }