· 6 years ago · Mar 31, 2019, 09:12 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 = "76561198079956410"; // 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 ["Exile_Bike_QuadBike_Black",2,[],true],
47 ["Exile_Bike_QuadBike_Csat",2,[],true],
48 //Vans
49 ["Exile_Car_Van_Box_Black",2,[],true],
50 //Offroads
51 ["Exile_Car_Offroad_White",2,[],true],
52 //["Exile_Car_Offroad_Rusty",2,[],true],
53 //["Exile_Car_Offroad_Armed_Guerilla",2,[],true],
54 //Hatchbacks
55 ["Exile_Car_MB4WDOpen",2,[],true],
56 ["Exile_Car_MB4WD",2,[],true],
57 //Hatchback sports
58 ["Exile_Car_Hatchback_Sport_Red",2,[],true],
59 ["Exile_Car_ProwlerLight",2,[],true],
60 ["Exile_Car_ProwlerUnarmed",2,[],true],
61 //SUV
62 ["Exile_Car_QilinUnarmed",2,[],true],
63 ["Exile_Car_SUV_Black",2,[],true],
64 ["Exile_Car_SUV_Grey",2,[],true],
65 ["Exile_Car_SUV_Orange",2,[],true],
66 //Volha
67 ["Exile_Car_Volha_Blue",2,[],true],
68 ["Exile_Car_Volha_White",2,[],true],
69 ["Exile_Car_Volha_Black",2,[],true],
70 // Bus
71 ["Exile_Car_Ikarus_Blue",2,[],true],
72 // Zamak
73 ["Exile_Car_Zamak",2,[],true],
74 // Urals
75 ["Exile_Car_Ural_Covered_Blue",2,[],true],
76 ["Exile_Car_Ural_Covered_Yellow",2,[],true],
77 ["Exile_Car_Ural_Covered_Worker",2,[],true],
78 ["Exile_Car_Ural_Covered_Military",2,[],true],
79 // Land rovers
80 ["Exile_Car_LandRover_Red",2,[],true],
81 ["Exile_Car_LandRover_Urban",2,[],true],
82 ["Exile_Car_LandRover_Green",2,[],true],
83 ["Exile_Car_LandRover_Sand",2,[],true],
84 ["Exile_Car_LandRover_Desert",2,[],true],
85 //armored
86 ["B_APC_Tracked_02_AA_F",2,[],true],
87 ["B_APC_Tracked_02_CRV_F",2,[],true],
88 ["B_APC_Tracked_02_rcws_F",2,[],true],
89 ["B_MBT_02_TUSK_F",2,[],true],
90 ["B_MBT_02_arty_F",2,[],true],
91 ["B_MBT_02_cannon_F",2,[],true],
92 ["B_MBT_02_mlrs_F",2,[],true],
93 ["I_APC_tracked_02_cannon_F",2,[],true],
94 ["I_MBT_02_cannon_F",2,[],true],
95 ["O_APC_Tracked_02_AA_F",2,[],true],
96 ["O_APC_Tracked_02_cannon_F",2,[],true],
97 ["O_APC_Wheeled_02_rcws_F",2,[],true],
98 ["O_APC_Wheeled_02_rcws_v2_F",2,[],true],
99 ["B_APC_Wheeled_02_cannon_F",2,[],true],
100 ["O_MBT_02_arty_F",2,[],true],
101 ["O_MBT_02_cannon_F",2,[],true],
102 //car
103 ["B_MRAP_02_F",2,[],true],
104 ["B_MRAP_02_hmg_F",2,[],true],
105 ["B_MRAP_02_gmg_F",2,[],true],
106 ["O_G_Offroad_02_F",2,[],true],
107 ["O_G_Offroad_02_armed_F",2,[],true],
108 ["O_Quadbike_02_F",2,[],true],
109 ["O_G_Quadbike_02_F",2,[],true],
110 ["B_Truck_02_covered_F",2,[],true],
111 ["B_Truck_02_transport_F",2,[],true],
112 ["O_G_Van_02_transport_F",2,[],true],
113 ["B_T_MRAP_02_hmg_F",2,[],true],
114 ["O_T_MRAP_02_hmg_ghex_F",2,[],true],
115 ["O_T_MRAP_02_gmg_ghex_F",2,[],true],
116 ["C_Quadbike_02_black_F",2,[],true],
117 ["O_Truck_02_transport_F",2,[],true],
118 ["O_Truck_02_covered_F",2,[],true],
119 ["O_Truck_02_device_F",2,[],true],
120 ["B_G_Offroad_02_armed_F",2,[],true],
121 ["B_G_Van_02_transport_F",2,[],true],
122 ///truck
123 ["O_G_Offroad_02_repair_F",2,[],true],
124 ["B_T_Truck_02_box_F",2,[],true],
125 ["B_T_Truck_02_medical_F",2,[],true],
126 ["O_G_Van_02_fuel_F",2,[],true],
127 ["B_Truck_02_Repair_F",2,[],true],
128 ["B_T_Truck_02_fuel_F",2,[],true],
129 ["B_Truck_02_medical_F",2,[],true],
130 //Choppers
131 ["RHS_AH2Z",2,[],true],
132 ["RHS_AH64D",2,[],true],
133 ["RHS_CH_47F",2,[],true],
134 ["RHS_UH2Y",2,[],true],
135 ["RHS_UH60M",2,[],true],
136 ["RHS_UH60M_MEV",2,[],true],
137 ["RHS_CH_47F",2,[],true],
138 ["O_Heli_Light_02_dynamicLoadout_F",2,[],true],
139 ["O_Heli_Transport_04_covered_black_F",2,[],true],
140 ["B_Heli_Light_02_F",2,[],true],
141 ["B_Heli_Transport_02_F",2,[],true],
142 ["B_Heli_Transport_02_camo_F",2,[],true],
143 ["B_Heli_Transport_02_camo_F",2,[],true],
144 ["I_Heli_light_02_dynamicLoadout_F",2,[],true],
145 ["B_Heli_Transport_02_unarmed_green_F",2,[],true],
146 ["B_Heli_Transport_02_unarmed_F",2,[],true],
147 ["B_T_VTOL_02_armed_F",2,[],true],
148 ["O_T_VTOL_02_vehicle_ghex_F",2,[],true],
149 //Wheeled Vehicle
150 ["rhsusf_M2078A2P2_B_M2_WD_fmtv_usarmy",2,[],true],
151 ["rhsusf_M2078A2P2_B_d_fmtv_usarmy",2,[],true],
152 ["rhsusf_M2078A2P2_B_wd_fmtv_usarmy",2,[],true],
153 ["rhsusf_M2078A2P2_d_fmtv_usarmy",2,[],true],
154 ["rhsusf_M2082A2P2_B_M2_D_fmtv_usarmy",2,[],true],
155 ["rhsusf_M2082A2P2_B_M2_wd_fmtv_usarmy",2,[],true],
156 ["rhsusf_M2082A2P2_B_D_fmtv_usarmy",2,[],true],
157 ["rhsusf_M2084A2P2_D_fmtv_usarmy",2,[],true],
158 ["rhsusf_M2084A2P2_WD_fmtv_usarmy",2,[],true],
159 ["rhsusf_m2025_w_mk29",2,[],true],
160 ["rhsusf_m998_w_2dr",2,[],true],
161 ["rhsusf_m998_w_4dr",2,[],true],
162 ["rhsusf_rg22_d",2,[],true],
163 ["rhsusf_rg22_m2_wd",2,[],true],
164 ["RHS_M2A2",2,[],true],
165 ["RHS_M2A2_BUSKI",2,[],true],
166 ["rhsusf_m209_usarmy",2,[],true],
167 ["rhsusf_m209d_usarmy",2,[],true],
168 ["rhsusf_m222_usarmy_M240",2,[],true],
169 ["rhsusf_m222_usarmy_MK29",2,[],true],
170 ["rhsusf_m222d_usarmy_medical",2,[],true],
171 ["rhsusf_m222_usarmy_supply",2,[],true],
172 ["rhsusf_m222_usarmy_unarmed",2,[],true],
173 ["rhsusf_m222d_usarmy",2,[],true],
174 ["rhsusf_m222d_usarmy_M240",2,[],true],
175 ["rhsusf_m222d_usarmy_MK29",2,[],true],
176 ["rhsusf_m222d_usarmy_medical",2,[],true],
177 ["rhsusf_m222d_usarmy_supply",2,[],true],
178 ["rhsusf_m222d_usarmy_unarmed",2,[],true],
179 ["rhsusf_m2a2aim_tuski_d",2,[],true],
180 ["rhsusf_m2a2aim_tuski_wd",2,[],true],
181 ["rhsusf_m2a2aimd_usarmy",2,[],true],
182 ["rhsusf_m2a2sep2tuskiwd_usarmy",2,[],true],
183 ["rhsusf_m2a2fep_d",2,[],true],
184 ["rhsusf_m2a2fep_od",2,[],true],
185 ["rhsusf_m2a2fep_wd",2,[],true],
186 ["rhsusf_m2a2sep2d_usarmy",2,[],true],
187 ["rhsusf_m2a2sep2tuskid_usarmy",2,[],true],
188 ["rhsusf_m2a2sep2tuskiid_usarmy",2,[],true],
189 ["rhsusf_m2a2sep2tuskiiwd_usarmy",2,[],true],
190 ["rhsusf_m2a2sep2tuskiwd_usarmy",2,[],true],
191 ["rhsusf_m2a2sep2wd_usarmy",2,[],true],
192 //fox
193 ["Fox_Pickup_6S",2,[],true],
194 ["Fox_Pickup_Tow",2,[],true],
195 ["Fox_Pickup_Apocalypse",2,[],true],
196 ["Fox_Charger_Apocalypse",2,[],true],
197 ["Fox_Tahoe_Apocalypse",2,[],true],
198 ["Fox_F40",2,[],true],
199 ["Fox_Viper",2,[],true],
200 ["Fox_GNX",2,[],true],
201 ["Fox_Outsider",2,[],true],
202 ["Fox_Landrover",2,[],true],
203 ["Fox_Landrover2",2,[],true],
204 ["Fox_Interceptor",2,[],true],
205 ["Fox_DaytonaStratos",2,[],true],
206 ["Fox_DaytonaGeneral",2,[],true],
207 ["Fox_Daytona",2,[],true],
208 ["Fox_ChallengerBR",2,[],true],
209 ["Fox_ChallengerDev",2,[],true],
210 ["Fox_ChallengerDev2",2,[],true],
211 ["Fox_ChallengerYB",2,[],true],
212 ["Fox_ChallengerO",2,[],true],
213 ["Fox_ChallengerW",2,[],true],
214 ["Fox_LandCruiserFox",2,[],true],
215 ["Fox_LandCruiser2",2,[],true],
216 ["Fox_LandCruiser2",2,[],true],
217 ["Fox_LandCruiser",2,[],true],
218 ["Fox_Patrol",2,[],true],
219 ["Fox_Patrol2",2,[],true],
220 ["Fox_Patrol2",2,[],true],
221 ["Fox_BUS",2,[],true],
222 ["Fox_MEGABUS",2,[],true]
223 //"Fox_CobraR_Police" //////WATCH THE COMMAS!!!!!! NO COMMA ON LAST LINE!
224 // Choppers
225 /*
226 ["Exile_Chopper_Hellcat_Green",1,[[22482.9,21144.8,0],[25240.1,21828.6,0]],false],
227 ["Exile_Chopper_Hummingbird_Green",1,[[12824.2,16725.8,0],[22079.8,7299.1,0]],false],
228 ["Exile_Chopper_Mohawk_FIA",1,[[17550.5,12240.5,0],[26782.6,24672,0]],false],
229 ["Exile_Chopper_Orca_CSAT",1,[[2722.07,12976.2,20]],false]*/
230////////////////////////////////////////////////////////////////////////
231];
232
233{
234 for "_i" from 0 to (_x select 1) do
235 {
236 _cancelSpawn = false;
237 _obj = _x select 0;
238 _count = count allMissionObjects _obj;
239 _positionCount = (count (_x select 2));
240 _isRandomRoadPos = _x select 3;
241
242 if !(_count >= _x select 1) then
243 {
244 _vehicleClass = _x select 0;
245 _position = selectRandom (_x select 2);
246
247 if !(_isRandomRoadPos) then
248 {
249 _foundSafePos = false;
250 _failSafe = 15;
251 _checks = 0;
252 waitUntil
253 {
254 _position = selectRandom (_x select 2);
255 _nearVehicles = nearestObjects [_position, ["car","air"], 10];
256 _nearVechicleCount = count _nearVehicles;
257 if (_nearVechicleCount == 0) then
258 {
259 _foundSafePos = true;
260 };
261 _checks = _checks + 1;
262 if (_checks >= _failSafe) then {_cancelSpawn = true; _foundSafePos = true;};
263 _foundSafePos
264 };
265 }
266 else
267 {
268 _foundSafePos = false;
269 waitUntil
270 {
271 _spawnCenter = getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition"); //Center of your map
272 _min = 15; // minimum distance from the center position (Number) in meters
273 _max = 30000; // maximum distance from the center position (Number) in meters
274 _mindist = 5; // minimum distance from the nearest object (Number) in meters, ie. spawn at least this distance away from anything within x meters..
275 _water = 0; // water mode 0: cannot be in water , 1: can either be in water or not , 2: must be in water
276 _shoremode = 0; // 0: does not have to be at a shore , 1: must be at a shore
277 _blackList = [[[0, 0],[0,0]]];
278
279 _startPosRoad = [_spawnCenter,_min,_max,_mindist,_water,10,_shoremode,_blackList] call BIS_fnc_findSafePos; //Find random spot on the map
280 _onRoadCheck = _startPosRoad nearRoads 100; //Find road objects 100m from spot
281 _countPossibleRoads = count _onRoadCheck; // count road objects
282
283 if (_countPossibleRoads == 0) then
284 {
285 }
286 else
287 {
288 _road = _onRoadCheck select 0;
289 _position = getPos _road;
290 _foundSafePos = true;
291 };
292 uiSleep 0.1;
293 _foundSafePos
294 };
295 };
296 if !(_cancelSpawn) then
297 {
298 if !(_debugForSP) then
299 {
300 _pinCode = format ["%1%2%3%4",round (random 8 +1),round (random 8 +1),round (random 8 +1),round (random 8 +1)];
301 _vehicleObject = [_vehicleClass, _position, (random 360), true,_pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
302 _vehicleObject setDamage 0.6;
303 _vehicleObject setFuel round (random 15 +10);
304
305 if !((_x select 0) isKindOf "AIR") then
306 {
307 _wheels = ["HitLF2Wheel","HitLFWheel","HitRFWheel","HitRF2Wheel"];
308 {
309 if (random 1 > 0.5) then
310 {
311 _vehicleObject setHitPointDamage [_x,1];
312 };
313 } forEach _wheels;
314 };
315 _vehicleObject setVariable ["ExileOwnerUID", _uid];
316 _vehicleObject setVariable ["ExileIsLocked",0];
317 _vehicleObject lock 0;
318 _vehicleObject call ExileServer_object_vehicle_database_insert;
319 _vehicleObject call ExileServer_object_vehicle_database_update;
320
321 diag_log format ["[Event: Persistent Spawns] -- Spawned a %1 at location: %2 -- Max allowed: %3",_x select 0,_position, _x select 1];
322 //[format["[Event: Persistent Spawns] -- Spawned a %1 at location: %2 -- Max allowed: %3",_x select 0,_position, _x select 1]] call MAR_fnc_log;
323 }
324 else
325 {
326 _vehicleObject = createVehicle [_vehicleClass,_position,[], 0, "NONE"];
327
328 if !((_x select 0) isKindOf "AIR") then
329 {
330 _wheels = ["HitLF2Wheel","HitLFWheel","HitRFWheel","HitRF2Wheel"];
331 {
332 _vehicleObject setHitPointDamage [_x,1];
333 } forEach _wheels;
334 };
335
336 _marker = createMarker [format["HeliCrash%1", diag_tickTime], _position];
337 _marker setMarkerType "mil_dot";
338 _marker setMarkerText "Vehicle";
339 };
340 }
341 else
342 {
343 if !(_debugForSP) then
344 {
345 //[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;
346 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];
347 }
348 else
349 {
350 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];
351 };
352 };
353 };
354 };
355
356} forEach _vehicleArray;
357
358_scriptComplete = true;
359
360waitUntil
361{
362 diag_log format ["ExileServer - Finished spawning world vehicles"];
363 //["ExileServer - Finished spawning world vehicles"] call MAR_fnc_log;
364 _scriptComplete
365};