Solved Buy Max Option

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

gamer_YT762

Member
Jun 9, 2021
19
0
1
24
Im making a clicker server, where you can buy upgrades. But when you have alot of points, you need to click so much on the upgrade. I want you to make a buy max thingy where you can instantly buy the upgrades that you afford. Like: You have 1b points and the upgrade costs 1m points, so you will need to click 1000 times. But i want to make it so you can buy that 1000 instantly with 1 click. If you can make it, then please. Thanks!

My points var: {%player%.points} || The points per click var (what you buy with the upgrade): {%player%.pointsperclick}
 
not sure if it works tho
Code:
command /setpoints <offline player> <integer>:
  trigger:
    set {POINTS::%player's uuid%} to arg-2

command /setprice <integer> <integer>:
  trigger:
    set {UPGRADEPRICE::%arg-1%} to arg-2

command /upgrade [<text>]:
  trigger:
    set {_x} to {POINTS::%player's uuid%} + 1
    set {_y} to {UPGRADEPRICE::%{_x}%} - {POINTS::%player's uuid%}
    if {_y} is less than or equal to 0:
      add 1 to {LEVEL::%player's uuid%}
      remove {UPGRADEPRICE::%{_x}%} from {POINTS::%player's uuid%}

command /maxupgrade [<text>]:
  trigger
      set {_x} to {POINTS::%player's uuid%} + 1
      set {_y} to {UPGRADEPRICE::%{_x}%} - {POINTS::%player's uuid%}
      while {_y} is less than or equal to 0:
          add 1 to {LEVEL::%player's uuid%}
          remove {UPGRADEPRICE::%{_x}%} from {POINTS::%player's uuid%}
          set {_x} to {POINTS::%player's uuid%} + 1
          set {_y} to {UPGRADEPRICE::%{_x}%} - {POINTS::%player's uuid%}
      wait 1 tick

the current level/upgrade: {LEVEL::%player's uuid%}
the current points of the player: {POINTS::%player's uuid%}

upgrade one level with /upgrade
upgrade all available levels with /maxupgrade

you have to set the price of the upgrades with /setprice <level> <price>
you have to convert your old variables into the new ones
you have to add a multiplier to your on click event thing
 
not sure if it works tho
Code:
command /setpoints <offline player> <integer>:
  trigger:
    set {POINTS::%player's uuid%} to arg-2

command /setprice <integer> <integer>:
  trigger:
    set {UPGRADEPRICE::%arg-1%} to arg-2

command /upgrade [<text>]:
  trigger:
    set {_x} to {POINTS::%player's uuid%} + 1
    set {_y} to {UPGRADEPRICE::%{_x}%} - {POINTS::%player's uuid%}
    if {_y} is less than or equal to 0:
      add 1 to {LEVEL::%player's uuid%}
      remove {UPGRADEPRICE::%{_x}%} from {POINTS::%player's uuid%}

command /maxupgrade [<text>]:
  trigger
      set {_x} to {POINTS::%player's uuid%} + 1
      set {_y} to {UPGRADEPRICE::%{_x}%} - {POINTS::%player's uuid%}
      while {_y} is less than or equal to 0:
          add 1 to {LEVEL::%player's uuid%}
          remove {UPGRADEPRICE::%{_x}%} from {POINTS::%player's uuid%}
          set {_x} to {POINTS::%player's uuid%} + 1
          set {_y} to {UPGRADEPRICE::%{_x}%} - {POINTS::%player's uuid%}
      wait 1 tick

the current level/upgrade: {LEVEL::%player's uuid%}
the current points of the player: {POINTS::%player's uuid%}

upgrade one level with /upgrade
upgrade all available levels with /maxupgrade

you have to set the price of the upgrades with /setprice <level> <price>
you have to convert your old variables into the new ones
you have to add a multiplier to your on click event thing
thanks, ill test it :emoji_wink:
[doublepost=1624102460,1624101847][/doublepost]
thanks, ill test it :emoji_wink:
i tested, and it crashes the server when i have alot of points