Spawn random vehicles in loop
#1

Hello. There is some kinda issue that server is spawning about 80-89 vehicles(should be many more as u can see), different every server restart.
What may be the cause?

Код:
new RandomVehicleModels[91] = {
	400, 401, 402, 404, 405, 410, 411, 412, 413, 415, 418, 419, 421,
	424, 426, 429, 434, 436, 439, 445, 451, 461, 462, 463, 466, 467,
	458, 471, 474, 475, 477, 478, 479, 480, 481, 482, 483, 489, 491,
	492, 496, 500, 505, 506, 507, 509, 510, 516, 517, 518, 521, 526,
	527, 529, 533, 534, 535, 536, 540, 541, 542, 543, 545, 546, 547,
	549, 550, 551, 554, 555, 558, 559, 560, 561, 562, 565, 566, 567,
	568, 575, 576, 579, 580, 581, 585, 586, 587, 589, 600, 602, 603
};

 	new randomvehicle[238];
	for(new i = 0; i < 238; i++){
		randomvehicle[i] = CreateVehicle(RandomVehicleModels[random(91)], RandomVehicles[i][0], RandomVehicles[i][1], RandomVehicles[i][2], RandomVehicles[i][3], random(254), random(254), -1);
	}
Reply
#2

I think, you shouldn't add it to a loop. Remove the loop and test it.
Reply
#3

Show us RandomVehicles array definition
Reply
#4

Quote:
Originally Posted by cdoubleoper
Посмотреть сообщение
Hello. There is some kinda issue that server is spawning about 80-89 vehicles(should be many more as u can see), different every server restart.
What may be the cause?

Код:
new RandomVehicleModels[91] = {
	400, 401, 402, 404, 405, 410, 411, 412, 413, 415, 418, 419, 421,
	424, 426, 429, 434, 436, 439, 445, 451, 461, 462, 463, 466, 467,
	458, 471, 474, 475, 477, 478, 479, 480, 481, 482, 483, 489, 491,
	492, 496, 500, 505, 506, 507, 509, 510, 516, 517, 518, 521, 526,
	527, 529, 533, 534, 535, 536, 540, 541, 542, 543, 545, 546, 547,
	549, 550, 551, 554, 555, 558, 559, 560, 561, 562, 565, 566, 567,
	568, 575, 576, 579, 580, 581, 585, 586, 587, 589, 600, 602, 603
};

 	new randomvehicle[238];
	for(new i = 0; i < 238; i++){
		randomvehicle[i] = CreateVehicle(RandomVehicleModels[random(91)], RandomVehicles[i][0], RandomVehicles[i][1], RandomVehicles[i][2], RandomVehicles[i][3], random(254), random(254), -1);
	}
Are you reading that 80-89 from the amount of vehicle models or the actual amount of cars?
Reply
#5

Those are models that are supposed to be used by random function setting model id.
I have tried it without loop but the problem still occurs.
Reply
#6

PHP код:
randomvehicle[i] = CreateVehicle(RandomVehicleModels[random(sizeof(RandomVehicleModels))], RandomVehicles[i][0], RandomVehicles[i][1], RandomVehicles[i][2], RandomVehicles[i][3], random(254), random(254), -1); 
Reply
#7

It still seems be the same, logs like:
Код:
Number of vehicle models: 87
Number of vehicle models: 81
Number of vehicle models: 85
etc..
There are supposed to spawn more than 200 vehicles.


//edit:
Okay guys, I just recognized that amount of loaded vehicles is kinda messing around (that happens idk why), all vehicles are properly loaded in the game. Thanks everyone for help!
Reply
#8

Number of vehicle models is not the same as number of vehicles. The logs show the intended information.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)