diff --git a/src/zr/infect.inc b/src/zr/infect.inc index b85644b..9f7f415 100644 --- a/src/zr/infect.inc +++ b/src/zr/infect.inc @@ -203,7 +203,7 @@ InfectOnClientDisconnect(client) } // Get a random valid array index. - new randindex = GetRandomInt(0, eligibleclients - 1); + new randindex = Math_GetRandomInt(0, eligibleclients - 1); // Get the client stored in the random array index. new randclient = GetArrayCell(arrayEligibleClients, randindex); diff --git a/src/zr/zombiereloaded.inc b/src/zr/zombiereloaded.inc index 4c16e0b..854a543 100644 --- a/src/zr/zombiereloaded.inc +++ b/src/zr/zombiereloaded.inc @@ -412,3 +412,27 @@ ZRBoolToString(bool:value, String:output[], maxlen) strcopy(output, maxlen, "0"); } } + +/** + * (from SMLIB 0.10.2) + * + * Returns a random, uniform Integer number in the specified (inclusive) range. + * This is safe to use multiple times in a function. + * The seed is set automatically for each plugin. + * Rewritten by MatthiasVance, thanks. + * + * @param min Min value used as lower border + * @param max Max value used as upper border + * @return Random Integer number between min and max + */ +#define SIZE_OF_INT 2147483647 // without 0 +stock Math_GetRandomInt(min, max) +{ + new random = GetURandomInt(); + + if (random == 0) { + random++; + } + + return RoundToCeil(float(random) / (float(SIZE_OF_INT) / float(max - min + 1))) + min - 1; +}