Random choice - betting script [on hold]












0















I'm trying to make a betting script with random choices using Math.random, but it only chooses the same bet and it is betting a single time before it crashes.



Not sure what is wrong with the script.



var minstake   = 0.00000001;  // valor base
var autorounds = 99999; // n° de rolls
var handbrake = 0.0001; // valor lose pause game
var autoruns = 1;

function getRandomNumber() {Math.floor(Math.random() * 2) + 1;
};

function playnow() {
if (autoruns > autorounds ) { console.log('Limit reached'); return; }

if (getRandomNumber!==1) {
document.getElementById('double_your_btc_bet_lo_button').click();
setTimeout(checkresultslo, 123);
return;
function checkresultslo() {
if (document.getElementById('double_your_btc_bet_lo_button').disabled === true) {
setTimeout(checkresultslo, 246);
return;}}}
if (getRandomNumber!==2) {
document.getElementById('double_your_btc_bet_hi_button').click();
setTimeout(checkresultshi, 123);
return;
function checkresultshi() {
if (document.getElementById('double_your_btc_bet_hi_button').disabled === true) {
setTimeout(checkresultshi, 246);
return;}}}
}
var stake = document.getElementById('double_your_btc_stake').value * 1;
var won = document.getElementById('double_your_btc_bet_win').innerHTML;
if (won.match(/(d+.d+)/) !== null) { won = won.match(/(d+.d+)/)[0]; } else { won = false; }
var lost = document.getElementById('double_your_btc_bet_lose').innerHTML;
if (lost.match(/(d+.d+)/) !== null) { lost = lost.match(/(d+.d+)/)[0]; } else { lost = false; }
if (won && !lost) { stake = minstake; console.log('Bet #' + autoruns + '/' + autorounds + ': Won ' + won + ' Stake: ' + stake.toFixed(8)); }
if (lost && !won) { stake = lost * 2.1; console.log('Bet #' + autoruns + '/' + autorounds + ': Lost ' + lost + ' Stake: ' + stake.toFixed(8)); }
if (!won && !lost) { console.log('Something went wrong');}
document.getElementById('double_your_btc_stake').value = stake.toFixed(8);
autoruns++;
if (stake >= handbrake) {
document.getElementById('handbrakealert').play();
console.log('Handbrake triggered! Execute playnow() to override');
}
setTimeout(playnow, 111);
playnow()









share|improve this question







New contributor




Lucas Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by radarbob, Sᴀᴍ Onᴇᴌᴀ, Hosch250, Mast, Jamal 12 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – radarbob, Sᴀᴍ Onᴇᴌᴀ, Hosch250, Mast, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 3





    Because there code does not work you should move the question to StackOverflow

    – radarbob
    13 hours ago











  • Move the last line playnow() outside the function.

    – Blindman67
    13 hours ago
















0















I'm trying to make a betting script with random choices using Math.random, but it only chooses the same bet and it is betting a single time before it crashes.



Not sure what is wrong with the script.



var minstake   = 0.00000001;  // valor base
var autorounds = 99999; // n° de rolls
var handbrake = 0.0001; // valor lose pause game
var autoruns = 1;

function getRandomNumber() {Math.floor(Math.random() * 2) + 1;
};

