Skript variable with Vault economy API

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

ERKO901

Member
May 24, 2023
3
0
1
24
Hello,
I want to ask you how can I use a Skript variable as Vault economy API.
I tried many ways but anyone didn't work.
 
When I want to use some plugin something like shop, it texts me that I need some economy plugin. If you execute /vault-info, it will text you that here is no economy. And I want to use my Skript variable that I use for coins.
 
When I want to use some plugin something like shop, it texts me that I need some economy plugin. If you execute /vault-info, it will text you that here is no economy. And I want to use my Skript variable that I use for coins.
I think this can be solved with skript-reflect if Skript's hook to vault doens't work , idk

Code:
import:
    org.bukkit.Bukkit
    net.milkbowl.vault.economy.Economy
 
on load:
    set {_rsp} to Bukkit.getServer().getServicesManager().getRegistration(Economy.class)
    set {vault::economy} to {_rsp}.getProvider()

#check if player registered in economy
function hasAccount(player: offlineplayer) :: boolean:
    return {vault::economy}.hasAccount({_player})

# get balance of player
function balance(player : offlineplayer) :: number:
    return {vault::economy}.getBalance({_player})

# add money to player's balance
function deposit(player : offlineplayer, amount: number) :: boolean:
    if {_amount} > 0 :
        set {_response} to {vault::economy}.depositPlayer({_player}, {_amount})
        return {_response}.transactionSuccess()
    return false

#remove money from player's balance
function withdraw(player: offlineplayer, amunt: number) :: boolean:
    if {_amount} > 0:
        set {_response} to {vault::economy}.withdrawPlayer({_player}, {_amount})
        return {_response}.transactionSuccess()
    return false
ALERT Im not tested this due to not using vault
 
Last edited: