SA-MP Forums Archive
Item Rarity - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Item Rarity (/showthread.php?tid=660297)



Item Rarity - SeanDenZYR - 30.10.2018

So i made this inventory system, and i made a command "/loot", and if he does /loot at a certain place, it gives him a random item, what i want is to have item rarity. Like, there is a 1 in X chance getting a sniper from /loot, how do i do this??


Re: Item Rarity - Kane - 30.10.2018

https://sampforum.blast.hk/showthread.php?tid=565233


Re: Item Rarity - SeanDenZYR - 30.10.2018

i can use floats in this right?


Re: Item Rarity - TheToretto - 30.10.2018

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