Random place a player inside a car !
#1

Hi , i recently made a Destruction Derby event system, i placed the vehicles , but i don't know how to spawn a player in a random vehicle from the stadium, and how do i check if the vehicle is occupied and randomly choose another vehicle to spawn the player in ?

My Cars:
Код:
	new monster1 = AddStaticVehicle(556,-1487.2834,950.9165,1037.2406,329.6498,1,1); // new monster 1
	new monster2 = AddStaticVehicle(556,-1434.5646,1054.6820,1038.8766,186.4777,1,1); // new monster 2
	new monster3 = AddStaticVehicle(556,-1445.6870,1053.2595,1038.8702,193.2916,1,1); // new monster 3
	new monster4 = AddStaticVehicle(556,-1455.2585,1051.8297,1038.8619,203.5183,1,1); // new monster 4
	new monster5 = AddStaticVehicle(556,-1464.4065,1048.9934,1038.8264,199.5579,1,1); // new monster 5
	new monster6 = AddStaticVehicle(556,-1471.7252,1045.7449,1038.7938,205.0068,1,1); // new monster 6
	new monster7 = AddStaticVehicle(556,-1479.6780,1041.6841,1038.7393,210.8146,1,1); // new monster 7
	new monster8 = AddStaticVehicle(556,-1487.1262,1037.8427,1038.6899,214.1441,1,1); // new monster 8
	new monster9 = AddStaticVehicle(556,-1493.9911,1033.2174,1038.6193,220.7202,1,1); // new monster 9
	new monster10 = AddStaticVehicle(556,-1500.5416,1027.6339,1038.5398,228.9707,1,1); // new monster 10
	new monster11 = AddStaticVehicle(556,-1505.8550,1020.5541,1038.4330,235.2052,1,1); // new monster 11
	new monster12 = AddStaticVehicle(556,-1510.2365,1012.5750,1038.3030,249.1985,1,1); // new monster 12
	new monster13 = AddStaticVehicle(556,-1513.2988,1003.5381,1038.1536,262.4470,1,1); // new monster 13
	new monster14 = AddStaticVehicle(556,-1513.8561,994.5020,1038.0179,265.6848,1,1); // new monster 14
	new monster15 = AddStaticVehicle(556,-1512.9813,986.1722,1037.8756,279.7787,1,1); // new monster 15
	new monster16 = AddStaticVehicle(556,-1510.9250,978.2054,1037.7422,290.6392,1,1); // new monster 16
	new monster17 = AddStaticVehicle(556,-1364.8241,933.9618,1036.7202,2.1879,1,1); // new monster 17
	new monster18 = AddStaticVehicle(556,-1356.1315,934.7183,1036.7362,11.2091,1,1); // new monster 18
	new monster19 = AddStaticVehicle(556,-1347.1301,937.1570,1036.7678,11.8812,1,1); // new monster 19
	new monster20 = AddStaticVehicle(556,-1338.8893,939.2545,1036.7842,15.3560,1,1); // new monster 20
	new monster21 = AddStaticVehicle(556,-1506.6924,970.5514,1037.6045,308.8196,1,1); // new monster 21
	new monster22 = AddStaticVehicle(556,-1501.3098,962.8225,1037.4675,313.5175,1,1); // new monster 22
	new monster23 = AddStaticVehicle(556,-1494.6224,956.4545,1037.3469,323.3496,1,1); // new monster 23
	new monster24 = AddStaticVehicle(556,-1330.5907,942.7485,1036.8322,20.8564,1,1); // new monster 24
	new monster25 = AddStaticVehicle(556,-1424.5273,1056.2172,1038.8837,184.7005,0,0); // new monster 25
	new monster26 = AddStaticVehicle(556,-1415.1556,1056.6334,1038.8738,190.1941,0,0); // new monster 26
	new monster27 = AddStaticVehicle(556,-1405.2643,1056.7433,1038.8590,185.7466,0,0); // new monster 27
	new monster28 = AddStaticVehicle(556,-1394.1807,1056.6417,1038.8392,180.0487,0,0); // new monster 28
	new monster29 = AddStaticVehicle(556,-1384.3055,1056.3485,1038.8186,181.1962,0,0); // new monster 29
	new monster30 = AddStaticVehicle(556,-1374.1044,1056.0690,1038.8004,179.9128,0,0); // new monster 30
	new monster31 = AddStaticVehicle(556,-1363.4244,1055.9064,1038.7756,179.9718,0,0); // new monster 31
	new monster32 = AddStaticVehicle(556,-1351.6461,1054.6216,1038.7311,166.3265,0,0); // new monster 32
	new monster33 = AddStaticVehicle(556,-1342.0129,1051.2181,1038.6572,157.4926,0,0); // new monster 33
	new monster34 = AddStaticVehicle(556,-1332.0526,1048.0087,1038.5846,154.4410,0,0); // new monster 34
	new monster35 = AddStaticVehicle(556,-1322.5983,1044.5275,1038.5125,149.3387,0,0); // new monster 35
	new monster36 = AddStaticVehicle(556,-1312.4955,1038.7716,1038.3989,139.0898,0,0); // new monster 36
	new monster37 = AddStaticVehicle(556,-1303.4700,1032.1687,1038.2756,139.2335,0,0); // new monster 37
	new monster38 = AddStaticVehicle(556,-1295.5974,1024.3896,1038.1302,122.9784,0,0); // new monster 38
	new monster39 = AddStaticVehicle(556,-1288.0642,1014.3893,1037.9514,111.1427,0,0); // new monster 39
	new monster40 = AddStaticVehicle(556,-1284.6841,1004.9897,1037.7874,104.7939,0,0); // new monster 40
	new monster41 = AddStaticVehicle(556,-1284.0204,992.5182,1037.5972,86.3457,0,0); // new monster 41
	new monster42 = AddStaticVehicle(556,-1286.9839,983.1573,1037.4279,72.4064,0,0); // new monster 42
	new monster43 = AddStaticVehicle(556,-1291.3236,973.2066,1037.2782,63.7734,0,0); // new monster 43
	new monster44 = AddStaticVehicle(556,-1298.4490,963.3160,1037.1136,48.2695,0,0); // new monster 44
	new monster45 = AddStaticVehicle(556,-1305.3727,956.0112,1037.0059,40.7791,0,0); // new monster 45
	new monster46 = AddStaticVehicle(556,-1315.0153,951.2667,1036.9423,30.0717,0,0); // new monster 46
	new monster47 = AddStaticVehicle(556,-1323.7701,947.5381,1036.9025,21.4738,0,0); // new monster 47
	new monster48 = AddStaticVehicle(444,-1398.0476,993.9810,1024.4506,267.5878,1,1); // new monster Admini
Reply
#2

use : https://sampwiki.blast.hk/wiki/IsPlayerInVehicle
and if player is not inside, Spawn player there.
Reply
#3

Loop through all the online player (or the ones in the event or whatever) then check if they're NOT in a vehicle
[ !IsPlayerInVehicle(i) ] then just place them in an unoccupied vehicle. Should do the trick
Reply
#4

My god. Use an array!
Reply
#5

pawn Код:
new monster[47]; // creates an array with 47 cells
monster[0] = ...
monster[1] = ...


// then use
monster[random(47)] // as random id
Reply
#6

Thanks a lot
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)