SinisterCarnage 0 Report post Posted July 18, 2017 Hello, i am currently hosting a server and wish to add one vehicle that randomly spawns thoughout the map. Such as a C130 or VTOL that would sell for allot of poptabs and would be worth hunting down. I only want one of them to spawn every server restart and I want it to be random where it spawns every time. Any help would be appreciated. Share this post Link to post Share on other sites
Quasi Normal (Melano!) 17 Report post Posted July 19, 2017 You don't need a script to do that. just add it to your random spawn vehicles list on your config.ccp and set a price for it. voila. Share this post Link to post Share on other sites
dekela 129 Report post Posted July 19, 2017 create a new folder inside your mission root folder, name it scripts (if one dose not already exist) paste the following into notepad++ and save as randVehicleSpawn.sqf Spoiler private ["_specVehicleMarker","_specVehicle","_flatPos","_accepted","_position","_objPos","_vehicle","_marker"]; //-------------------- Config part _specVehicleMarker = 1; // Show vehicle on the map 1=show, 0=no show _specVehicle = "B_T_VTOL_01_infantry_F"; //sets vehicle type //-------------------- find a random, relatively flat, empty spot for the vehicle _flatPos = [0,0,0]; _accepted = false; while {!_accepted} do { _position = [] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty [5,0,0.2,sizeOf "Land_TentHangar_V1_F",0,false]; while {(count _flatPos) < 2} do { _position = [] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty [5,0,0.2,sizeOf "Land_TentHangar_V1_F",0,false]; }; _accepted = true; }; _objPos = [_flatPos, 25, 35, 10, 0, 0.5, 0] call BIS_fnc_findSafePos; //-------------------- crate the vehicle and set direction _vehicle = _specVehicle createVehicle _flatPos; _vehicle allowdamage false; waitUntil {!isNull _vehicle}; _vehicle setDir (random 360); _vehicle setVectorUp surfaceNormal position _vehicle; _vehicle allowdamage true; //-------------------- show a debug marker for the vehicle if _specVehicleMarker = 1 if (_specVehicleMarker == 1) then { _marker = createmarker ["Vehicle Position",_flatPos]; _marker setMarkerColor "ColorOrange"; _marker setMarkerType "hd_destroy"; _marker setMarkerText " Special Vehicle Position"; }; place randVehicleSpawn.sqf inside the scripts folder at the top of initServer.sqf (underneath /** * Created with Exile Mod 3DEN Plugin * exile.majormittens.co.uk */) paste the following [] execVM "scripts\randVehicleSpawn.sqf"; repbo and enjoy this is not original code, just a quick copy/paste together of existing code, but it works 5 1 Share this post Link to post Share on other sites
Joshi120 0 Report post Posted July 19, 2017 9 hours ago, dekela said: create a new folder inside your mission root folder, name it scripts (if one dose not already exist) paste the following into notepad++ and save as randVehicleSpawn.sqf Reveal hidden contents private ["_specVehicleMarker","_specVehicle","_flatPos","_accepted","_position","_objPos","_vehicle","_marker"]; //-------------------- Config part _specVehicleMarker = 1; // Show vehicle on the map 1=show, 0=no show _specVehicle = "B_T_VTOL_01_infantry_F"; //sets vehicle type //-------------------- find a random, relatively flat, empty spot for the vehicle _flatPos = [0,0,0]; _accepted = false; while {!_accepted} do { _position = [] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty [5,0,0.2,sizeOf "Land_TentHangar_V1_F",0,false]; while {(count _flatPos) < 2} do { _position = [] call BIS_fnc_randomPos; _flatPos = _position isFlatEmpty [5,0,0.2,sizeOf "Land_TentHangar_V1_F",0,false]; }; _accepted = true; }; _objPos = [_flatPos, 25, 35, 10, 0, 0.5, 0] call BIS_fnc_findSafePos; //-------------------- crate the vehicle and set direction _vehicle = _specVehicle createVehicle _flatPos; _vehicle allowdamage false; waitUntil {!isNull _vehicle}; _vehicle setDir (random 360); _vehicle setVectorUp surfaceNormal position _vehicle; _vehicle allowdamage true; //-------------------- show a debug marker for the vehicle if _specVehicleMarker = 1 if (_specVehicleMarker == 1) then { _marker = createmarker ["Vehicle Position",_flatPos]; _marker setMarkerColor "ColorOrange"; _marker setMarkerType "hd_destroy"; _marker setMarkerText " Special Vehicle Position"; }; place randVehicleSpawn.sqf inside the scripts folder at the top of initServer.sqf (underneath /** * Created with Exile Mod 3DEN Plugin * exile.majormittens.co.uk */) paste the following [] execVM "scripts\randVehicleSpawn.sqf"; repbo and enjoy this is not original code, just a quick copy/paste together of existing code, but it works oh my .... thats perfect Thanks! just talked with my bud about something like this a few hours ago heh but... could you maybe make a version wich takes 1 Vehicle from a list of possible vehicles ? duno if thats possible tho >.> Share this post Link to post Share on other sites
dekela 129 Report post Posted July 19, 2017 Quote but... could you maybe make a version wich takes 1 Vehicle from a list of possible vehicles ? duno if thats possible tho >.> Yes it's possible. What list of vehicles would you like to chose from? Share this post Link to post Share on other sites
Joshi120 0 Report post Posted July 19, 2017 46 minutes ago, dekela said: Yes it's possible. What list of vehicles would you like to chose from? one of each VTOL's so once Blackfish and the other one Y-32 Xi'an Share this post Link to post Share on other sites
Quasi Normal (Melano!) 17 Report post Posted July 19, 2017 You can do that i guess _specVehicle = selectRandom ["v1","v2","v3","v4","v5"]; //sets vehicle type 2 Share this post Link to post Share on other sites
SinisterCarnage 0 Report post Posted July 19, 2017 Thank you all for your responses I will give this a go. Share this post Link to post Share on other sites
dekela 129 Report post Posted July 20, 2017 12 hours ago, Joshi120 said: one of each VTOL's so once Blackfish and the other one Y-32 Xi'an as quasi normal posted, _specVehicle = selectRandom ["O_T_VTOL_02_infantry_F","B_T_VTOL_01_infantry_F"]; //sets vehicle type 3 Share this post Link to post Share on other sites
Joshi120 0 Report post Posted July 20, 2017 4 hours ago, dekela said: as quasi normal posted, _specVehicle = selectRandom ["O_T_VTOL_02_infantry_F","B_T_VTOL_01_infantry_F"]; //sets vehicle type Awesome! Thanks a lot :3 Share this post Link to post Share on other sites