Jump to content
Sign in to follow this  
mjr.hassle

Spawned object duplicated on reconnect.

Recommended Posts

Hi. I`m working on a MP Free Flight mission. Nothing fancy, three flagpoles that allow you to spawn a light, medium or heavy helicopter of your choice. I`ve included a vehicle cleanup script and respawn, as accidents do happen. :)

So far its running ok as far as I can see, but for one problem: If I run the mission on a dedicated server (Set to persistant) then leave and rejoin, the flagpoles are spawned again, so instead of three I have six. If I leave and rejoin again, another 3 appear and so on.

Would anyone be able to let me know what I`m doing wrong please? Here`s the scripts I`m using.

Aircrate.sqf

_obj =  "FlagCarrier_Larkin_H" createVehicle (getMarkerPos "AirObj");
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Light") +"</t>"), "Airspawn.sqf", ["Heli_Light01_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Vrana Corp") +"</t>"), "Airspawn.sqf", ["Heli_Light01_Vrana_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Larkin Aviation") +"</t>"), "Airspawn.sqf", ["Heli_Light01_Wave_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: BlueLine") +"</t>"), "Airspawn.sqf", ["Heli_Light01_blueline_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Digital Times") +"</t>"), "Airspawn.sqf", ["Heli_Light01_digital_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Elliptical") +"</t>"), "Airspawn.sqf", ["Heli_Light01_elliptical_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Furious") +"</t>"), "Airspawn.sqf", ["Heli_Light01_furious_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Grey Watcher") +"</t>"), "Airspawn.sqf", ["Heli_Light01_graywatcher_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Jeans") +"</t>"), "Airspawn.sqf", ["Heli_Light01_jeans_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Shadow") +"</t>"), "Airspawn.sqf", ["Heli_Light01_shadow_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Sunset") +"</t>"), "Airspawn.sqf", ["Heli_Light01_sunset_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Wasp") +"</t>"), "Airspawn.sqf", ["Heli_Light01_wasp_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Sheriff Dept") +"</t>"), "Airspawn.sqf", ["Heli_Light01_sheriff_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Time Trial") +"</t>"), "Airspawn.sqf", ["Heli_Light01_TimeTrial_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION") +"</t>"), "Airspawn.sqf", ["Heli_Light01_ION_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION Tactical") +"</t>"), "Airspawn.sqf", ["CIV_Heli_Light01_ION_H"]];

Airspawn.sqf

private ["_Air","_caller","_type","_pos","_list","_mDir"];
_caller = (_this select 1);
_type = (_this select 3) select 0;

_pos = getMarkerPos "Airspawn_1";
_list = nearestObjects [_pos, ["Air"], 10];
{deleteVehicle _x} forEach _list;

sleep 0.5;
if (!(_type == "")) then 
{
{_Air = _type createVehicle (getMarkerPos "AirSpawn_1");
hintSilent "Aircraft Selected. Previous Aircraft was removed.";
} else 
{
hintSilent "Aircraft removed.";
};

switch (_type) do {
case "Heli_Light01_H" : {_Air = "Heli_Light01_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_Vrana_H" : {_Air = "Heli_Light01_Vrana_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_Wave_H" : {_Air = "Heli_Light01_Wave_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_blueline_H" : {_Air = "Heli_Light01_blueline_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_digital_H" : {_Air = "Heli_Light01_digital_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_elliptical_H" : {_Air = "Heli_Light01_elliptical_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_furious_H" : {_Air = "Heli_Light01_furious_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_graywatcher_H" : {_Air = "Heli_Light01_graywatcher_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_jeans_H" : {_Air = "Heli_Light01_jeans_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_shadow_H" : {_Air = "Heli_Light01_shadow_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_sunset_H" : {_Air = "Heli_Light01_sunset_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_wasp_H" : {_Air = "Heli_Light01_wasp_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_sheriff_H" : {_Air = "Heli_Light01_sheriff_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_TimeTrial_H" : {_Air = "Heli_Light01_TimeTrial_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_ION_H" : {_Air = "Heli_Light01_ION_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "CIV_Heli_Light01_ION_H" : {_Air = "CIV_Heli_Light01_ION_H" createVehicle (getMarkerPos "AirSpawn_1");};
};
};
sleep 0.1;
_mDir = markerDir "Airspawn_1";
_Air setDir _mDIR;

And this is in my init.sqf.

waituntil {(alive player)};


call compile preprocessFileLineNumbers "AirSpawn.sqf";
execVM "Aircrate.sqf";

Any help would be greatly appreciated. :)

Share this post


Link to post
Share on other sites

I'm going to guess locality is your problem... your script is running on both the server and the clients. Somewhere in your script you will need to put in an if (isServer) statement so that it runs on the server ONLY, and not on each client.

Note that I am just guessing ;)

Share this post


Link to post
Share on other sites

Hi there,

Savage is right, createVehicle command has global effects and therefore must only be executed on one client or the server only.

Aircrate.sqf

Change to:

if (isServer) then {
spawnFlag = "FlagCarrier_Larkin_H" createVehicle (getMarkerPos "AirObj");
publicVariable "spawnFlag";
};

if (!isDedicated) then {
waitUntil {!(isNil "spawnFlag")};
_obj = spawnFlag;
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Light") +"</t>"), "Airspawn.sqf", ["Heli_Light01_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Vrana Corp") +"</t>"), "Airspawn.sqf", ["Heli_Light01_Vrana_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Larkin Aviation") +"</t>"), "Airspawn.sqf", ["Heli_Light01_Wave_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: BlueLine") +"</t>"), "Airspawn.sqf", ["Heli_Light01_blueline_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Digital Times") +"</t>"), "Airspawn.sqf", ["Heli_Light01_digital_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Elliptical") +"</t>"), "Airspawn.sqf", ["Heli_Light01_elliptical_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Furious") +"</t>"), "Airspawn.sqf", ["Heli_Light01_furious_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Grey Watcher") +"</t>"), "Airspawn.sqf", ["Heli_Light01_graywatcher_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Jeans") +"</t>"), "Airspawn.sqf", ["Heli_Light01_jeans_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Shadow") +"</t>"), "Airspawn.sqf", ["Heli_Light01_shadow_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Sunset") +"</t>"), "Airspawn.sqf", ["Heli_Light01_sunset_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Wasp") +"</t>"), "Airspawn.sqf", ["Heli_Light01_wasp_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Sheriff Dept") +"</t>"), "Airspawn.sqf", ["Heli_Light01_sheriff_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Time Trial") +"</t>"), "Airspawn.sqf", ["Heli_Light01_TimeTrial_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION") +"</t>"), "Airspawn.sqf", ["Heli_Light01_ION_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION Tactical") +"</t>"), "Airspawn.sqf", ["CIV_Heli_Light01_ION_H"]];
};

and

Airspawn.sqf

_caller = (_this select 1);

Change to:

_caller = (_this select 1);
if (!local _caller) exitWith {};

That should fix all locality issues.

Edited by sxp2high
forgot something...

Share this post


Link to post
Share on other sites

Thank you so much! :) Spent so much time over the weekend looking for solutions that I almost started dreaming code.

I will implement the changes when I get in tonight. Thanks again.

Share this post


Link to post
Share on other sites
Savage is right, createVehicle command has global effects and therefore must only be executed on one client or the server only.

Hah!!! I'm showing my wife your post to prove that yes indeed...sometimes Savage is right.

Share this post


Link to post
Share on other sites

:tempt:

Mjr.Hassle, your init.sqf has some flaws as well.

waituntil {(alive player)}; // This line will give you an error on the dedicated, since "player" doesn't exist on a dedi. And the line is not needed anyway. Please delete it

This line however should be on the very top of your init.sqf:

waitUntil {(isDedicated) || !(isNull player)}; // Make init JIP compatible

I also don't see a reason to call the AirSpawn.sqf in your init.sqf ... and more important: Never call files that have a sleep in them. execVM or spawn them instead.

Share this post


Link to post
Share on other sites

Thanks for the info. :) To be honest, the scripts and bits I`'m using I pulled from the A2 editing thread. I`m clueless with scripting and coding tbh. Saying that, I`m learning bit by bit the does and dont`s thanks to posts like yours above. :)

