hey guys!
I have a upgrade system on my server for a skill system and the price for each upgrade is defined by the calculation "6n^2-12n+16" with n being the amount of times they have purchased an upgrade. This system works for buying a singular upgrade but i want to make a system to purchase as many upgrades as possible with the money you have but everytime i use the code below, it sets the price to something beyond my balance. i dont know what the problem is. any help would be greatly appreaciated!
function calcPrice(n: integer) :: integer:
set {_y} to {_n}^2
set {_y} to {_y} * 6
set {_y} to {_y} - 12 * {_n}
set {_y} to {_y} + 16
return {_y}
while {farming::%{_p}'s uuid%::balance} is greater than calcPrice({farming::%{_p}'s uuid%::miningmultiplierindextemp}):
add calcPrice({farming::%{_p}'s uuid%::miningmultiplierindextemp}) to {farming::%{_p}'s uuid%::maxprice}
add 1 to {farming::%{_p}'s uuid%::miningmultiplierindextemp}
set {_k} to {farming::%{_p}'s uuid%::maxprice}
delete {farming::%{_p}'s uuid%::maxprice}
delete {farming::%{_p}'s uuid%::miningmultiplierindextemp}
make gui slot "d" with glowing slimeball named "&x&1&1&c&8&8&6&lUPGRADE MAX" with lore "&fCurrent Multiplier: &x&2&9&8&8&f&f%{farming::%{_p}'s uuid%::miningmultiplier}%x" and "&fPrice: &x&2&9&8&8&f&f%{_k}%":```