Solved Need Help Functions

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

King_Creeperz

Member
Oct 6, 2020
45
0
8
so I am looking at some forums about functions and I think I wanna learn how to do it. the first thing I know about it is that ik that a function allows you to make quick variables that do a action when used. I think the code to the start is like this
Code:
Function money(money: number) :: number
    #do code
also what I wanna do is make something that splits numbers to make it look like these certain numbers
(1k, 1m, 1b, 1t ,1q, 1Q, etc)
I think it is like
Code:
set {_shortens} to "K,3|M,6|B,9|T,12|q,15|Q,18"
but idk after that
Also I am using %player's balance%
 
Last edited:
Function shortcuter(Number: Number) :: String:
Set {_shortcuter} to {_Number}
If {_shortcuter} is less than 1000:
Return "%{_shortcuter}%"
Else if {_shortcuter} is greater or equal to 1000:
Set {_short} to "%{_shortcuter}/1000%"
Set {_symbol} to "K"
If {_shortcuter} is greater or equal to 1000000:
Set {_short} to "%{_shortcuter}/1000000%"
Set {_symbol} to "M"
Return "%{_short}%%{_symbol}%"
[doublepost=1629619233,1629619201][/doublepost]
Code:
Function shortcuter(Number: Number) :: String:
  Set {_shortcuter} to {_Number}
  If {_shortcuter} is less than 1000:
    Return "%{_shortcuter}%"
  Else if {_shortcuter} is greater or equal to 1000:
    Set {_short} to "%{_shortcuter}/1000%"
    Set {_symbol} to "K"
    If {_shortcuter} is greater or equal to 1000000:
      Set {_short} to "%{_shortcuter}/1000000%"
      Set {_symbol} to "M"
  Return "%{_short}%%{_symbol}%"
 
thanks! I'll try it
[doublepost=1629666916,1629652279][/doublepost]ok I have some questions... what can you do with functions and what is Return?
 
Status
Not open for further replies.