Help with the random function
#1

I have 63 cars and i want to make them go to these positions randomly, but i don't want them to fall in the same position at the same time, what should i do?

Here's some of the code

pawn Код:
new Position = random(63);
                switch(Position)
                {
                    case 0:
                    {
                        CarInfo[o][cLocationx] = 1656.5000000;
                        CarInfo[o][cLocationy] = -1080.3000488;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 1:
                    {
                        CarInfo[o][cLocationx] = 1649.3000488;
                        CarInfo[o][cLocationy] = -1080.0999756;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 2:
                    {
                        CarInfo[o][cLocationx] = 1656.5999756;
                        CarInfo[o][cLocationy] = -1084.5999756;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 3:
                    {
                        CarInfo[o][cLocationx] = 1649.1999512;
                        CarInfo[o][cLocationy] = -1084.5999756;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 4:
                    {
                        CarInfo[o][cLocationx] = 1656.5999756;
                        CarInfo[o][cLocationy] = -1088.9000244;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 5:
                    {
                        CarInfo[o][cLocationx] = 1649.3000488;
                        CarInfo[o][cLocationy] = -1089.0000000;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 6:
                    {
                        CarInfo[o][cLocationx] = 1673.0000000;
                        CarInfo[o][cLocationy] = -1083.0000000;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 7:
                    {
                        CarInfo[o][cLocationx] = 1620.0999756;
                        CarInfo[o][cLocationy] = -1079.6999512;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 8:
                    {
                        CarInfo[o][cLocationx] = 1656.4000244;
                        CarInfo[o][cLocationy] = -1107.0999756;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 9:
                    {
                        CarInfo[o][cLocationx] = 1649.1999512;
                        CarInfo[o][cLocationy] = -1107.0999756;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 10:
                    {
                        CarInfo[o][cLocationx] = 1656.5000000;
                        CarInfo[o][cLocationy] = -1111.4000244;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 11:
                    {
                        CarInfo[o][cLocationx] = 1649.4000244;
                        CarInfo[o][cLocationy] = -1111.4000244;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 12:
                    {
                        CarInfo[o][cLocationx] = 1649.2998047;
                        CarInfo[o][cLocationy] = -1093.6992188;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 13:
                    {
                        CarInfo[o][cLocationx] = 1620.0999756;
                        CarInfo[o][cLocationy] = -1085.1999512;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 14:
                    {
                        CarInfo[o][cLocationx] = 1620.0999756;
                        CarInfo[o][cLocationy] = -1089.6999512;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 15:
                    {
                        CarInfo[o][cLocationx] = 1620.0999756;
                        CarInfo[o][cLocationy] = -1094.1999512;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 16:
                    {
                        CarInfo[o][cLocationx] = 1620.1999512;
                        CarInfo[o][cLocationy] = -1098.5999756;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 17:
                    {
                        CarInfo[o][cLocationx] = 1629.5999756;
                        CarInfo[o][cLocationy] = -1103.0000000;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 270.0;
                    }
                    case 18:
                    {
                        CarInfo[o][cLocationx] = 1620.0999756;
                        CarInfo[o][cLocationy] = -1107.4000244;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 19:
                    {
                        CarInfo[o][cLocationx] = 1620.0996094;
                        CarInfo[o][cLocationy] = -1103.099609;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 20:
                    {
                        CarInfo[o][cLocationx] = 1629.5996094;
                        CarInfo[o][cLocationy] = -1107.5000000;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 270.0;
                    }
                    case 21:
                    {
                        CarInfo[o][cLocationx] =  1629.6999512;
                        CarInfo[o][cLocationy] = -1085.0000000;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 270.0;
                    }
                    case 22:
                    {
                        CarInfo[o][cLocationx] =  1629.5996094;
                        CarInfo[o][cLocationy] = -1098.5000000;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 270.0;
                    }
                    case 23:
                    {
                        CarInfo[o][cLocationx] =  1629.5996094;
                        CarInfo[o][cLocationy] = -1093.8994141;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 270.0;
                    }
                    case 24:
                    {
                        CarInfo[o][cLocationx] =  1629.5996094;
                        CarInfo[o][cLocationy] = -1089.5996094;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 270.0;
                    }
                    case 25:
                    {
                        CarInfo[o][cLocationx] = 1656.5000000;
                        CarInfo[o][cLocationy] = -1093.5000000;
                        CarInfo[o][cLocationz] = 23.7000008;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 26:
                    {
                        CarInfo[o][cLocationx] = 1672.9000244;
                        CarInfo[o][cLocationy] = -1079.1999512;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 27:
                    {
                        CarInfo[o][cLocationx] = 1672.9000244;
                        CarInfo[o][cLocationy] = -1086.5999756;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 28:
                    {
                        CarInfo[o][cLocationx] = 1673.0999756;
                        CarInfo[o][cLocationy] = -1090.0999756;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 29:
                    {
                        CarInfo[o][cLocationx] = 1683.0999756;
                        CarInfo[o][cLocationy] = -1129.4000244;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 30:
                    {
                        CarInfo[o][cLocationx] = 1673.0000000;
                        CarInfo[o][cLocationy] = -1093.6992188;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 31:
                    {
                        CarInfo[o][cLocationx] = 1679.0000000;
                        CarInfo[o][cLocationy] = -1129.4000244;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 32:
                    {
                        CarInfo[o][cLocationx] = 1670.5000000;
                        CarInfo[o][cLocationy] = -1129.4000244;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 33:
                    {
                        CarInfo[o][cLocationx] = 1674.8000488;
                        CarInfo[o][cLocationy] = -1129.3000488;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 34:
                    {
                        CarInfo[o][cLocationx] = 1682.9000244;
                        CarInfo[o][cLocationy] = -1121.3000488;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 35:
                    {
                        CarInfo[o][cLocationx] = 1678.9000244;
                        CarInfo[o][cLocationy] = -1121.5999756;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 36:
                    {
                        CarInfo[o][cLocationx] = 1674.8000488;
                        CarInfo[o][cLocationy] = -1122.099975;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 37:
                    {
                        CarInfo[o][cLocationx] = 1670.6999512;
                        CarInfo[o][cLocationy] = -1122.0999756;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 38:
                    {
                        CarInfo[o][cLocationx] = 1682.9000244;
                        CarInfo[o][cLocationy] = -1113.8000488;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 39:
                    {
                        CarInfo[o][cLocationx] = 1678.9000244;
                        CarInfo[o][cLocationy] = -1114.0999756;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 40:
                    {
                        CarInfo[o][cLocationx] = 1674.6999512;
                        CarInfo[o][cLocationy] = -1114.1999512;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 41:
                    {
                        CarInfo[o][cLocationx] = 1670.5999756;
                        CarInfo[o][cLocationy] = -1114.1999512;
                        CarInfo[o][cLocationz] = 29.6000004;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 42:
                    {
                        CarInfo[o][cLocationx] = 1680.1999512;
                        CarInfo[o][cLocationy] = -1114.1999512;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 43:
                    {
                        CarInfo[o][cLocationx] = 1680.4000244;
                        CarInfo[o][cLocationy] = -1122.0999756;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 44:
                    {
                        CarInfo[o][cLocationx] = 1680.1999512;
                        CarInfo[o][cLocationy] = -1118.1999512;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 45:
                    {
                        CarInfo[o][cLocationx] = 1680.4000244;
                        CarInfo[o][cLocationy] = -1126.0000000;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 46:
                    {
                        CarInfo[o][cLocationx] = 1680.5000000;
                        CarInfo[o][cLocationy] = -1130.1999512;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 47:
                    {
                        CarInfo[o][cLocationx] = 1672.8000488;
                        CarInfo[o][cLocationy] = -1118.5000000;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 48:
                    {
                        CarInfo[o][cLocationx] = 1672.5999756;
                        CarInfo[o][cLocationy] = -1114.4000244;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 49:
                    {
                        CarInfo[o][cLocationx] = 1673.0000000;
                        CarInfo[o][cLocationy] = -1122.0999756;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 50:
                    {
                        CarInfo[o][cLocationx] = 1673.0999756;
                        CarInfo[o][cLocationy] = -1126.0000000;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 51:
                    {
                        CarInfo[o][cLocationx] = 1673.1999512;
                        CarInfo[o][cLocationy] = -1130.0999756;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 52:
                    {
                        CarInfo[o][cLocationx] = 1665.4000244;
                        CarInfo[o][cLocationy] = -1127.4000244;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 53:
                    {
                        CarInfo[o][cLocationx] = 1665.5000000;
                        CarInfo[o][cLocationy] = -1113.6999512;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 54:
                    {
                        CarInfo[o][cLocationx] = 1665.5000000;
                        CarInfo[o][cLocationy] = -1120.3000488;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 0.0;
                    }
                    case 55:
                    {
                        CarInfo[o][cLocationx] = 1673.5999756;
                        CarInfo[o][cLocationy] = -1083.3000488;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 56:
                    {
                        CarInfo[o][cLocationx] = 1664.9000244;
                        CarInfo[o][cLocationy] = -1079.0999756;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 270.0;
                    }
                    case 57:
                    {
                        CarInfo[o][cLocationx] = 1650.4338;
                        CarInfo[o][cLocationy] = -1123.8925;
                        CarInfo[o][cLocationz] = 23.5782;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 58:
                    {
                        CarInfo[o][cLocationx] = 1673.5999756;
                        CarInfo[o][cLocationy] = -1087.1999512;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 59:
                    {
                        CarInfo[o][cLocationx] = 1673.5999756;
                        CarInfo[o][cLocationy] = -1090.9000244;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 60:
                    {
                        CarInfo[o][cLocationx] = 1673.3994141;
                        CarInfo[o][cLocationy] = -1079.3994141;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 90.0;
                    }
                    case 61:
                    {
                        CarInfo[o][cLocationx] = 1665.0999756;
                        CarInfo[o][cLocationy] = -1089.6999512;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 270.0;
                    }
                    case 62:
                    {
                        CarInfo[o][cLocationx] = 1665.0000000;
                        CarInfo[o][cLocationy] = -1082.6999512;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 270.0;
                    }
                    case 63:
                    {
                        CarInfo[o][cLocationx] = 1665.0999756;
                        CarInfo[o][cLocationy] = -1086.1999512;
                        CarInfo[o][cLocationz] = 24.0000000;
                        CarInfo[o][cAngle] = 270.0;
                    }
                }
Reply
#2

Do you want to use every item in the switch or only a few?
Reply
#3

I have 63 positions (car parking spots) and 63 cars, i want them to go on these spots randomly but only one at the same position, because the way i did sometimes 5 cars go on the same spot for example
Reply
#4

Starting to think that's not possible
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)