public static bool TakePlayerTokens(PlayerMobile player, int amount, bool informPlayer) { #if USE_TOKENS ulong masterLooterTokens = 0; int curTokens = 0; int amountLeft = amount; int firstPortion = 0; if (amount < 0) { return(false); } // Get Player's total tokens MasterLooterBackpack backpack = Daat99MasterLootersUtils.GetMasterLooter(player); if (backpack != null) { masterLooterTokens = backpack.TokensAmount; } Item[] tokenStacks = player.Backpack.FindItemsByType(typeof(Daat99Tokens)); foreach (Item tokenStack in tokenStacks) { curTokens += tokenStack.Amount; } // Check Total Tokens >= Item Cost if ((curTokens + int.Parse(masterLooterTokens.ToString()) >= amountLeft)) { // Withdraw from backpack first if (amountLeft > curTokens) { firstPortion = curTokens; } else { firstPortion = amountLeft; } amountLeft -= player.Backpack.ConsumeUpTo(typeof(Daat99Tokens), firstPortion, false); // Withdraw remaining from MasterLooterBackpack if (amountLeft > 0) { backpack.RemoveTokensAmount(ulong.Parse(amountLeft.ToString())); } return(true); } else { player.SendMessage(1173, String.Format("You have {0} tokens in your backpack but require {1}.", curTokens, amount)); } if (amountLeft == 0) { return(true); } #endif return(false); }
public static bool GiveTokensToPlayer(PlayerMobile player, int amount, bool informPlayer) { //return MasterStorageUtils.GiveTypeToPlayer(player, typeof(Daat99Tokens), amount, informPlayer); return(Daat99MasterLootersUtils.GivePlayerTokens(player, amount, informPlayer)); }