Selecting random vehicle with conditions -
m4karow - 10.02.2019
Hey there
I've making a new vehicle system that I have to implement to my mission system too.
What method do you recommend to select random vehicles for missions?
For example:
I use bitflags and there are some vehicles with flag TRAILERS.
How I can select random id from theese vehicles?
Thanks in advance
Re: Selecting random vehicle with conditions -
Mugala - 10.02.2019
dunno thing about bitflags, so is there a function in that bitflag which checks a vehicle if it's a trailer or not? for one vehicle.
Re: Selecting random vehicle with conditions -
m4karow - 11.02.2019
Quote:
Originally Posted by Mugala
dunno thing about bitflags, so is there a function in that bitflag which checks a vehicle if it's a trailer or not? for one vehicle.
|
Yes. if(GetVehicleFlag(vehicleid, VEHICLE_FLAG_TRAILER)) { ... }
Re: Selecting random vehicle with conditions -
m4karow - 11.02.2019
bump
Re: Selecting random vehicle with conditions -
TokicMajstor - 11.02.2019
Код:
new const Float:RandomCars[][] =
{
// Random ids here
{456}, // 0
{478}, // 1
{567}, // 2
}
Re: Selecting random vehicle with conditions -
Freaksken - 11.02.2019
Quote:
Originally Posted by TokicMajstor
Код:
new const Float:RandomCars[][] =
{
// Random ids here
{456}, // 0
{478}, // 1
{567}, // 2
}
|
Uhm, what's the second array dimension for? These are not strings, ...
Код:
new const RandomCars[] = {
456,
478,
567
};
Re: Selecting random vehicle with conditions -
TokicMajstor - 11.02.2019
Quote:
Originally Posted by Freaksken
Uhm, what's the second array dimension for? These are not strings, ...
Код:
new const Float:RandomCars[] = {
456,
478,
567
};
|
I was just typing fast like how he can do "random" but anyway thanks for that
Re: Selecting random vehicle with conditions -
DTV - 12.02.2019
Quote:
Originally Posted by Freaksken
Uhm, what's the second array dimension for? These are not strings, ...
Код:
new const Float:RandomCars[] = {
456,
478,
567
};
|
Don't forget that vehicle ids aren't floats either, so no need to specify it as a float value.
Re: Selecting random vehicle with conditions -
m4karow - 12.02.2019
Quote:
Originally Posted by ******
Is every trailer a valid target? Does every trailer have that flag set? And if so, could you use the model ID instead? Regardless, you could add them to an iterator when creating them and use Iter_Random. The other code is either totally hard coded to IDs, which is a bad idea, or merely selects a model, not an instance.
|
Model id will doesn't matter becouse I'll set other type of flags for the missions (Vehicles that the player have to tow, stole, etc)
It will be easier if I can add theese vehicles to an iterator but the problem is what I said before. I've only can add theese "Mission vehicles" to an iterator like MissionVehicles where it will be faster to loop throught. But I won't able to select a random id with conditions.
Re: Selecting random vehicle with conditions -
m4karow - 14.02.2019
bunp
Re: Selecting random vehicle with conditions -
m4karow - 14.02.2019
Quote:
Originally Posted by Y_Less
I think you need a two phase system then. Loop through once to count the number of valid vehicles, select a random number in that range, then loop through again until you hit that number.
|
So there’s no any method. Maybe this will be fine. Thanks for your help