Balance split (NEED HELP)

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

Status
Not open for further replies.

XSKRIPTX

Member
Dec 26, 2017
47
1
8
35
Hello, it is possible do split balance?
example: 5.000 instead of 5000

i work with: {coins.%player%}
 
code_language.skript:
function regex(n: object) :: text:    #<--- use this function
    if "%{_n}%" contains ".":
        set {_s::*} to split "%{_n}%" at "."
        set {_n} to "%a({_s::1})%.%last 2 characters of {_s::2}%"
        return "%{_n}%"
    else:
        set {_n} to a("%{_n}%")
        return "%{_n} ? 0%"
function a(b: text) :: text:    #<--- ignore this function, its just part of it
    if length of {_b} > 3:
        return "%a(first length of {_b} - 3 characters of {_b})%,%last 3 characters of {_b}%"
    return {_b}

how to use:
(note: Anything can be used within this function, Im using balance of player to show you but you could use a variable.)
code_language.skript:
send "Balance: %regex(balance of player)%"
 
code_language.skript:
function regex(n: object) :: text:    #<--- use this function
    if "%{_n}%" contains ".":
        set {_s::*} to split "%{_n}%" at "."
        set {_n} to "%a({_s::1})%.%last 2 characters of {_s::2}%"
        return "%{_n}%"
    else:
        set {_n} to a("%{_n}%")
        return "%{_n} ? 0%"
function a(b: text) :: text:    #<--- ignore this function, its just part of it
    if length of {_b} > 3:
        return "%a(first length of {_b} - 3 characters of {_b})%,%last 3 characters of {_b}%"
    return {_b}

how to use:
(note: Anything can be used within this function, Im using balance of player to show you but you could use a variable.)
code_language.skript:
send "Balance: %regex(balance of player)%"

i have test it but a have 2 Errors
https://gyazo.com/d2433924532be9190450531af03213a2

Code:
Code:
function regex(n: object) :: text:
    if "%{_n}%" contains ".":
        set {_s::*} to split "%{_n}%" at "."
        set {_n} to "%a({_s::1})%.%last 2 characters of {_s::2}%"
        return "%{_n}%"
    else:
        set {_n} to a("%{_n}%")
        return "%{_n} ? 0%"
function a(b: text) :: text:
    if length of {_b} > 3:
        return "%a(first length of {_b} - 3 characters of {_b})%,%last 3 characters of {_b}%"
    return {_b}
command /testcoins:
    trigger:
        send "Coins: %regex({coins.%player%})%"
 
i have test it but a have 2 Errors
https://gyazo.com/d2433924532be9190450531af03213a2

Code:
Code:
function regex(n: object) :: text:
    if "%{_n}%" contains ".":
        set {_s::*} to split "%{_n}%" at "."
        set {_n} to "%a({_s::1})%.%last 2 characters of {_s::2}%"
        return "%{_n}%"
    else:
        set {_n} to a("%{_n}%")
        return "%{_n} ? 0%"
function a(b: text) :: text:
    if length of {_b} > 3:
        return "%a(first length of {_b} - 3 characters of {_b})%,%last 3 characters of {_b}%"
    return {_b}
command /testcoins:
    trigger:
        send "Coins: %regex({coins.%player%})%"
Which version of Skript and Spigot are you using?
 
Status
Not open for further replies.