Deacon Frost

08-19-2008, 01:39 AM

This part is solved, post #17 has the next issue! Please read that :D!

Alright, I have been searching as hard as I can, and trying to figure out how to compile this all. But I really can't figure it out.

I'll include below what I have, but here's what I need:

I need a script that generates a random number based on a percentage chance. Lets say a person has a 10% chance to get a 100, and in order for the script to return true the number must be 100 or greater. So I need it to generate the number based on that person's 10% chance. Not only that, but if it returns false, I need to add 2% to the person's chance, and redo it until it returns true, or it is stopped. It needs to wait 2 seconds in-between each new roll.

So I have all the scripts I need, I'm positive, they all come from w3schools, or various places. They each do the function separately, but I'm getting a headache trying to figure out how to combine them.

function generate(){

var randomnumber=Math.floor(Math.random()*101)

}

if (chance => '100')

{

document.write("You successfully got the log.");

}

else

{

+2%

}

setTimeout("document.getElementById('txt').value='2 seconds!'",2000);

<script type="text/javascript">

for (i = 0; i <= 5; i++)

{

document.write("The number is " + i);

document.write("<br />");

}

</script>

<script type="text/javascript">

var i=0;

while (i<=10)

{

document.write("The number is " + i);

document.write("<br />");

i=i+1;

}

</script>

function() {

if(number == 100) {

return true

} else {

return false +2 chance

}

});

The bottom one is basically what is gonna output, the others are just the randomizing/checking, etc.

I'm going to be putting this on a form of sorts, and it'll just output text, which the return true will do. But it'll basically be called upon through php, if that helps.

:(. My head hurts.

Thanks if anyone can help, ask questions, and I'll answer to the best I can.

Alright, I have been searching as hard as I can, and trying to figure out how to compile this all. But I really can't figure it out.

I'll include below what I have, but here's what I need:

I need a script that generates a random number based on a percentage chance. Lets say a person has a 10% chance to get a 100, and in order for the script to return true the number must be 100 or greater. So I need it to generate the number based on that person's 10% chance. Not only that, but if it returns false, I need to add 2% to the person's chance, and redo it until it returns true, or it is stopped. It needs to wait 2 seconds in-between each new roll.

So I have all the scripts I need, I'm positive, they all come from w3schools, or various places. They each do the function separately, but I'm getting a headache trying to figure out how to combine them.

function generate(){

var randomnumber=Math.floor(Math.random()*101)

}

if (chance => '100')

{

document.write("You successfully got the log.");

}

else

{

+2%

}

setTimeout("document.getElementById('txt').value='2 seconds!'",2000);

<script type="text/javascript">

for (i = 0; i <= 5; i++)

{

document.write("The number is " + i);

document.write("<br />");

}

</script>

<script type="text/javascript">

var i=0;

while (i<=10)

{

document.write("The number is " + i);

document.write("<br />");

i=i+1;

}

</script>

function() {

if(number == 100) {

return true

} else {

return false +2 chance

}

});

The bottom one is basically what is gonna output, the others are just the randomizing/checking, etc.

I'm going to be putting this on a form of sorts, and it'll just output text, which the return true will do. But it'll basically be called upon through php, if that helps.

:(. My head hurts.

Thanks if anyone can help, ask questions, and I'll answer to the best I can.