SA-MP Forums Archive
Not getting the other case? - 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: Not getting the other case? (/showthread.php?tid=225642)



Not getting the other case? - Antonio [G-RP] - 14.02.2011

For some reason, I'm only getting case 0 (the first one) and never the second one.
Any ideas as to what's wrong?

pawn Код:
new route = random(2);
                    switch(route)
                    {
                        case 0:
                        {
                            GarbageRouteCount[playerid][0] = 1;
                            SetPlayerCheckpoint(playerid, GarbageRouteOne[0][0], GarbageRouteOne[0][1], GarbageRouteOne[0][2], 5.0);
                            SendClientMessage(playerid, COLOR_GREEN, "You have started your garbage route. Follow the checkpoints to recieve your pay.");
                        }
                        case 1:
                        {
                            GarbageRouteCount[playerid][1] = 1;
                            SetPlayerCheckpoint(playerid, GarbageRouteTwo[0][0], GarbageRouteTwo[0][1], GarbageRouteTwo[0][2], 5.0);
                            SendClientMessage(playerid, COLOR_GREEN, "You have started your garbage route. Follow the checkpoints to recieve your pay.");
                        }
                    }



Re: Not getting the other case? - cessil - 14.02.2011

it's random so maybe it's just your luck


Re: Not getting the other case? - Antonio [G-RP] - 14.02.2011

So there's no problem with the code? I just have horrible luck?


Re: Not getting the other case? - Krx17 - 14.02.2011

Yes. There is a 50/50 chance of getting 0 or 1 but your probability of getting 0 is probably 90%.


Re: Not getting the other case? - (SF)Noobanatior - 14.02.2011

try
pawn Код:
random(200)/100;



Re: Not getting the other case? - Mokerr - 14.02.2011

Ehm.. you think you always get No. 1 only... cause both are the same <.<


Re: Not getting the other case? - Antonio [G-RP] - 14.02.2011

Quote:
Originally Posted by Mokerr
Посмотреть сообщение
Ehm.. you think you always get No. 1 only... cause both are the same <.<
How are they the same?


Re: Not getting the other case? - cessil - 14.02.2011

Quote:
Originally Posted by (SF)Noobanatior
Посмотреть сообщение
try
pawn Код:
random(200)/100;
that's a terrible idea, that could return from 0 - 2 including 0.01, 0.02, 1.99 ect.


Re: Not getting the other case? - Mokerr - 15.02.2011

Quote:
Originally Posted by Antonio [G-RP]
Посмотреть сообщение
How are they the same?
Same message and checkpoints ;p


Re: Not getting the other case? - Antonio [G-RP] - 15.02.2011

Quote:
Originally Posted by Mokerr
Посмотреть сообщение
Same message and checkpoints ;p
Indeed, the message is the same, but the checkpoints are not.