MrBlue
Basic economics system and economy API

Supported Games
GameServerKingsGameServerKings

Economics is a basic economics system that other plugins can make use of by using the provided API. On its own, this plugin only provides the features listed and has no shop.

Permissions

  • economics.balance -- Allows player to use the balance command for other players
  • economics.deposit -- Allows player to use the deposit command
  • economics.depositall -- Allows player to use the deposit command to deposit amount to all players
  • economics.setbalance -- Allows player to use the setbalance command
  • economics.setbalanceall -- Allows player to use the setbalance command to set money for all players
  • economics.transfer -- Allows player to use the transfer command
  • economics.transferall -- Allows player to use the transfer command to transfer amount to all connected players
  • economics.withdraw -- Allows player to use the withdraw command
  • economics.withdrawall -- Allows player to use the withdraw command to withdraw amount from all players
  • economics.wipe -- Allows player to use the ecowipe command to wipe data

Commands

  • balance
    Check your balance (does not require or use a permission)
  • balance <player name or id>
    Check [name] player balance (requires economics.balance)
  • deposit <player name or id | *> <amount>
    Deposit [amount] to [name] player (requires economics.deposit)
  • setbalance <player name or id | *> <amount>
    Set balance to [amount] for [name] player (requires economics.setbalance)
  • transfer <player name or id | *> <amount>
    Transfer [amount] to [name] player (requires economics.transfer)
  • withdraw <player name or id | *> <amount>
    Withdraw [amount] from [name] player (requires economics.withdraw)
  • ecowipe
    Wipe all saved Economics data, including balances (requires economics.wipe)

Note: The asterisk (*) in the above command usage means ALL players; use with caution. Using the * for ALL players requires to associated *All permission.

Configuration

{
  "Allow negative balance for accounts": false,
  "Balance limit for accounts (0 to disable)": 0,
  "Negative balance limit for accounts (0 to disable)": 0,
  "Remove unused accounts": true,
  "Log transactions to file": false,
  "Starting account balance (0 or higher)": 1000,
  "Wipe balances on new save file": false
}

Note: The wipe on new save option currently only works with Rust and Hurtworld.

Localization

{
  "CommandBalance": "balance",
  "CommandDeposit": "deposit",
  "CommandSetBalance": "SetBalance",
  "CommandTransfer": "transfer",
  "CommandWithdraw": "withdraw",
  "CommandWipe": "ecowipe",
  "DataSaved": "Economics data saved!",
  "DataWiped": "Economics data wiped!",
  "DepositedToAll": "Deposited {0:C} total ({1:C} each) to {2} player(s)",
  "LogDeposit": "{0:C} deposited to {1}",
  "LogSetBalance": "{0:C} set as balance for {1}",
  "LogTransfer": "{0:C} transferred to {1} from {2}",
  "LogWithdrawl": "{0:C} withdrawn from {1}",
  "NegativeBalance": "Balance can not be negative!",
  "NotAllowed": "You are not allowed to use the '{0}' command",
  "NoPlayersFound": "No players found with name or ID '{0}'",
  "PlayerBalance": "Balance for {0}: {1:C}",
  "PlayerLacksMoney": "'{0}' does not have enough money!",
  "PlayersFound": "Multiple players were found, please specify: {0}",
  "ReceivedFrom": "You have received {0} from {1}",
  "SetBalanceForAll": "Balance set to {0:C} for {1} player(s)",
  "TransactionFailed": "Transaction failed! Make sure amount is above 0",
  "TransferredTo": "{0} transferred to {1}",
  "TransferredToAll": "Transferred {0:C} total ({1:C} each) to {2} player(s)",
  "TransferToSelf": "You can not transfer money yourself!",
  "UsageBalance": "{0} - check your balance",
  "UsageBalanceOthers": "{0} <player name or id> - check balance of a player",
  "UsageDeposit": "{0} <player name or id> <amount> - deposit amount to player",
  "UsageSetBalance": "Usage: {0} <player name or id> <amount> - set balance for player",
  "UsageTransfer": "Usage: {0} <player name or id> <amount> - transfer money to player",
  "UsageWithdraw": "Usage: {0} <player name or id> <amount> - withdraw money from player",
  "UsageWipe": "Usage: {0} - wipe all economics data",
  "YouLackMoney": "You do not have enough money!",
  "YouLostMoney": "You lost: {0:C}",
  "YouReceivedMoney": "You received: {0:C}",
  "YourBalance": "Your balance is: {0:C}",
  "WithdrawnForAll": "Withdrew {0:C} total ({1:C} each) from {2} player(s)",
  "ZeroAmount": "Amount cannot be zero"
}

For Developers

API Methods

private double Balance(string playerId)
private double Balance(ulong playerId)

private bool Deposit(string playerId, double amount)
private bool Deposit(ulong playerId, double amount)

private bool SetBalance(string playerId, double amount)
private bool SetBalance(ulong playerId, double amount)

private bool Transfer(string playerId, string targetId, double amount)
private bool Transfer(ulong playerId, string targetId, double amount)

private bool Withdraw(string playerId, double amount)
private bool Withdraw(ulong playerId, double amount)

Hooks

private void OnEconomicsBalanceUpdated(string playerId, double amount)

Called when a player's account balance changes.

private OnEconomicsDeposit(string playerId, double amount)

Called when a deposit is made to a player's account.

private void OnEconomicsWithdrawl(string playerId, double amount)

Called when a withdrawal is made from a player's account.

private void OnEconomicsTransfer(string playerId, string targetId, double amount)

Called when a transfer is made between player accounts.

private void OnEconomicsDataWiped()

Called when all economics data is wiped.

private void OnEconomicsDataWiped(IPlayer player)

Called when economics data for a specific player.

Credits

  • Nogrod, for the original C# version of this plugin
  • Bombardir, for the original Lua version of this plugin
  • Wulf, for maintaining the plugin

MIT License, with distribution exclusivity for uMod.org


Copyright (c) 2020 Wulf


Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:


The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.


THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.