💻
alt:V Athena Docs v3.0.0
  • Info
    • Introduction
    • Patreon & Support
    • Athena Discord
    • FAQ
  • Installation
    • Common Issues
    • Windows
    • Linux (Ubuntu 20.04+)
    • Debugging
    • Updating
  • Info
    • Admin
    • Configuration
    • Console
    • Database
    • Hotkeys
    • Identifier
  • Plugins
    • Load Plugins
    • Create Plugins
    • Mods
    • Clothing
  • Controllers
    • What is a Controller?
    • Blip Controller
    • Interaction Controller
    • Marker Controller
    • Object Controller
    • Ped Controller
    • Text Label Controller
    • World Notification Controller
  • Systems
    • Interiors
    • Inventory & Items
    • Inventory Rules
    • Jobs
    • Time
    • Weather
  • Menus
    • Menu Types
    • Action Menus
    • Input Menu
    • Wheel Menu
  • Player
    • Admin-Commands
    • Animations
    • Attach Objects
    • Credits
    • Currency
    • Commands
    • Error Screen
    • Message
    • Meta
    • Notifications
    • Particle
    • Progress Bar
    • Save
    • Shard
    • Sound
    • Spinners
    • Task Timeline
  • Custom WebViews
    • Introduction
    • Your First Page
    • CSS Framework
  • Misc
    • Custom Sounds
    • Custom Streamers
    • Custom Icons
    • Adding Locale / Translations
    • Adding Vehicle Rules
    • Adding Whitelist
    • Adding Wheel Menus
    • Adding Parking Garages
Powered by GitBook
On this page
  • Currency Types
  • Set Currency
  • Adding Currency
  • Removing Currency
  • Remove All Currency Types
Edit on GitHub
  1. Player

Currency

Currency related commands for individual players.

All currency related functionality for managing cash and bank values.

Accessible on Server Side

Currency Types

Currency currently comes in two types. There is bank and cash.

Cash is a value that can be considered on-hand while bank is money stored in a 'safe' location. They're effectively the same but it's dependent on you to decide how to use them and the rules behind each currency type.

Set Currency

This is pretty much just for administrative related things. Currency can bet set to an exact value.

Athena.player.currency.set(player, CurrencyTypes.CASH, 50000)
Athena.player.currency.set(player, CurrencyTypes.BANK, 50000)

Adding Currency

Cash

if (!Athena.player.currency.add(player, CurrencyTypes.CASH, 25)) {
    // Did not add the currency successfully
    return;
}

// added successfully

Bank

if (!Athena.player.currency.add(player, CurrencyTypes.BANK, 25)) {
    // Did not add the currency successfully
    return;
}

// added successfully

Removing Currency

Cash

if (!Athena.player.currency.sub(player, CurrencyTypes.CASH, 25)) {
    // Did not remove the currency successfully
    return;
}

// removed successfully

Bank

if (!Athena.player.currency.sub(player, CurrencyTypes.BANK, 25)) {
    // Did not remove the currency successfully
    return;
}

// removed successfully

Remove All Currency Types

There is sometimes a situation where you wan to remove both cash on-hand and bank currency at the same time. That is what subAllCurrencies is for.

The function below will remove all currencies and start with cash first.

As a general example. Imagine the player has the following:

  • 100 Cash

  • 100 Bank

Together than is 200.

If the cost of an item is 150; you can use subAllCurrencies to subtract 100 from cash and 50 from bank. Leaving 50 remaining in the player's overall currency stats.

Example

if (!Athena.player.currency.subAllCurrencies(player, 25)) {
    // Did not have enough to remove all.
    return;
}

// Removed cash first, and then whatever was left from bank.
PreviousCreditsNextCommands

Last updated 3 years ago