· 7 years ago · Nov 12, 2018, 10:50 AM
1/*
2
3 Remove the comments on the MARMA logs if you want to log the spawns to MARMA.
4
5 The _uid variable MUST be changed to a valid UID that already exists in the account table.
6
7 How it works -
8
9 On server init, the script will count AllMissionObjects (X) on a per vehicle basis listed in the array below. If there is less than the defined amount the server will spawn a persistent vehicle with a random pin number
10 UNLOCKED at the defined or random road position.
11
12 This script can be used to replace the standard EXILE world vehicle spawns, so that the vehicles that are spawned are persistent. Players will not know the pin number, but its still a "benefit" to them as the vehicle they find
13 is persistent. And hey, they might just guess the number..
14
15 This script accounts for ALL vehicles, purchased or other wise. So if players have bought vehicles, and those vehicles exceed the maximum defined number in tbe below array, the server wont spawn anymore.
16
17 Configure the _vehicleArray below
18 Adjust the safePos parameters line 132 - 138
19
20*/
21
22uiSleep 30;
23
24diag_log ["ExileServer - Spawning persistent vehicle spawns"];
25//["ExileServer - Spawning world persistent vehicles"] call MAR_fnc_log;
26
27private ["_count","_uid","_debugForSP","_vehicle","_vehicleArray","_count","_vehicleClass","_position","_positionCount","_pinCode","_vehicleObject","_nearVehicles","_nearVechicleCount","_marker","_cancelSpawn","_isRandomRoadPos","_road","_scriptComplete"];
28
29_scriptComplete = false;
30_debugForSP = false; // If true , when the script is run in the editor it will create markers on the vehicle spawns.
31
32_uid = "1234"; // Needs to be a valid UID that exists in the account table (best to use a server owners uid)
33
34/*
35 How the vehicle array works -
36
37 Select 0 - Vehicle class name
38 Select 1 - Number - amount limit, will only maintain this many vehicles on the server
39 Select 2 - Array of positions EG [[0,0,0].[0,0,0]] - Will randomly select one of the positions per vehicle, if the position is occupied it will try for the other positions
40 Select 3 - Boolean - If true, will spawn the vehicle on a random road, if false, will look to the positions above.
41
42*/
43
44_vehicleArray =
45[
46 // Quads
47 ["Exile_Bike_QuadBike_Black",10,[],true],
48 ["Exile_Bike_QuadBike_Csat",10,[],true],
49 // Vans
50 ["Exile_Car_Van_Box_Black",10,[],true],
51 // Offroads
52 ["Exile_Car_Offroad_White",10,[],true],
53 ["Exile_Car_Offroad_Rusty10",10,[],true],
54 ["Exile_Car_Offroad_Armed_Guerilla010",10,[],true],
55 // Hatchbacks
56 ["Exile_Car_MB4WDOpen",10,[],true],
57 ["Exile_Car_MB4WD",10,[],true],
58 // Hatchback sports
59 ["Exile_Car_Hatchback_Sport_Red",10,[],true],
60 ["Exile_Car_ProwlerLight",10,[],true],
61 ["Exile_Car_ProwlerUnarmed",10,[],true],
62 // SUV
63 ["Exile_Car_QilinUnarmed",10,[],true],
64 ["Exile_Car_SUV_Black",10,[],true],
65 ["Exile_Car_SUV_Grey",10,[],true],
66 ["Exile_Car_SUV_Orange",10,[],true],
67 // Volha
68 ["Exile_Car_Volha_Blue",10,[],true],
69 ["Exile_Car_Volha_White",10,[],true],
70 ["Exile_Car_Volha_Black",10,[],true],
71 // Bus
72 ["Exile_Car_Ikarus_Blue",10,[],true],
73 // Zamak
74 ["Exile_Car_Zamak",10,[],true],
75 // Urals
76 ["Exile_Car_Ural_Covered_Blue",10,[],true],
77 ["Exile_Car_Ural_Covered_Yellow",10,[],true],
78 ["Exile_Car_Ural_Covered_Worker",10,[],true],
79 ["Exile_Car_Ural_Covered_Military",10,[],true],
80 // Land rovers
81 ["Exile_Car_LandRover_Red",10,[],true],
82 ["Exile_Car_LandRover_Urban",10,[],true],
83 ["Exile_Car_LandRover_Green",10,[],true],
84 ["Exile_Car_LandRover_Sand",10,[],true],
85 ["Exile_Car_LandRover_Desert",10,[],true],
86 //armored
87 ["O_APC_Tracked_010_AA_F",10,[],true],
88 ["O_MBT_010_cannon_F",10,[],true],
89 ["O_MBT_010_arty_F",10,[],true],
90 ["O_APC_Wheeled_010_rcws_F",10,[],true],
91 ["O_T_APC_Tracked_010_cannon_ghex_F",10,[],true],
92 ["O_T_APC_Tracked_010_AA_ghex_F",10,[],true],
93 ["O_T_APC_Wheeled_010_rcws_ghex_F",10,[],true],
94 ["O_T_MBT_010_cannon_ghex_F",10,[],true],
95 ["O_T_MBT_010_arty_ghex_F",10,[],true],
96 //car
97 ["O_MRAP_010_F",10,[],true],
98 ["O_MRAP_010_hmg_F",10,[],true],
99 ["O_MRAP_010_gmg_F",10,[],true],
100 ["O_G_Offroad_010_F",10,[],true],
101 ["O_G_Offroad_010_armed_F",10,[],true],
102 ["O_Quadbike_010_F",10,[],true],
103 ["O_G_Quadbike_010_F",10,[],true],
104 ["O_Truck_010_covered_F",10,[],true],
105 ["O_Truck_010_transport_F",10,[],true],
106 ["O_G_Van_010_transport_F",10,[],true],
107 ["O_Truck_010_transport_F",10,[],true],
108 ["O_Truck_010_covered_F",10,[],true],
109 ["O_Truck_010_device_F",10,[],true],
110 ["O_T_LSV_010_armed_F",10,[],true],
111 ["O_T_LSV_010_armed_viper_F",10,[],true],
112 ["O_T_LSV_010_unarmed_F",10,[],true],
113 ["O_T_LSV_010_unarmed_viper_F",10,[],true],
114 ["O_LSV_010_armed_F",10,[],true],
115 ["O_LSV_010_armed_viper_F",10,[],true],
116 ["O_LSV_010_unarmed_F",10,[],true],
117 ["O_LSV_010_unarmed_viper_F",10,[],true],
118 ["O_T_LSV_010_armed_black_F",10,[],true],
119 ["O_T_LSV_010_armed_ghex_F",10,[],true],
120 ["O_T_LSV_010_armed_arid_F",10,[],true],
121 ["O_T_LSV_010_unarmed_black_F",10,[],true],
122 ["O_T_LSV_010_unarmed_ghex_F",10,[],true],
123 ["O_T_LSV_010_unarmed_arid_F",10,[],true],
124 ["O_LSV_010_armed_black_F",10,[],true],
125 ["O_LSV_010_armed_ghex_F",10,[],true],
126 ["O_LSV_010_armed_arid_F",10,[],true],
127 ["O_LSV_010_unarmed_black_F",10,[],true],
128 ["O_LSV_010_unarmed_ghex_F",10,[],true],
129 ["O_LSV_010_unarmed_arid_F",10,[],true],
130 ["O_T_MRAP_010_ghex_F",10,[],true],
131 ["O_T_MRAP_010_hmg_ghex_F",10,[],true],
132 ["O_T_MRAP_010_gmg_ghex_F",10,[],true],
133 ["O_T_Quadbike_010_ghex_F",10,[],true],
134 ["O_T_Truck_010_transport_ghex_F",10,[],true],
135 ["O_T_Truck_010_covered_ghex_F",10,[],true],
136 ["O_T_Truck_010_device_ghex_F",10,[],true],
137 ["B_MRAP_010_F",10,[],true],
138 ["B_G_Offroad_010_armed_F",10,[],true],
139 ["B_G_Van_010_transport_F",10,[],true],
140 ["B_T_LSV_010_unarmed_F",10,[],true],
141 ["B_LSV_010_unarmed_F",10,[],true],
142 ["B_LSV_010_armed_black_F",10,[],true],
143 ["B_LSV_010_armed_olive_F",10,[],true],
144 ["B_LSV_010_unarmed_black_F",10,[],true],
145 ["B_LSV_010_unarmed_olive_F",10,[],true],
146 ["B_T_LSV_010_armed_black_F",10,[],true],
147 ["B_T_LSV_010_armed_olive_F",10,[],true],
148 ["B_T_LSV_010_unarmed_black_F",10,[],true],
149 ["B_T_LSV_010_unarmed_olive_F",10,[],true],
150 /*//truck
151 ["O_G_Offroad_010_repair_F",10,[[]],true],
152 ["O_Truck_010_box_F",10,[[]],true],
153 ["O_Truck_010_medical_F",10,[[]],true],
154 ["O_Truck_010_Ammo_F",10,[[]],true],
155 ["O_Truck_010_fuel_F",10,[[]],true],
156 ["O_G_Van_010_fuel_F",10,[[]],true],
157 ["O_Truck_010_repair_F",10,[[]],true],
158 ["O_Truck_010_ammo_F",10,[[]],true],
159 ["O_Truck_010_fuel_F",10,[[]],true],
160 ["O_Truck_010_medical_F",10,[[]],true],
161 ["Land_Pod_Heli_Transport_04_bench_F",10,[[]],true],
162 ["Land_Pod_Heli_Transport_04_covered_F",10,[[]],true],
163 ["Land_Pod_Heli_Transport_04_medevac_F",10,[[]],true],
164 ["Land_Pod_Heli_Transport_04_bench_black_F",10,[[]],true],
165 ["Land_Pod_Heli_Transport_04_covered_black_F",10,[[]],true],
166 ["Land_Pod_Heli_Transport_04_medevac_black_F",10,[[]],true],
167 ["O_T_Truck_010_repair_ghex_F",10,[[]],true],
168 ["O_T_Truck_010_ammo_ghex_F",10,[[]],true],
169 ["O_T_Truck_010_fuel_ghex_F",10,[[]],true],
170 ["O_T_Truck_010_medical_ghex_F",10,[[]],true],
171 //Choppers
172 ["RHS_AH10Z",10,[[]],true],
173 ["RHS_AH64D",10,[[]],true],
174 ["RHS_CH_47F",10,[[]],true],
175 ["RHS_UH10Y",10,[[]],true],
176 ["RHS_UH60M",10,[[]],true],
177 ["RHS_UH60M_MEV",10,[[]],true],
178 ["rhsusf_CH510E_USMC",10,[[]],true],
179 ["O_Heli_Light_010_unarmed_F",10,[[]],true],
180 ["O_Heli_Transport_04_covered_black_F",10,[[]],true],
181 ["O_T_VTOL_010_infantry_F",10,[[]],true],
182 ["O_T_VTOL_010_vehicle_F",10,[[]],true],
183 ["O_T_VTOL_010_infantry_hex_F",10,[[]],true],
184 ["O_T_VTOL_010_infantry_ghex_F",10,[[]],true],
185 ["O_T_VTOL_010_infantry_grey_F",10,[[]],true],
186 ["O_T_VTOL_010_vehicle_hex_F",10,[[]],true],
187 ["O_T_VTOL_010_vehicle_ghex_F",10,[[]],true],
188 ["O_T_VTOL_010_vehicle_grey_F",10,[[]],true],
189 ["B_Heli_Light_010_F",10,[[]],true],
190 ["B_Heli_Transport_010_F",10,[[]],true],
191 ["B_Heli_Transport_010_camo_F",10,[[]],true],
192 ["B_Heli_Transport_010_unarmed_F",10,[[]],true],
193 ["B_Heli_Transport_010_unarmed_green_F",10,[[]],true],
194 ["B_CTRG_Heli_Transport_010_sand_F",10,[[]],true],
195 ["B_CTRG_Heli_Transport_010_tropic_F",10,[[]],true],
196 ["B_T_VTOL_010_infantry_F",10,[[]],true],
197 ["B_T_VTOL_010_vehicle_F",10,[[]],true],
198 //Wheeled Vehicle
199 ["rhsusf_M1078A10P10_B_M10_d_fmtv_usarmy",10,[[]],true],
200 ["rhsusf_M1078A10P10_B_M10_wd_fmtv_usarmy",10,[[]],true],
201 ["rhsusf_M1078A10P10_B_d_fmtv_usarmy",10,[[]],true],
202 ["rhsusf_M1078A10P10_B_wd_fmtv_usarmy",10,[[]],true],
203 ["rhsusf_M1078A10P10_d_fmtv_usarmy",10,[[]],true],
204 ["rhsusf_M1078A10P10_wd_fmtv_usarmy",10,[[]],true],
205 ["rhsusf_M10810A10P10_B_M10_d_MHQ_fmtv_usarmy",10,[[]],true],
206 ["rhsusf_M10810A10P10_B_M10_d_fmtv_usarmy",10,[[]],true],
207 ["rhsusf_M10810A10P10_B_M10_wd_fmtv_usarmy",10,[[]],true],
208 ["rhsusf_M10810A10P10_B_d_fmtv_usarmy",10,[[]],true],
209 ["rhsusf_M10810A10P10_B_wd_fmtv_usarmy",10,[[]],true],
210 ["rhsusf_M10810A10P10_d_fmtv_usarmy",10,[[]],true],
211 ["rhsusf_M10810A10P10_wd_fmtv_usarmy",10,[[]],true],
212 ["rhsusf_m10105_w",10,[[]],true],
213 ["rhsusf_m10105_w_m10",10,[[]],true],
214 ["rhsusf_m10105_w_mk109",10,[[]],true],
215 ["rhsusf_m998_w_10dr",10,[[]],true],
216 ["rhsusf_m998_w_4dr",10,[[]],true],
217 ["rhsusf_rg1010_d",10,[[]],true],
218 ["rhsusf_rg1010_m10_d",10,[[]],true],
219 ["RHS_M10A10",10,[[]],true],
220 ["RHS_M10A10_BUSKI",10,[[]],true],
221 ["RHS_M10A10",10,[[]],true],
222 ["RHS_M10A10_BUSKI",10,[[]],true],
223 ["RHS_M10A10_BUSKIII",10,[[]],true],
224 ["rhsusf_m109_usarmy",10,[[]],true],
225 ["rhsusf_m109d_usarmy",10,[[]],true],
226 ["rhsusf_m101010_usarmy",10,[[]],true],
227 ["rhsusf_m101010_usarmy_M1040",10,[[]],true],
228 ["rhsusf_m101010_usarmy_MK109",10,[[]],true],
229 ["rhsusf_m101010_usarmy_medical",10,[[]],true],
230 ["rhsusf_m101010_usarmy_supply",10,[[]],true],
231 ["rhsusf_m101010_usarmy_unarmed",10,[[]],true],
232 ["rhsusf_m101010d_usarmy",10,[[]],true],
233 ["rhsusf_m101010d_usarmy_M1040",10,[[]],true],
234 ["rhsusf_m101010d_usarmy_MK109",10,[[]],true],
235 ["rhsusf_m101010d_usarmy_medical",10,[[]],true],
236 ["rhsusf_m101010d_usarmy_supply",10,[[]],true],
237 ["rhsusf_m101010d_usarmy_unarmed",10,[[]],true],
238 ["rhsusf_m10a10aim_tuski_d",10,[[]],true],
239 ["rhsusf_m10a10aim_tuski_wd",10,[[]],true],
240 ["rhsusf_m10a10aimd_usarmy",10,[[]],true],
241 ["rhsusf_m10a10aimwd_usarmy",10,[[]],true],
242 ["rhsusf_m10a10fep_d",10,[[]],true],
243 ["rhsusf_m10a10fep_od",10,[[]],true],
244 ["rhsusf_m10a10fep_wd",10,[[]],true],
245 ["rhsusf_m10a10sep10d_usarmy",10,[[]],true],
246 ["rhsusf_m10a10sep10tuskid_usarmy",10,[[]],true],
247 ["rhsusf_m10a10sep10tuskiid_usarmy",10,[[]],true],
248 ["rhsusf_m10a10sep10tuskiiwd_usarmy",10,[[]],true],
249 ["rhsusf_m10a10sep10tuskiwd_usarmy",10,[[]],true],
250 ["rhsusf_m10a10sep10wd_usarmy",10,[[]],true],
251 // Choppers
252 /*
253 ["Exile_Chopper_Hellcat_Green",1,[[23483.9,21144.8,0],[25240.1,21828.6,0]],false],
254 ["Exile_Chopper_Hummingbird_Green",1,[[12834.2,16735.8,0],[23079.8,7299.1,0]],false],
255 ["Exile_Chopper_Mohawk_FIA",1,[[17550.5,13240.5,0],[26783.6,24673,0]],false],
256 ["Exile_Chopper_Orca_CSAT",1,[[3732.07,12976.3,20]],false]*/
257];
258
259{
260 for "_i" from 0 to (_x select 1) do
261 {
262 _cancelSpawn = false;
263 _obj = _x select 0;
264 _count = count allMissionObjects _obj;
265 _positionCount = (count (_x select 2));
266 _isRandomRoadPos = _x select 3;
267
268 if !(_count >= _x select 1) then
269 {
270 _vehicleClass = _x select 0;
271 _position = selectRandom (_x select 2);
272
273 if !(_isRandomRoadPos) then
274 {
275 _foundSafePos = false;
276 _failSafe = 15;
277 _checks = 0;
278 waitUntil
279 {
280 _position = selectRandom (_x select 2);
281 _nearVehicles = nearestObjects [_position, ["car","air"], 10];
282 _nearVechicleCount = count _nearVehicles;
283 if (_nearVechicleCount == 0) then
284 {
285 _foundSafePos = true;
286 };
287 _checks = _checks + 1;
288 if (_checks >= _failSafe) then {_cancelSpawn = true; _foundSafePos = true;};
289 _foundSafePos
290 };
291 }
292 else
293 {
294 _foundSafePos = false;
295 waitUntil
296 {
297 _spawnCenter = getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition"); //Center of your map
298 _min = 15; // minimum distance from the center position (Number) in meters
299 _max = 30000; // maximum distance from the center position (Number) in meters
300 _mindist = 5; // minimum distance from the nearest object (Number) in meters, ie. spawn at least this distance away from anything within x meters..
301 _water = 0; // water mode 0: cannot be in water , 1: can either be in water or not , 2: must be in water
302 _shoremode = 0; // 0: does not have to be at a shore , 1: must be at a shore
303 _blackList = [[[0, 0],[0,0]]];
304
305 _startPosRoad = [_spawnCenter,_min,_max,_mindist,_water,10,_shoremode,_blackList] call BIS_fnc_findSafePos; //Find random spot on the map
306 _onRoadCheck = _startPosRoad nearRoads 100; //Find road objects 100m from spot
307 _countPossibleRoads = count _onRoadCheck; // count road objects
308
309 if (_countPossibleRoads == 0) then
310 {
311 }
312 else
313 {
314 _road = _onRoadCheck select 0;
315 _position = getPos _road;
316 _foundSafePos = true;
317 };
318 uiSleep 0.1;
319 _foundSafePos
320 };
321 };
322 if !(_cancelSpawn) then
323 {
324 if !(_debugForSP) then
325 {
326 _pinCode = format ["%1%2%3%4",round (random 8 +1),round (random 8 +1),round (random 8 +1),round (random 8 +1)];
327 _vehicleObject = [_vehicleClass, _position, (random 360), true,_pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
328 _vehicleObject setDamage 0.8;
329 _vehicleObject setFuel 0;
330
331 if !((_x select 0) isKindOf "AIR") then
332 {
333 _wheels = ["HitLF2Wheel","HitLFWheel","HitRFWheel","HitRF2Wheel"];
334 {
335 if (random 1 > 0.5) then
336 {
337 _vehicleObject setHitPointDamage [_x,1];
338 };
339 } forEach _wheels;
340 };
341 _vehicleObject setVariable ["ExileOwnerUID", _uid];
342 _vehicleObject setVariable ["ExileIsLocked",0];
343 _vehicleObject lock 0;
344 _vehicleObject call ExileServer_object_vehicle_database_insert;
345 _vehicleObject call ExileServer_object_vehicle_database_update;
346
347 diag_log format ["[Event: Persistent Spawns] -- Spawned a %1 at location: %2 -- Max allowed: %3",_x select 0,_position, _x select 1];
348 //[format["[Event: Persistent Spawns] -- Spawned a %1 at location: %2 -- Max allowed: %3",_x select 0,_position, _x select 1]] call MAR_fnc_log;
349 }
350 else
351 {
352 _vehicleObject = createVehicle [_vehicleClass,_position,[], 0, "NONE"];
353
354 if !((_x select 0) isKindOf "AIR") then
355 {
356 _wheels = ["HitLF2Wheel","HitLFWheel","HitRFWheel","HitRF2Wheel"];
357 {
358 _vehicleObject setHitPointDamage [_x,1];
359 } forEach _wheels;
360 };
361
362 _marker = createMarker [format["HeliCrash%1", diag_tickTime], _position];
363 _marker setMarkerType "mil_dot";
364 _marker setMarkerText "Vehicle";
365 };
366 }
367 else
368 {
369 if !(_debugForSP) then
370 {
371 //[format["[Event: Persistent Spawns] -- Could not find valid spawn position for %1 at position %2 -- exiting try for this vehicle",_x select 0,_position]] call MAR_fnc_log;
372 diag_log format["[Event: Persistent Spawns] -- Could not find valid spawn position for %1 at position %2 -- exiting try for this vehicle",_x select 0,_position];
373 }
374 else
375 {
376 hint format["[Event: Persistent Spawns] -- Could not find valid spawn position for %1 at position %2 -- exiting try for this vehicle",_x select 0,_position];
377 };
378 };
379 };
380 };
381
382} forEach _vehicleArray;
383
384_scriptComplete = true;
385
386waitUntil
387{
388 diag_log format ["ExileServer - Finished spawning world vehicles"];
389 //["ExileServer - Finished spawning world vehicles"] call MAR_fnc_log;
390 _scriptComplete
391};