So I tried to make a function that will run something and set a variable into a number that will be used for "wait", after that it'll wait for that amount of variable time to run the function again. Look I know the explanation might be very confusing and make no sense but this is the code:
Now the problem is that it run the function again even before the set time. For example if the wait is 10 seconds, it'll run the function again at 7 seconds. Idk how to fix this, is this a problem with my code or a bug, pls help me I'm so desperate. If you need more info I can provide them if I have it. Thank you
Code:
function testRate():
if {testChange} = true:
set {incRateTest.percent} to random number between 5 and 10 # increase percentage
set {incRateTest.wait} to random integer between 15 and 20 # number for "wait"
set {_incValtest} to (rounded down ({valtest} * ({incRateTest.percent} / 100)))
add {_incValtest} to {valtest} #the value after being increased
wait 5 ticks
broadcast "%nl%&e&lCONVERTION RATE INCREASE%nl%&7"
broadcast " &6| &ePercentage: &f%{incRateTest.percent}%%%"
broadcast " &6| &eNext Change: &f%{incRateTest.wait}% &fseconds%nl%&7"
set {incRateTest.waitTime} to "%{incRateTest.wait}% seconds" parsed as timespan # time until next increasement
set {incRateTest.timeWait} to now # this is for another line of code to tell the time difference until the next increasement
set {incRateTest.waitForNext} to "%{incRateTest.wait}% seconds" parsed as timespan # this is tp set the "wait" time parsed as timespan
wait {incRateTest.waitForNext}
testRate()
else if {testChange} = false:
stop
Now the problem is that it run the function again even before the set time. For example if the wait is 10 seconds, it'll run the function again at 7 seconds. Idk how to fix this, is this a problem with my code or a bug, pls help me I'm so desperate. If you need more info I can provide them if I have it. Thank you