lai0n lai0n  • 21.06.14 17:00

[Script] Serial Empty [Script] Serial 21.06.14 17:00

Olá Convidado,


desenvolvi meu primeiro script em JavaScript (JS) que se trata de um pequeno sistema de serial que provalvemente irei usar em meu proximo emulador .


script:
Código:


<script language="JavaScript">


var numArr = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h"); // Add elements here
var pickArr = new Array(); // The array that will be formed
var count=0;
var doFlag=false;
var iterations=0;

function pickNums(nums)
{
iterations+=1;
var currNum = Math.round((numArr.length-1)*Math.random());
if(count!=0)
{
for(var i=0; i<pickArr.length; i++)
{
if(numArr[currNum]==pickArr[i])
{
doFlag=true;
break;
}
}
}
if(!doFlag)
{
pickArr[count]=numArr[currNum];
document.write('<b>' + numArr[currNum] + '</b> <font color="#808080">|</font> ');
count+=1;
}
if(iterations<(numArr.length*3)) // Compare for max iterations you want
{
if((count<nums))
{
pickNums(nums);
}
}
else
{
location.reload();
}
}

pickNums(5); // Call the function, the argument is the number of elements you want to pick.
// Here we pick 5 unique random numbers
</script>



Atenciosamente,
Permissões neste sub-fórum
Não podes responder a tópicos

BH Servers

Recomendamos a BH Servers com proteção DDOS gratuita em Cloud Server de alta performance. Entrega imediata.