SA-MP Forums Archive
Spawn random vehicles in loop - 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)
+--- Thread: Spawn random vehicles in loop (/showthread.php?tid=593944)



Spawn random vehicles in loop - cdoubleoper - 11.11.2015

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);
	}



Re: Spawn random vehicles in loop - Karan007 - 12.11.2015

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


Re: Spawn random vehicles in loop - Macluawn - 12.11.2015

Show us RandomVehicles array definition


Re: Spawn random vehicles in loop - [ABK]Antonio - 12.11.2015

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?


Re: Spawn random vehicles in loop - cdoubleoper - 12.11.2015

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.


Re: Spawn random vehicles in loop - AbyssMorgan - 12.11.2015

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); 



Re: Spawn random vehicles in loop - cdoubleoper - 12.11.2015

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!


Re: Spawn random vehicles in loop - Macluawn - 12.11.2015

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