Again, thanks for taking the time to let me know, really do appreciated it. :)

EDIT:

Alrighty! The above works perfectly, thanks. Removing the airspawn reference from the init.sqf got rid of an error that was showing with _showscripterrors running.

I`ve added 2 more flags to spawn medium and heavy helicopters.

I`ve altered the aircrate.sqf which now looks like this:

if (isServer) then {
   spawnFlag = "FlagCarrier_Larkin_H" createVehicle (getMarkerPos "AirObj"); spawnFlag2 = "FlagCarrier_Larkin_H" createvehicle (getmarkerpos "airobj2"); spawnFlag3 = "FlagCarrier_Larkin_H" createvehicle (getmarkerpos "airobj3");
   publicVariable "spawnFlag"; "spawnFlag2"; "spawnFlag3";
};

if (!isDedicated) then {
   waitUntil {!(isNil "spawnFlag")};
   _obj = spawnFlag;
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Light") +"</t>"), "Airspawn.sqf", ["Heli_Light01_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Vrana Corp") +"</t>"), "Airspawn.sqf", ["Heli_Light01_Vrana_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Larkin Aviation") +"</t>"), "Airspawn.sqf", ["Heli_Light01_Wave_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: BlueLine") +"</t>"), "Airspawn.sqf", ["Heli_Light01_blueline_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Digital Times") +"</t>"), "Airspawn.sqf", ["Heli_Light01_digital_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Elliptical") +"</t>"), "Airspawn.sqf", ["Heli_Light01_elliptical_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Furious") +"</t>"), "Airspawn.sqf", ["Heli_Light01_furious_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Grey Watcher") +"</t>"), "Airspawn.sqf", ["Heli_Light01_graywatcher_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Jeans") +"</t>"), "Airspawn.sqf", ["Heli_Light01_jeans_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Shadow") +"</t>"), "Airspawn.sqf", ["Heli_Light01_shadow_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Sunset") +"</t>"), "Airspawn.sqf", ["Heli_Light01_sunset_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Wasp") +"</t>"), "Airspawn.sqf", ["Heli_Light01_wasp_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Sheriff Dept") +"</t>"), "Airspawn.sqf", ["Heli_Light01_sheriff_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Time Trial") +"</t>"), "Airspawn.sqf", ["Heli_Light01_TimeTrial_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION") +"</t>"), "Airspawn.sqf", ["Heli_Light01_ION_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION Tactical") +"</t>"), "Airspawn.sqf", ["CIV_Heli_Light01_ION_H"]];


   _obj = spawnFlag2;
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Civil") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Larkin Aviation") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Wave_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION") +"</t>"), "Airspawn2.sqf", ["IND_Heli_Medium01_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Flamingo") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Flamingo_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Frost Fire") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Frostfire_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Parrot") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Parrot_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Coastguard") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Coastguard_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Red") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Red_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Redlines") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Redlines_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Shark") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Shark_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Sun") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Sun_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Twilight") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Twilight_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Wasp") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Wasp_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Sheriff Dept") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Sheriff_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Medium FLIR") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_FLIR_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Luxury") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Luxury_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Vrana Corp") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Luxury_Vrana_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Air Ambulance") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Medic_H"]];


   _obj = spawnFlag3;
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Civil") +"</t>"), "Airspawn3.sqf", ["Heli_Heavy01_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Vrana Corp") +"</t>"), "Airspawn3.sqf", ["Heli_Heavy01_Vrana_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Larkin Aviation Ind") +"</t>"), "Airspawn3.sqf", ["Heli_Heavy01_Wave_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION") +"</t>"), "Airspawn3.sqf", ["IND_Heli_Heavy01_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Luxury") +"</t>"), "Airspawn3.sqf", ["Heli_Heavy01_Luxury_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Vrana Corp Exec") +"</t>"), "Airspawn3.sqf", ["Heli_Heavy01_Luxury_Vrana_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION (VIP)") +"</t>"), "Airspawn3.sqf", ["Ind_Heli_Heavy01_Luxury_H"]];
   _obj addAction [("<t color=""#66FF00"">" + ("Spawn: Marine One") +"</t>"), "Airspawn3.sqf", ["Heli_Heavy01_Luxury_President_H"]];

};

