Changing to another map
#28

Quote:
Originally Posted by gamer931215
View Post
Use a variable, like in this example:

pawn Code:
new bool:VehicleUsed[30];

//call this if you need a random id between 0/30
stock GetRandomVehicleID()
{
    for(new i = 0;i<30;i++)
    {
        if(!VehicleUsed[i])
        {
            VehicleUsed[i] = true;
            return i;
        }
    }
    return -1; //no vehicles left
}

//call this if youre changing your maps
stock ResetVehicles()
{
    for(new i = 0;i<30;i++)
    {
        VehicleUsed[i] = false;
    }
}
If your not always using 30 vehicles, then use a parameter to get the map like this:
pawn Code:
stock GetRandomVehicleID(map)
{
    switch(map)
    {
        case 0:
        {
            for(new i = 0;i<30;i++)
            {
                if(!VehicleUsed[i])
                {
                    VehicleUsed[i] = true;
                    return i;
                }
            }
        }
    }
    return -1; //no vehicles left
}
or just use the parameter to set the limit for the loop
So in stead off
pawn Code:
new rand1=random(30);
PutPlayerInVehicle(i, CarMap1[rand1], 0);
I have to use this:
pawn Code:
PutPlayerInVehicle(i,GetRandomVehicleID(1),0);//for map 1
Reply


Messages In This Thread
Changing to another map - by Michael@Belgium - 22.08.2011, 11:21
Re: Changing to another map ! *NEED HELP ASAP* - by [MWR]Blood - 22.08.2011, 11:27
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 22.08.2011, 11:29
Re: Changing to another map ! *NEED HELP ASAP* - by [MWR]Blood - 22.08.2011, 11:36
Re: Changing to another map ! *NEED HELP ASAP* - by Lenny the Cup - 22.08.2011, 11:46
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 22.08.2011, 12:57
Re: Changing to another map ! *NEED HELP ASAP* - by [MWR]Blood - 22.08.2011, 13:13
Re: Changing to another map ! *NEED HELP ASAP* - by Lenny the Cup - 22.08.2011, 14:09
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 22.08.2011, 15:23
Re: Changing to another map ! *NEED HELP ASAP* - by wups - 22.08.2011, 15:27
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 22.08.2011, 15:58
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 22.08.2011, 18:38
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 23.08.2011, 14:00
Re: Changing to another map ! *NEED HELP ASAP* - by Jochemd - 26.08.2011, 10:33
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 26.08.2011, 10:43
Re: Changing to another map ! *NEED HELP ASAP* - by Jochemd - 26.08.2011, 11:13
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 26.08.2011, 11:39
Re: Changing to another map ! *NEED HELP ASAP* - by Lorenc_ - 26.08.2011, 11:41
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 26.08.2011, 11:45
Re: Changing to another map ! *NEED HELP ASAP* - by Pinguinn - 26.08.2011, 11:51
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 26.08.2011, 12:06
Re: Changing to another map ! *NEED HELP ASAP* - by Pinguinn - 26.08.2011, 12:31
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 26.08.2011, 13:18
Re: Changing to another map ! *NEED HELP ASAP* - by Pinguinn - 26.08.2011, 14:02
Re: Changing to another map ! *NEED HELP ASAP* - by gamer931215 - 27.08.2011, 19:16
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 28.08.2011, 22:23
Re: Changing to another map ! *NEED HELP ASAP* - by gamer931215 - 28.08.2011, 22:38
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 29.08.2011, 11:04
Re: Changing to another map ! *NEED HELP ASAP* - by gamer931215 - 29.08.2011, 11:11
Re: Changing to another map ! *NEED HELP ASAP* - by Suraj - 15.09.2011, 01:54
Re: Changing to another map ! *NEED HELP ASAP* - by Michael@Belgium - 30.09.2011, 15:57

Forum Jump:


Users browsing this thread: 2 Guest(s)