The custom random
#10

pawn Код:
new oldInt[2] = {-1, ...};

GetFreeInt()
{
    for(new i = 0; i < sizeof oldInt; i++)
    {
        if(oldInt[i] == -1) return i;
    }
    return 0; //Start overwriting the array
}

stock randomEx(min, max)
{
    new ints;
    new s = GetFreeInt();
    do {
        ints = Randomize(min, max+1);
    }
    while(ints == oldInt[s] && ints == oldInt[s-1]);
    printf("%d", ints);
    oldInt[s] = ints;
    return oldInt[s];
}

CMD:ur(playerid, params[])
{
    SendClientMessageEx(playerid, 0xFF0000AA, "Random Number: %d", randomEx(1, 299));
    return 1;
}
I don't have any better idea.
Reply


Messages In This Thread
The custom random - by ProjectMan - 14.08.2013, 10:22
Re: The custom random - by ProjectMan - 14.08.2013, 10:35
Re: The custom random - by Dragonsaurus - 14.08.2013, 10:37
Re: The custom random - by ProjectMan - 14.08.2013, 10:47
Re: The custom random - by Dragonsaurus - 14.08.2013, 10:54
Re: The custom random - by [XST]O_x - 14.08.2013, 10:57
Re: The custom random - by ProjectMan - 14.08.2013, 11:17
Re: The custom random - by ProjectMan - 14.08.2013, 11:45
Re: The custom random - by [XST]O_x - 14.08.2013, 11:57
Re: The custom random - by [XST]O_x - 14.08.2013, 12:15

Forum Jump:


Users browsing this thread: 3 Guest(s)