SA-MP Forums Archive
Random route - 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: Random route (/showthread.php?tid=263250)



Random route - ajwar - 21.06.2011

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}

};



Re: Random route - Lorenc_ - 21.06.2011

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...