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



Problem with random - nuriel8833 - 04.01.2015

Im trying to make a random vehicle spawn , without helis and trailers and so on , but I have problem with random
Ive set it like this:
pawn Код:
randvc = random(212);
    switch(randvc)
    {
    case 17: finalv = 400+randvc-6; //
    case 25: finalv = 400+randvc-6; //
    case 30: finalv = 400+randvc-6; //
    case 32: finalv = 400+randvc-6; //
    case 35: finalv = 400+randvc-6; //
    case 46..47: finalv = 400+randvc-6; //
    case 49..50: finalv = 400+randvc-6; //
    case 52..54: finalv = 400+randvc-6; //
    case 60: finalv = 400+randvc-6; //
    case 64: finalv = 400+randvc-6; //
    case 69: finalv = 400+randvc-6; //
    case 72..73: finalv = 400+randvc-6; //
    case 76: finalv = 400+randvc-6; //
    case 84: finalv = 400+randvc-6; //
    case 87..88: finalv = 400+randvc-6; //
    case 93: finalv = 400+randvc-1; // //
    case 97: finalv = 400+randvc-6; //
    case 111..113: finalv = 400+randvc-6; //
    case 119: finalv = 400+randvc-1; // //
    case 120: finalv = 400+randvc-6; //
    case 137..138: finalv = 400+randvc-6; //
    case 148: finalv = 400+randvc-6; //
    case 153: finalv = 400+randvc-6; //
    case 163: finalv = 400+randvc-6; //
    case 169: finalv = 400+randvc-1; // //
    case 170: finalv = 400+randvc-6; //
    case 177: finalv = 400+randvc-6; //
    case 187:  finalv = 400+randvc-6; //
    case 190..191: finalv = 400+randvc-6; //
    case 192..193: finalv = 609; // // //
    case 195:  finalv = 400+randvc-6; //
    case 206..211: finalv = 400+randvc-6; //
    default: finalv = 400+randvc; }
as you can see removed all helis and trailers , but yet they keep spawn to me
What am I doing wrong with random?


Re: Problem with random - ATGOggy - 04.01.2015

Show AddStaticVehicle


Re: Problem with random - nuriel8833 - 04.01.2015

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
Show AddStaticVehicle
pawn Код:
CreateVehicle(finalv,x,y,z,a,rc1,rc2,-1);



Re: Problem with random - DavidBilla - 04.01.2015

Not sure what is wrong with the switch statement but instead of adding 400 in every case, do

randvc = 400+random(212);

And in each case,something like

case 17: finalv = randvc-6;


Re: Problem with random - ATGOggy - 04.01.2015

For what is that '-6'?

PHP код:
case 206..211finalv 400+randvc-6
That -6 is causing all problems.


Re: Problem with random - nuriel8833 - 04.01.2015

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
For what is that '-6'?

PHP код:
case 206..211finalv 400+randvc-6
That -6 is causing all problems.
Its complicated , to turn the banned vehicles into normal vehicles. If I put a number smaller than 6 some of them will turn to another banned vehicle


Re: Problem with random - ATGOggy - 04.01.2015

Quote:
Originally Posted by nuriel8833
Посмотреть сообщение
Its complicated , to turn the banned vehicles into normal vehicles. If I put a number smaller than 6 some of them will turn to another banned vehicle
Banned vehicle?


Re: Problem with random - ATGOggy - 04.01.2015

Go ingame and get the id of the heli or trailer that has spawned.


Re: Problem with random - ATGOggy - 04.01.2015

But still, there are some errors.
For example,
if ranvc=60,

finalv=400+60-6=454, which is a boat


Re: Problem with random - ATGOggy - 04.01.2015

2nd example,
if ranvc=93,

finalv=400+93-6=487, which is maverick