Random route
#1

Is it possible to choose randomly DriverRoute3 or DriverRoute2 DriverRoute1? I want to choose one of those three in random way:

pawn Код:
new Float:DriverRoute3[][3] =
{
    // Positions, (X, Y, Z and Facing Angle)
    {-2584.7021,309.9371,5.1650},
    {-2559.8579,196.9890,6.6660},
    {-2539.8284,-75.2840,16.7041},
    {-2489.6602,91.1577,25.7453},
    {-2457.0125,138.0177,35.1633},
    {-2154.9475,495.9309,35.3191}

};
new Float:DriverRoute4[][3] =
{
    // Positions, (X, Y, Z and Facing Angle)
    {-2584.7021,309.9371,5.1650},
    {-2559.8579,196.9890,6.6660},
    {-2539.8284,-75.2840,16.7041},
    {-2489.6602,91.1577,25.7453},
    {-2457.0125,138.0177,35.1633},
    {-2154.9475,495.9309,35.3191}

};
new Float:DriverRoute5[][3] =
{
    // Positions, (X, Y, Z and Facing Angle)
    {-2584.7021,309.9371,5.1650},
    {-2559.8579,196.9890,6.6660},
    {-2539.8284,-75.2840,16.7041},
    {-2489.6602,91.1577,25.7453},
    {-2457.0125,138.0177,35.1633},
    {-2154.9475,495.9309,35.3191}

};
Reply
#2

pawn Код:
stock RandomRoute()
{
    switch(random(3))
    {
        case 0: return DriverRoute3[random(sizeof(DriverRoute3))][3];
        case 1: return DriverRoute4[random(sizeof(DriverRoute4))][3];
        case 2: return DriverRoute5[random(sizeof(DriverRoute5))][3];
    }
    return -1;
}
This?
Untested...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)