Problem with random
#1

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?
Reply
#2

Show AddStaticVehicle
Reply
#3

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

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;
Reply
#5

For what is that '-6'?

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

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
Reply
#7

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?
Reply
#8

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

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

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

2nd example,
if ranvc=93,

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


Forum Jump:


Users browsing this thread: 2 Guest(s)