Hi all,
I have a script similar to enemy air support script in evolution for A1 that looks like this:
while {true} do
{
_posCreate = position aHeli_start;
_pilot=objNull;
waitUntil {
_pilot = createGroup (west);
!(isNull _pilot);
};
"US_Soldier_Pilot_EP1" createUnit [position aheli_start, _pilot, "this setCaptive true", 1.0, "PRIVATE"];
_recy = [_pilot] execVM "Scripts\grpRecycle.sqf";
_aHeli = createVehicle ["AH64D_EP1", _posCreate, [], 0, "NONE"];
_aHeli setPos [getPos _aHeli select 0, getPos _aHeli select 1, 0.15];
_aHeli setDir 240;
(units _pilot select 0) assignAsGunner _aHeli;
(units _pilot select 0) moveInGunner _aHeli;
{_x addEventHandler ["Killed", {handle = [_this select 0] execVM "Scripts\Bury.sqf"}]} forEach (units _pilot);
_aHeli addEventHandler ["Killed", {handle = [_this select 0] execVM "Scripts\Bury.sqf"; CO SideChat "GUNSHIP DESTROYED"}];
sleep 10;
waitUntil {!(canMove _aHeli) or !(alive _aHeli) or ((isNull (driver _aHeli)) and (isNull (gunner _aHeli)))};
{_x setDamage 1} forEach units _pilot;
if (alive _aHeli) then {_aHeli setDamage 1};
sleep 5.0;
};
Im calling the script from Init.sqf:
_aAH = [] execVM "Scripts\Support\aHeli.sqf";
Bury.sqf deletes destroyed vehicles:
_unit = _this select 0;
sleep 150;
[_unit] join grpNull;
sleep 450;
_unit removeallEventHandlers "Killed";
_unit removeallEventHandlers "getOut";
_unit removeallEventHandlers "getIn";
if (not (_unit isKindOf "Man")) then
{
_class = typeOf _unit;
_pos = position _unit;
_dir = direction _unit;
_speed = speed _unit;
//if (_unit isKindOf "Air") then {sleep 5.0};
{deleteVehicle _x} forEach ([_unit] + crew _unit);
_vcl = _class createVehicle _pos;
_vcl setPos _pos;
_vcl setDir _dir;
_vec setVelocity [_speed, 0, 0];
_vcl setFuel 0.0;
_vcl setDamage 1;
sleep 300.0;
deleteVehicle _vcl;
} else {
sleep 300.0;
if (not (isNull _unit)) then {deleteVehicle _unit};
};
CO is just a unit that is saying messages.
It all works great in SP but not in MP. On dedicated server it seems to spawn as much helicopters as there is players :confused:. If I start a client server on my PC it works fine (only 1 heli). If start a server on my PC but with another player (so 2 players from the start) then 2 helicopters spawn.
Can anyone tell me how can I get only 1 heli to spawn no matter what but to have the script working in SP as well. If that is even possible.
And to be clear, just in case, Im not trying to rip anything off. Im just trying to learn here by reinventing the wheel :).