SA-MP Forums Archive
random - 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: random (/showthread.php?tid=507574)



random - Dziugsas - 18.04.2014

Hello guys!


Apearently i can't do this:
pawn Код:
randomEx(6,4,16,18,10,17);
So how i can choose random number ,but only from that numbers which i selected?

Like not from 1 to 5 ,but 16 or 17 or 2 or 5 and etc...


Re: random - Conradus - 18.04.2014

Код:
new randomNumbers[6] = {6,4,16,18,10,17};
new rand = randomEx(0, 5);

new myrandomnumber = randomNumbers[rand];



Re: random - Dziugsas - 18.04.2014

How could i import your script to mine's?

pawn Код:
BusinessInfo[id][bInsideInt] = randomINT;
    randomINT = randomEx(6,4,16,18,10,17);
    if(randomINT == 6)
    {
        BusinessInfo[id][bExitX] = -26.691598;
        BusinessInfo[id][bExitY] = -55.714897;
        BusinessInfo[id][bExitZ] = 1003.546875;
    }
    if(randomINT == 4)
    {
        BusinessInfo[id][bExitX] = -27.312299;
        BusinessInfo[id][bExitY] = -29.277599;
        BusinessInfo[id][bExitZ] = 1003.557250;
    }
    if(randomINT == 16)
    {
        BusinessInfo[id][bExitX] = -25.132598;
        BusinessInfo[id][bExitY] = -139.066986;
        BusinessInfo[id][bExitZ] = 1003.546875;
    }
    if(randomINT == 18)
    {
        BusinessInfo[id][bExitX] = -30.946699;
        BusinessInfo[id][bExitY] = -89.609596;
        BusinessInfo[id][bExitZ] = 1003.546875;
    }
    if(randomINT == 10)
    {
        BusinessInfo[id][bExitX] = 6.091179;
        BusinessInfo[id][bExitY] = -29.271898;
        BusinessInfo[id][bExitZ] = 1003.549438;
    }
    if(randomINT == 18)
    {
        BusinessInfo[id][bExitX] = -25.884498;
        BusinessInfo[id][bExitY] = -185.868988;
        BusinessInfo[id][bExitZ] = 1003.546875;
    }



Re: random - RajatPawar - 18.04.2014

EDIT: Late, still valid?

pawn Код:
randomFromSet(...)
     return getarg(random(numargs()));
You can use any number of arguments you want.


Re: random - Vince - 18.04.2014

This really tiny function should work;
pawn Код:
randomSelective(...)
    return getarg(random(numargs()));
Edit: Damn, I'm slow.


Re: random - Dziugsas - 18.04.2014

Can you guys try to integrate your scripts to mine's?
I'm beginner...