Progress Bar Skript 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 community!

    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!

DashElector

Member
Sep 24, 2024
3
0
1
I've tried using this as a progress bar which i made, which works like 10% of the time, but it wont work for certain numbers:


code_language.skript:
function progressBar(p: player, var: object, amount: integer, type: text) :: string:
  set {_percent} to {_var} / {_amount} * 100.0
  if {_percent} >= 100:
    set {_percent} to 100
  set {_progress} to {_percent} * 0.01 * 50
  loop {_progress} times:
    set {_rest} to 50 - {_progress}
    set {_bar} to (join {_bar} and "&e&l|")
  loop {_rest} times:
    set {_bar} to (join {_bar} and "&8&l|")
  if {_var} < 1:
    if {_type} is "percent":
      set {_fullbar} to "&8&l|||||||||||||||||||||||||||||||||||||||||||||||||| &f%{_percent}%%%"
    else if {_type} is "nopercent":
      set {_fullbar} to "&8&l||||||||||||||||||||||||||||||||||||||||||||||||||"
  send action bar {_fullbar} to {_P}
  return {_fullbar}


Is there anything that can fix it?
 
code_language.skript:
function progressBar(p: player, var: number, amount: number, type: text):
  set {_progress} to min(1, {_var} / {_amount})
  set {_s} to ""
  loop 50 times:
    if {_progress}*50 >= loop-number:
      set {_s} to "%{_s}%&e&l|"
    else:
      set {_s} to "%{_s}%&8&l|"
  if {_type} = "percent":
    set {_bar} to "%{_s}% &f%{_progress}*100%%%"
  else:
    set {_bar} to {_s}
  send action bar {_bar} to {_p}
don't wanna be a spoonfeeder but i don't see any other way to fix that code