You'll want to include a paused "flag" and a loss counter... so, if there is a "win", you reset the lossCount back to 0... if a "loss" AND chance == 33.33 then you increment it by 1. When the counter gets to 5, you set the flag to true and use that condition to specify the betsize = 0.00000001
I assume when you say that "it resumes from the previous level" that you want it to store the old bet amount from where it paused... and then use that once it starts betting again?
NOTE: this code is UNTESTED chance = 81.12
bethigh = true
basebet = 0.00000031
nextbet = basebet
losscount = 0
oldbet = 0
paused = false
function dobet()
if win then
if paused then
losscount = 0
paused = false
nextbet = oldbet * 1.59738 -- resume betting at previous level
else
chance = 81.12
nextbet = basebet
end
else
if chance == 33.33 then
losscount = losscount + 1
if losscount == 5 then
paused = true
nextbet = 0.00000001
oldbet = previousbet -- save the current bet for resuming later
elseif losscount > 5 then
paused = true
nextbet = 0.00000001
else
nextbet = previousbet * 1.59738
end
else
chance = 33.33
nextbet = basebet/3.3
end
end
end