Discord Thread How could I make this command so you can run "/pay {name} 1b" instead of "/pay {name} 1000000000"

  • 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!

This thread came from the skUnity Discord. You can't reply to it here but if you join the skUnity Discord, you'll be able to post a reply there. The thread link is part of the thread's message.
Status
Not open for further replies.

skUnity Discord

Site Manager
Aug 5, 2023
12,755
0
0
The skUnity Discord
discord.gg
code_language.skript:
command /pay [<player>] [<integer>]:
    cooldown: 5 seconds
    cooldown message: &cYou need to wait %remaining time% before using this again!
    trigger:
        if arg-1 is not set:
            message "&cYou need to specify an online player!"
            stop
        if arg-2 is not set:
            message "&cYou need to specify an amount!"
            stop
        set {_m} to arg-2
        if player's balance < {_m}:
            message "&cYou need $%player's balance - {_m}% to pay this amount!"
            stop
        remove arg-2 from player's balance
        message "&aYou have successfully sent $%arg-2% to %arg-1%" to sender
        message "&aYou have received $%arg-2% from %arg-1%" to arg-1

Posted by: inqy. from the skUnity Discord. View the thread on skUnity Discord here
 
i think <@224021503908380672
and <@830057380359438396> wrote a function for that:
code_language.skript:
hs
function rformat(s: string) :: number:
    set {_s} to {_s} in lower case
    loop ("k|m|b|t|qa|qi|sx|sp|oc" split at "|"):
        add 1 to {_i} if {_s} partially matches "(\d|\.)(k|m|b|t|qa|qi|sx|sp|oc)"
        set {_z::*} to split {_s} at loop-value
        replace all "," in {_z::1} with ""
        {_z::1} does not partially match "[^.0-9]":
            return ({_z::1} parsed as number) * (10 ^ ({_i} * 3))
    return 0

Posted by: bluelhf from the skUnity Discord.
 
instead of arg-2 being an integer you'd use a text and then use rformat(arg-2) to convert it to a number
code_language.skript:
applescript
# blah blah command /pay whatever
  trigger:
    set {_amount} to rformat(arg-2)

Posted by: bluelhf from the skUnity Discord.
 
code_language.skript:
command /pay [<player>] [<text>]:
    cooldown: 5 seconds
    cooldown message: &cYou need to wait %remaining time% before using this again!
    trigger:
        set {_amount} to rformat(arg-2)
        if arg-1 is not set:
            message "&cYou need to specify an online player!"
            stop
        if arg-2 is not set:
            message "&cYou need to specify an amount!"
            stop
        set {_m} to arg-2
        if player's balance < {_m}:
            message "&cYou need $%player's balance - {_m}% to pay this amount!"
            stop
        remove arg-2 from player's balance
        message "&aYou have successfully sent $%arg-2% to %arg-1%" to sender
        message "&aYou have received $%arg-2% from %arg-1%" to arg-1

command /bal [<offlineplayer>]:
    trigger:
        if arg-1 is not set:
            set {_p} to sender
        else:
            set {_p} to arg-1
        set {_m} to balance of {_p}
        send action bar "&a%{_p}%'s Balance: %formatt({_p}'s balance)%" to sender
        play sound "minecraft:entity.player.levelup" at volume 1 at pitch 1 to player



function formatt(n: number) :: text:
    set {_data} to "QT,18|Q,15|T,12|B,9|M,6|k,3"
    loop split {_data} at "|":
        set {_s::*} to split loop-value at ","
        {_n} >= 10 ^ {_s::2} parsed as number
        return "%{_n} / 10 ^ {_s::2} parsed as number%%{_s::1}%"
    return "%{_n}%"


function rformat(s: string) :: number:
    set {_s} to {_s} in lower case
    loop ("k|m|b|t|qa|qi|sx|sp|oc" split at "|"):
        add 1 to {_i} if {_s} partially matches "(\d|\.)(k|m|b|t|qa|qi|sx|sp|oc)"
        set {_z::*} to split {_s} at loop-value
        replace all "," in {_z::1} with ""
        {_z::1} does not partially match "[^.0-9]":
            return ({_z::1} parsed as number) * (10 ^ ({_i} * 3))
    return 0
got 1 error
oop sorry
command /pay [<player>] [<text>]:
    cooldown: 5 seconds
    cooldown message: &cYou need to wait %remaining time% before using this again!
    trigger:
        set {_amount} to rformat(arg-2)
        if arg-1 is not set:
            message "&cYou need to specify an online player!"
            stop
        if arg-2 is not set:
            message "&cYou need to specify an amount!"
            stop
        set {_m} to arg-2
        if player's balance < {_m}:
            message "&cYou need $%player's balance - {_m}% to pay this amount!"
            stop
        remove arg-2 from player's balance
        message "&aYou have successfully sent $%arg-2% to %arg-1%" to sender
        message "&aYou have received $%arg-2% from %arg-1%" to arg-1
        
function rformat(s: string) :: number:
    set {_s} to {_s} in lower case
    loop ("k|m|b|t|qa|qi|sx|sp|oc" split at "|"):
        add 1 to {_i} if {_s} partially matches "(\d|\.)(k|m|b|t|qa|qi|sx|sp|oc)"
        set {_z::*} to split {_s} at loop-value
        replace all "," in {_z::1} with ""
        {_z::1} does not partially match "[^.0-9]":
            return ({_z::1} parsed as number) * (10 ^ ({_i} * 3))
there
ohh
is it {_amount}
instead of arg-2 on line 16

Posted by: inqy. from the skUnity Discord.
 
Status
Not open for further replies.