function playnow() {
if (autoruns > autorounds ) { console.log('Limit reached'); return; }

if (getRandomNumber!==1) {
document.getElementById('double_your_btc_bet_lo_button').click();
setTimeout(checkresultslo, 123);
return;
function checkresultslo() {
if (document.getElementById('double_your_btc_bet_lo_button').disabled === true) {
setTimeout(checkresultslo, 246);
return;}}}
if (getRandomNumber!==2) {
document.getElementById('double_your_btc_bet_hi_button').click();
setTimeout(checkresultshi, 123);
return;
function checkresultshi() {
if (document.getElementById('double_your_btc_bet_hi_button').disabled === true) {
setTimeout(checkresultshi, 246);
return;}}}
}
var stake = document.getElementById('double_your_btc_stake').value * 1;
var won = document.getElementById('double_your_btc_bet_win').innerHTML;
if (won.match(/(d+.d+)/) !== null) { won = won.match(/(d+.d+)/)[0]; } else { won = false; }
var lost = document.getElementById('double_your_btc_bet_lose').innerHTML;
if (lost.match(/(d+.d+)/) !== null) { lost = lost.match(/(d+.d+)/)[0]; } else { lost = false; }
if (won && !lost) { stake = minstake; console.log('Bet #' + autoruns + '/' + autorounds + ': Won ' + won + ' Stake: ' + stake.toFixed(8)); }
if (lost && !won) { stake = lost * 2.1; console.log('Bet #' + autoruns + '/' + autorounds + ': Lost ' + lost + ' Stake: ' + stake.toFixed(8)); }
if (!won && !lost) { console.log('Something went wrong');}
document.getElementById('double_your_btc_stake').value = stake.toFixed(8);
autoruns++;
if (stake >= handbrake) {
document.getElementById('handbrakealert').play();
console.log('Handbrake triggered! Execute playnow() to override');
}
setTimeout(playnow, 111);
playnow()









share|improve this question







New contributor




Lucas Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by radarbob, Sᴀᴍ Onᴇᴌᴀ, Hosch250, Mast, Jamal 12 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – radarbob, Sᴀᴍ Onᴇᴌᴀ, Hosch250, Mast, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 3





    Because there code does not work you should move the question to StackOverflow

    – radarbob
    13 hours ago











  • Move the last line playnow() outside the function.

    – Blindman67
    13 hours ago














0












0








0








I'm trying to make a betting script with random choices using Math.random, but it only chooses the same bet and it is betting a single time before it crashes.



Not sure what is wrong with the script.



var minstake   = 0.00000001;  // valor base
var autorounds = 99999; // n° de rolls
var handbrake = 0.0001; // valor lose pause game
var autoruns = 1;

function getRandomNumber() {Math.floor(Math.random() * 2) + 1;
};

function playnow() {
if (autoruns > autorounds ) { console.log('Limit reached'); return; }

if (getRandomNumber!==1) {
document.getElementById('double_your_btc_bet_lo_button').click();
setTimeout(checkresultslo, 123);
return;
function checkresultslo() {
if (document.getElementById('double_your_btc_bet_lo_button').disabled === true) {
setTimeout(checkresultslo, 246);
return;}}}
if (getRandomNumber!==2) {
document.getElementById('double_your_btc_bet_hi_button').click();
setTimeout(checkresultshi, 123);
return;
function checkresultshi() {
if (document.getElementById('double_your_btc_bet_hi_button').disabled === true) {
setTimeout(checkresultshi, 246);
return;}}}
}
var stake = document.getElementById('double_your_btc_stake').value * 1;
var won = document.getElementById('double_your_btc_bet_win').innerHTML;
if (won.match(/(d+.d+)/) !== null) { won = won.match(/(d+.d+)/)[0]; } else { won = false; }
var lost = document.getElementById('double_your_btc_bet_lose').innerHTML;
if (lost.match(/(d+.d+)/) !== null) { lost = lost.match(/(d+.d+)/)[0]; } else { lost = false; }
if (won && !lost) { stake = minstake; console.log('Bet #' + autoruns + '/' + autorounds + ': Won ' + won + ' Stake: ' + stake.toFixed(8)); }
if (lost && !won) { stake = lost * 2.1; console.log('Bet #' + autoruns + '/' + autorounds + ': Lost ' + lost + ' Stake: ' + stake.toFixed(8)); }
if (!won && !lost) { console.log('Something went wrong');}
document.getElementById('double_your_btc_stake').value = stake.toFixed(8);
autoruns++;
if (stake >= handbrake) {
document.getElementById('handbrakealert').play();
console.log('Handbrake triggered! Execute playnow() to override');
}
setTimeout(playnow, 111);
playnow()









