1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Balance split (NEED HELP)

Discussion in 'Skript' started by XSKRIPTX, Jun 21, 2019.

Thread Status:
Not open for further replies.
  1. XSKRIPTX

    XSKRIPTX Member

    Joined:
    Dec 26, 2017
    Messages:
    47
    Likes Received:
    1
    Hello, it is possible do split balance?
    example: 5.000 instead of 5000

    i work with: {coins.%player%}
     
  2. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    232
    Code (Skript):
    1. function regex(n: object) :: text:    #<--- use this function
    2.     if "%{_n}%" contains ".":
    3.         set {_s::*} to split "%{_n}%" at "."
    4.         set {_n} to "%a({_s::1})%.%last 2 characters of {_s::2}%"
    5.         return "%{_n}%"
    6.     else:
    7.         set {_n} to a("%{_n}%")
    8.         return "%{_n} ? 0%"
    9. function a(b: text) :: text:    #<--- ignore this function, its just part of it
    10.     if length of {_b} > 3:
    11.         return "%a(first length of {_b} - 3 characters of {_b})%,%last 3 characters of {_b}%"
    12.     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 (Skript):
    1. send "Balance: %regex(balance of player)%"
     
  3. XSKRIPTX

    XSKRIPTX Member

    Joined:
    Dec 26, 2017
    Messages:
    47
    Likes Received:
    1
    i have test it but a have 2 Errors
    https://gyazo.com/d2433924532be9190450531af03213a2

    Code:
    Code (Text):
    1. function regex(n: object) :: text:
    2.     if "%{_n}%" contains ".":
    3.         set {_s::*} to split "%{_n}%" at "."
    4.         set {_n} to "%a({_s::1})%.%last 2 characters of {_s::2}%"
    5.         return "%{_n}%"
    6.     else:
    7.         set {_n} to a("%{_n}%")
    8.         return "%{_n} ? 0%"
    9. function a(b: text) :: text:
    10.     if length of {_b} > 3:
    11.         return "%a(first length of {_b} - 3 characters of {_b})%,%last 3 characters of {_b}%"
    12.     return {_b}
    13. command /testcoins:
    14.     trigger:
    15.         send "Coins: %regex({coins.%player%})%"
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    232
    Which version of Skript and Spigot are you using?
     
  5. XSKRIPTX

    XSKRIPTX Member

    Joined:
    Dec 26, 2017
    Messages:
    47
    Likes Received:
    1
    2.2-SNAPSHOT
     
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    232
    Hmm... Im not sure then, I've never used a Skript version that was like 4 years outdated. Parts of the code I sent might have been introduced in one of the 100 versions that have come out since that version.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...