Bump, Gachl seems to be busy and hasn't responded to my last pm, so this is what we have so far:
PHP Code:
new iLastRandom[12][3];
public GetBetterRandomInt(min, max, rid)
{
if (max > sizeof(iLastRandom[]))
return GetRandomInt(min, max);
new iRandom = GetRandomInt(min, max);
new bool:bWrong = true;
while (bWrong)
{
bWrong = false;
for (new i = 0; i < sizeof(iLastRandom[]); i++)
{
if (iLastRandom[rid][i] == iRandom)
{
bWrong = true;
break;
}
}
if (bWrong)
iRandom = GetRandomInt(min, max);
}
for (new j = sizeof(iLastRandom[]) - 2; j >= 0; j++)
{
iLastRandom[rid][j+1] = iLastRandom[rid][j];
}
iLastRandom[rid][0] = iRandom;
return iRandom;
}
That is supposed to prevent each (uhh) thing I use it on from rolling the same thing.
Problem is it doesn't work at all.
PHP Code:
new random = GetBetterRandomInt(0, 13, 0);
Format(message, sizeof(message), "\x03%s\x01 Rolled a\x04 %i\x01!", clientname, random);
SayText2(client, message);
return Plugin_Continue;
With that I can still roll the same number twice, even three times in a row.
Same this with:
PHP Code:
// Start of plugin
#define numroll 12
new const String:rollphrases[numroll][] = {
//stuff here
};
////////////////////////
// In function
Format(message, sizeof(message), rollphrases[GetBetterRandomInt(0, numroll-1, 1)], clientname);
SayText2(client, message);
return Plugin_Continue;
I can "roll" the same string multiple times in a row.