private static void PurchasePlayerGrid(MarketListing Offer, ulong Buyer, MyIdentity BuyerIdentity, ulong Owner) { //Log.Error("A"); if (!MySession.Static.Players.TryGetIdentityFromSteamID(Owner, out MyIdentity OwnerIdentity)) { return; } //Have a successfull buy RemoveMarketListing(Owner, Offer.Name); //Transfer grid if (PlayerHangar.TransferGrid(Owner, Buyer, Offer.Name)) { Chat.Send($"Successfully purchased {Offer.Name} from {OwnerIdentity.DisplayName}! Check your hangar!", Buyer); MyBankingSystem.ChangeBalance(BuyerIdentity.IdentityId, -1 * Offer.Price); MyBankingSystem.ChangeBalance(OwnerIdentity.IdentityId, Offer.Price); } }
private static void PurchaseServerGrid(MarketListing Offer, ulong Buyer, MyIdentity BuyerIdentity) { if (!File.Exists(Offer.FileSBCPath)) { Log.Error($"{Offer.FileSBCPath} doesnt exsist! Was this removed prematurely?"); return; } var ToInfo = new PlayerInfo(); ToInfo.LoadFile(Hangar.MainPlayerDirectory, Buyer); //Log.Error("TotalBuys: " + ToInfo.GetServerOfferPurchaseCount(Offer.Name)); if (Offer.TotalPerPlayer != 0 && ToInfo.GetServerOfferPurchaseCount(Offer.Name) >= Offer.TotalPerPlayer) { Chat.Send($"You have reached your buy limit for this offer!", Buyer); return; } GridStamp Stamp = new GridStamp(Offer.FileSBCPath); Stamp.GridName = Offer.Name; //Log.Error("C"); if (PlayerHangar.TransferGrid(ToInfo, Stamp)) { //Log.Error("Changing Balance"); MyBankingSystem.ChangeBalance(BuyerIdentity.IdentityId, -1 * Offer.Price); Chat.Send($"Successfully purchased {Offer.Name}! Check your hangar!", Buyer); GridOfferBought(Offer, Buyer); //Hangar.Config.RefreshModel(); } }