SA-MP Forums Archive
How to check for a certain random choice - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to check for a certain random choice (/showthread.php?tid=175683)



How to check for a certain random choice - Jochemd - 10.09.2010

Hello,

As my topic title says: how to check for a certain random choice? I shall give an example:

pawn Код:
new EngineRandom[][] =
{
    {"* Engine started.", 1 },
    {"* Engine start failed.", 0 }
};
For example, I want to check if the engine is failed. How can I request that with if(engineresult == blabla) { ??

I'm sure one of you know!

Regards, Jochem


Re: How to check for a certain random choice - LarzI - 10.09.2010

pawn Код:
new rand = random(sizeof(EngineRandom));
//do something with it, e.g. EngineRandom[rand]
if(rand == 0)
// do stuff



Re: How to check for a certain random choice - Voldemort - 10.09.2010

pawn Код:
new EngineRandom[2][30] =
{
    { 1 ,"* Engine started."},
    { 0,"* Engine start failed." }
};
make for example
pawn Код:
new rand = random(sizeof(EngineRandom));

SendCientMessage(playerid,COLOR_YOURS,EngineRandom[rand][1]);
EngineOn[vehicleid] = EngineRandom[rand][0];



Re: How to check for a certain random choice - [03]Garsino - 10.09.2010

pawn Код:
switch(random(2))
{
    case 0: // Engine started
    case 1: // Engine start failed
}