private void BuyLot(GamePlayer player, byte response) { if (response != 0x01) { return; } lock (DatabaseItem) // Mannen 10:56 PM 10/30/2006 - Fixing every lock(this) { if (!string.IsNullOrEmpty(DatabaseItem.OwnerID)) { return; } if (HouseMgr.GetHouseNumberByPlayer(player) != 0 && player.Client.Account.PrivLevel != (int)ePrivLevel.Admin) { ChatUtil.SendMerchantMessage(player, "You already own another lot or house (Number " + HouseMgr.GetHouseNumberByPlayer(player) + ")."); return; } long totalCost = HouseTemplateMgr.GetLotPrice(DatabaseItem); if (player.RemoveMoney(totalCost, "You just bought this lot for {0}.", eChatType.CT_Merchant, eChatLoc.CL_SystemWindow)) { InventoryLogging.LogInventoryAction(player, this, eInventoryActionType.Merchant, totalCost); DatabaseItem.LastPaid = DateTime.Now; DatabaseItem.OwnerID = player.ObjectId; CreateHouse(player, 0); } else { ChatUtil.SendMerchantMessage(player, "You dont have enough money!"); } } }
public virtual bool OnPlayerSell(GamePlayer player, InventoryItem item) { if (!item.IsDropable) { ChatUtil.SendMerchantMessage(player, "This item can't be sold."); return(false); } return(true); }
public void HandlePacket(GameClient client, GSPacketIn packet) { // player is null, return // active consignment merchant is null, return if (!(client.Player?.ActiveInventoryObject is GameConsignmentMerchant conMerchant)) { return; } // current house is null, return House house = HouseMgr.GetHouse(conMerchant.HouseNumber); if (house == null) { return; } // make sure player has permissions to withdraw from the consignment merchant if (!house.CanUseConsignmentMerchant(client.Player, ConsignmentPermissions.Withdraw)) { client.Player.Out.SendMessage("You don't have permission to withdraw money from this merchant!", eChatType.CT_Important, eChatLoc.CL_ChatWindow); return; } lock (conMerchant.LockObject()) { long totalConMoney = conMerchant.TotalMoney; if (totalConMoney > 0) { if (ServerProperties.Properties.CONSIGNMENT_USE_BP) { client.Player.Out.SendMessage($"You withdraw {totalConMoney} BountyPoints from your Merchant.", eChatType.CT_Important, eChatLoc.CL_ChatWindow); client.Player.BountyPoints += totalConMoney; client.Player.Out.SendUpdatePoints(); } else { ChatUtil.SendMerchantMessage(client, "GameMerchant.OnPlayerWithdraw", Money.GetString(totalConMoney)); client.Player.AddMoney(totalConMoney); InventoryLogging.LogInventoryAction(conMerchant, client.Player, eInventoryActionType.Merchant, totalConMoney); } conMerchant.TotalMoney -= totalConMoney; if (ServerProperties.Properties.MARKET_ENABLE_LOG) { Log.Debug($"CM: [{client.Player.Name}:{client.Account.Name}] withdraws {totalConMoney} from CM on lot {conMerchant.HouseNumber}."); } client.Out.SendConsignmentMerchantMoney(conMerchant.TotalMoney); } } }