The part I changed still seems to work. The flags appear, but now I`m not sure how to go about giving the new flags the spawn ability. I was hoping you might be able to advise me please.

Edited by Mjr.Hassle

Share this post


Link to post
Share on other sites

Sure. I marked the stuff I changed in red. :)

if (isServer) then {
spawnFlag = "FlagCarrier_Larkin_H" createVehicle (getMarkerPos "AirObj");
publicVariable "spawnFlag";
spawnFlag2 = "FlagCarrier_Larkin_H" createvehicle (getmarkerpos "airobj2");
[color="#FF0000"]publicVariable "spawnFlag2";[/color]
spawnFlag3 = "FlagCarrier_Larkin_H" createvehicle (getmarkerpos "airobj3");
[color="#FF0000"]publicVariable "spawnFlag3";[/color]
};

if (!isDedicated) then {
waitUntil {!(isNil "spawnFlag")[color="#FF0000"] && !(isNil "spawnFlag2") && !(isNil "spawnFlag3")[/color]}; [color="#008000"]// Wait until the server created the flags[/color]
_obj = spawnFlag;
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Light") +"</t>"), "Airspawn.sqf", ["Heli_Light01_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Vrana Corp") +"</t>"), "Airspawn.sqf", ["Heli_Light01_Vrana_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Larkin Aviation") +"</t>"), "Airspawn.sqf", ["Heli_Light01_Wave_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: BlueLine") +"</t>"), "Airspawn.sqf", ["Heli_Light01_blueline_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Digital Times") +"</t>"), "Airspawn.sqf", ["Heli_Light01_digital_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Elliptical") +"</t>"), "Airspawn.sqf", ["Heli_Light01_elliptical_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Furious") +"</t>"), "Airspawn.sqf", ["Heli_Light01_furious_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Grey Watcher") +"</t>"), "Airspawn.sqf", ["Heli_Light01_graywatcher_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Jeans") +"</t>"), "Airspawn.sqf", ["Heli_Light01_jeans_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Shadow") +"</t>"), "Airspawn.sqf", ["Heli_Light01_shadow_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Sunset") +"</t>"), "Airspawn.sqf", ["Heli_Light01_sunset_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Wasp") +"</t>"), "Airspawn.sqf", ["Heli_Light01_wasp_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Sheriff Dept") +"</t>"), "Airspawn.sqf", ["Heli_Light01_sheriff_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Time Trial") +"</t>"), "Airspawn.sqf", ["Heli_Light01_TimeTrial_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION") +"</t>"), "Airspawn.sqf", ["Heli_Light01_ION_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION Tactical") +"</t>"), "Airspawn.sqf", ["CIV_Heli_Light01_ION_H"]];


_obj = spawnFlag2;
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Civil") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Larkin Aviation") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Wave_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION") +"</t>"), "Airspawn2.sqf", ["IND_Heli_Medium01_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Flamingo") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Flamingo_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Frost Fire") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Frostfire_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Parrot") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Parrot_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Coastguard") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Coastguard_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Red") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Red_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Redlines") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Redlines_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Shark") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Shark_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Sun") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Sun_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Twilight") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Twilight_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Wasp") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Wasp_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Sheriff Dept") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Sheriff_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Medium FLIR") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_FLIR_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Luxury") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Luxury_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Vrana Corp") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Luxury_Vrana_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Air Ambulance") +"</t>"), "Airspawn2.sqf", ["Heli_Medium01_Medic_H"]];


_obj = spawnFlag3;
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Civil") +"</t>"), "Airspawn3.sqf", ["Heli_Heavy01_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Vrana Corp") +"</t>"), "Airspawn3.sqf", ["Heli_Heavy01_Vrana_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Larkin Aviation Ind") +"</t>"), "Airspawn3.sqf", ["Heli_Heavy01_Wave_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION") +"</t>"), "Airspawn3.sqf", ["IND_Heli_Heavy01_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Luxury") +"</t>"), "Airspawn3.sqf", ["Heli_Heavy01_Luxury_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Vrana Corp Exec") +"</t>"), "Airspawn3.sqf", ["Heli_Heavy01_Luxury_Vrana_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: ION (VIP)") +"</t>"), "Airspawn3.sqf", ["Ind_Heli_Heavy01_Luxury_H"]];
_obj addAction [("<t color=""#66FF00"">" + ("Spawn: Marine One") +"</t>"), "Airspawn3.sqf", ["Heli_Heavy01_Luxury_President_H"]];
};

I presume you want to have a different spawn position for each flag, so the Airspawn file has to be changed as well:

private ["_Air","_caller","_type","_pos","_list","_mDir"];
_caller = (_this select 1);
_type = (_this select 3) select 0;


[color="#FF0000"]_flag = _this select 0;

_pos = switch (_flag) do {
case (spawnFlag) : { getMarkerPos "Airspawn_1"; };
case (spawnFlag2) : { getMarkerPos "Airspawn_2" };
case (spawnFlag3) : { getMarkerPos "Airspawn_3" };
};

_mDir = switch (_flag) do {
case (spawnFlag) : { markerDir "Airspawn_1"; };
case (spawnFlag2) : { markerDir "Airspawn_2" };
case (spawnFlag3) : { markerDir "Airspawn_3" };
};[/color]


_list = nearestObjects [_pos, ["Air"], 10];
{deleteVehicle _x} forEach _list;

sleep 0.5;
if (!(_type == "")) then 
{
{_Air = _type createVehicle (getMarkerPos "AirSpawn_1");
hintSilent "Aircraft Selected. Previous Aircraft was removed.";
} else 
{
hintSilent "Aircraft removed.";
};

switch (_type) do {
case "Heli_Light01_H" : {_Air = "Heli_Light01_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_Vrana_H" : {_Air = "Heli_Light01_Vrana_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_Wave_H" : {_Air = "Heli_Light01_Wave_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_blueline_H" : {_Air = "Heli_Light01_blueline_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_digital_H" : {_Air = "Heli_Light01_digital_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_elliptical_H" : {_Air = "Heli_Light01_elliptical_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_furious_H" : {_Air = "Heli_Light01_furious_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_graywatcher_H" : {_Air = "Heli_Light01_graywatcher_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_jeans_H" : {_Air = "Heli_Light01_jeans_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_shadow_H" : {_Air = "Heli_Light01_shadow_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_sunset_H" : {_Air = "Heli_Light01_sunset_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_wasp_H" : {_Air = "Heli_Light01_wasp_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_sheriff_H" : {_Air = "Heli_Light01_sheriff_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_TimeTrial_H" : {_Air = "Heli_Light01_TimeTrial_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "Heli_Light01_ION_H" : {_Air = "Heli_Light01_ION_H" createVehicle (getMarkerPos "AirSpawn_1");};
case "CIV_Heli_Light01_ION_H" : {_Air = "CIV_Heli_Light01_ION_H" createVehicle (getMarkerPos "AirSpawn_1");};
};
};
sleep 0.1;
[color="#FF0000"]_air setPosATL _pos;[/color] [color="#008000"]// I recommend a setPos after createVehicle, because createVehicle is not 100% accurate[/color]
_Air setDir _mDIR;

Edited by sxp2high

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×