Item Rarity
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
pawn Код:
frandom(Float:max, Float:min = 0.0, dp = 4)
{
    new
        // Get the multiplication for storing fractional parts.
        Float:mul = floatpower(10.0, dp),
        // Get the max and min as integers, with extra dp.
        imin = floatround(min * mul),
        imax = floatround(max * mul);
    // Get a random int between two bounds and convert it to a float.
    return float(random(imax - imin) + imin) / mul;
}
You can use that as:

pawn Код:
new Float:rand = frandom(5.5); // Any float from 0.0 to 5.5 (up to 4 dp).
new Float:rand = frandom(5.5, -5.5); // Any float from -5.5 to 5.5 (up to 4 dp).
new Float:rand = frandom(5.5, 0.0, 1); // Any float from 0.0 to 5.5 (up to 1 dp).
new Float:rand = frandom(5.5, -5.5, 1); // Any float from -5.5 to 5.5 (up to 1 dp).
Source
Reply


Messages In This Thread
Item Rarity - by SeanDenZYR - 30.10.2018, 06:44
Re: Item Rarity - by Kane - 30.10.2018, 06:55
Re: Item Rarity - by SeanDenZYR - 30.10.2018, 12:45
Re: Item Rarity - by TheToretto - 30.10.2018, 12:57

Forum Jump:


Users browsing this thread: 1 Guest(s)