share|improve this question







New contributor




Lucas Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I'm trying to make a betting script with random choices using Math.random, but it only chooses the same bet and it is betting a single time before it crashes.



Not sure what is wrong with the script.



var minstake   = 0.00000001;  // valor base
var autorounds = 99999; // n° de rolls
var handbrake = 0.0001; // valor lose pause game
var autoruns = 1;

function getRandomNumber() {Math.floor(Math.random() * 2) + 1;
};

function playnow() {
if (autoruns > autorounds ) { console.log('Limit reached'); return; }

if (getRandomNumber!==1) {
document.getElementById('double_your_btc_bet_lo_button').click();
setTimeout(checkresultslo, 123);
return;
function checkresultslo() {
if (document.getElementById('double_your_btc_bet_lo_button').disabled === true) {
setTimeout(checkresultslo, 246);
return;}}}
if (getRandomNumber!==2) {
document.getElementById('double_your_btc_bet_hi_button').click();
setTimeout(checkresultshi, 123);
return;
function checkresultshi() {
if (document.getElementById('double_your_btc_bet_hi_button').disabled === true) {
setTimeout(checkresultshi, 246);
return;}}}
}
var stake = document.getElementById('double_your_btc_stake').value * 1;
var won = document.getElementById('double_your_btc_bet_win').innerHTML;
if (won.match(/(d+.d+)/) !== null) { won = won.match(/(d+.d+)/)[0]; } else { won = false; }
var lost = document.getElementById('double_your_btc_bet_lose').innerHTML;
if (lost.match(/(d+.d+)/) !== null) { lost = lost.match(/(d+.d+)/)[0]; } else { lost = false; }
if (won && !lost) { stake = minstake; console.log('Bet #' + autoruns + '/' + autorounds + ': Won ' + won + ' Stake: ' + stake.toFixed(8)); }
if (lost && !won) { stake = lost * 2.1; console.log('Bet #' + autoruns + '/' + autorounds + ': Lost ' + lost + ' Stake: ' + stake.toFixed(8)); }
if (!won && !lost) { console.log('Something went wrong');}
document.getElementById('double_your_btc_stake').value = stake.toFixed(8);
autoruns++;
if (stake >= handbrake) {
document.getElementById('handbrakealert').play();
console.log('Handbrake triggered! Execute playnow() to override');
}
setTimeout(playnow, 111);
playnow()






javascript random






share|improve this question







New contributor




Lucas Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Lucas Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Lucas Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 13 hours ago









Lucas OliveiraLucas Oliveira

61




61




New contributor




Lucas Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Lucas Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Lucas Oliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by radarbob, Sᴀᴍ Onᴇᴌᴀ, Hosch250, Mast, Jamal 12 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – radarbob, Sᴀᴍ Onᴇᴌᴀ, Hosch250, Mast, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.




put on hold as off-topic by radarbob, Sᴀᴍ Onᴇᴌᴀ, Hosch250, Mast, Jamal 12 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – radarbob, Sᴀᴍ Onᴇᴌᴀ, Hosch250, Mast, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 3





    Because there code does not work you should move the question to StackOverflow

    – radarbob
    13 hours ago











  • Move the last line playnow() outside the function.

    – Blindman67
    13 hours ago














  • 3





    Because there code does not work you should move the question to StackOverflow

    – radarbob
    13 hours ago











  • Move the last line playnow() outside the function.

    – Blindman67
    13 hours ago








3




3





Because there code does not work you should move the question to StackOverflow

– radarbob
13 hours ago





Because there code does not work you should move the question to StackOverflow

– radarbob
13 hours ago













Move the last line playnow() outside the function.

– Blindman67
13 hours ago





Move the last line playnow() outside the function.

– Blindman67
13 hours ago










0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

is 'sed' thread safe

How to make a Squid Proxy server?