Jump to content
Sign in to follow this  
cougarxr7

Killing Pilot causes, Error Zero divisor

Recommended Posts

Not sure why this is happening.

I believe it has to do with an update/updates.

Pilots that eject from an aircraft are not being killed or deleted.

Original files use in Killjoys' "EvolutionB2.Sara",

"makesu.sqf" and "bury.sqf"

makesu.sqf

if (not (local server)) exitwith {};
rscripts=rscripts+1;
for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
_starts = [ka1,ka2,ka3,ka4];
_poscreate = position (_starts select (round random 3));

_pilot = createGroup (east);

"SoldierEPilot" createUnit [position tpos2, _pilot];
"SoldierEPilot" createUnit [position tpos2, _pilot];
_recy = [_pilot,"none",objNull] spawn {[_this select 0,_this select 1,_this select 2] call EVO_gRecy};
//if(isNull (units _pilot select 0)) exitWith {};
_heli = createVehicle ["Su34", _poscreate, [], 100, "FLY"];
_heli setpos [getpos _heli select 0, getpos _heli select 1, 200];
_heli setdir (random 359);
_heli engineon true;
_vec setVelocity [200, 0, 0];
_sumark = [_heli] execVM "scripts\sumarker.sqf";
(units _pilot select 0) assignAsDriver _heli;
(units _pilot select 1) assignAsGunner _heli;

(units _pilot select 0) moveInDriver _heli;
(units _pilot select 1) moveInGunner _heli;
//player moveInGunner _heli;

//_pilot setSpeedMode "LIMITED";
_pilot setCombatMode "RED";
{_x addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}]} forEach (units _pilot);
_heli addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}];
_handle = [_pilot] execVM "scripts\flightpath.sqf";

sleep 10.0;
waitUntil {not (alive _heli) or isNull (driver _heli)};
if (alive _heli) then {_heli setdammage 1};
sleep 600.0; //10 mins
};

bury.sqf

_unit = _this select 0;
_tag = "none";
_tag = _this select 1;
_grp = group _unit;
//sleep 600.0; //3 min =180
//sleep 10.0; //3 min =180
_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;
_vel = velocity _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;
_vcl setVelocity _vel;
_vcl setFuel 0.0;
_vcl setDamage 1;
sleep 300.0;
deletevehicle _vcl;
};
if (_unit isKindOf "Man") then
{
sleep 300.0;
if( not (isnull _unit)) then {server action ["HIDEBODY", _unit]};
};

You can't use makesu.sqf file without making code changes

or at lest I can't.

After making changes it will work, here it is.

modifided makesu.sqf

if (not (local server)) exitwith {};
rscripts=rscripts+1;
for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
_starts = ["EnemyAir01","EnemyAir02","EnemyAir03","EnemyAir04"];
_poscreate = getmarkerpos (_starts select (round random 3));

_pilot = createGroup (east);
"SoldierEPilot" createUnit [position tpos2, _pilot];
"SoldierEPilot" createUnit [position tpos2, _pilot];
_heli = createVehicle ["Mi17", _poscreate, [], 100, "FLY"];
_heli setpos [getpos _heli select 0, getpos _heli select 1, 200]; _heli flyinheight 100;
_heli setdir (random 359);
_heli engineon true;
_vec setVelocity [200, 0, 0];
_sumark = [_heli] execVM "scripts\sumarker.sqf";

(units _pilot select 0) assignAsDriver _heli;
(units _pilot select 1) assignAsCargo _heli;

(units _pilot select 0) moveInDriver _heli;
(units _pilot select 1) moveInCargo _heli;

_heli setDamage .6;
sleep 6;
_pilot setCombatMode "RED";
{_x addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}]} forEach (units _pilot);
_heli addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}];
_handle = [_pilot] execVM "scripts\flightpath.sqf";

sleep 10.0;
waitUntil {not (alive _heli) or isNull (driver _heli)};
if (alive _heli) then {_heli setdammage 1};
sleep 30.0; //10 mins
};

If you shoot the helo and kill it along with both pilot, no problem.

If they eject, 1 will be killed/deleted/removed in time.

The other pilot will wonder the map going to a wpt 3,000 meters away.

OK no problem lets kill/delete/remove this pilot.

new moddified "makesu.sqf"

if (not (local server)) exitwith {};
rscripts=rscripts+1;

for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
_starts = ["EnemyAir01","EnemyAir01","EnemyAir01","EnemyAir01"];
_poscreate = getmarkerpos (_starts select (round random 3));

_pilot = createGroup (east);
_unit1 = _pilot createUnit ["SoldierEPilot",getmarkerpos "centerp", [], 300, "NONE"];Sleep GlobalSleep;
_unit2 = _pilot createUnit ["SoldierEPilot",getmarkerpos "centerp", [], 300, "NONE"];Sleep GlobalSleep;
[_unit1,_unit2] join _pilot;			

_heli = createVehicle ["Mi17", _poscreate, [], 000, "NONE"];Sleep GlobalSleep;
_heli setpos [getpos _heli select 0, getpos _heli select 1, 000]; _heli flyinheight 000;
_heli setdir (random 359);
_heli engineon true;
_sumark = [_heli] execVM "scripts\sumarker.sqf";
(units _pilot select 0) assignAsDriver _heli;
(units _pilot select 0) moveInDriver _heli;
(units _pilot select 1) assignAsCargo _heli;
(units _pilot select 1) moveInCargo _heli;

 _pilot setCombatMode "RED";
{_x addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}]} forEach (units _pilot);
_heli addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}];
_spawne = [_heli] spawn {[_this select 0] call idelSVEC};

_handle = [_pilot] execVM "air\DMi17_rockets_RUflightpath.sqf";
sleep 1;

waitUntil  {(speed _heli == 0) or not (alive _heli)};
	sleep 30;
	 _heli setDamage 1;
	Sleep 10.0;		 
	(units _pilot select 0) setDamage 1;
	(units _pilot select 1) setDamage 1;		 
sleep 40.0; 
};

With the code above this is the error it causes!

Error in expression <ot select 0) setDamage 1;

(units _pilot select 1) setDamage 1;

sleep 40.0;

};

>

Error position: <select 1) setDamage 1;

sleep 30.0;

};

>

Error Zero divisor

That error only happens when you kill the helo with both pilots in the helo.

Blocking out "//" the helo "addEventHandler", all errors stop, as well as the helo getting removed from the map.

If they (Pilots) eject before the helo is killed, then no error and both pilots are killed/deleted/removed in time!

I hope someone has an answer, I'm really curious as to why this is happening.

Edited by Cougarxr7

Share this post


Link to post
Share on other sites

Do you know in which script the code...

if (alive (units _pilot select 1)) then {(units _pilot select 1)>

...is written, because I do not see it in any of the scripts you posted above. We will need to find it to solve this completely.

Anyway, I assume what is happening is that the code is trying to access an element of an array which does not exist, namely the second element of the group _pilot. What is probably happening is that if the helo is killed it also kills one or more of the pilots inside which means there are fewer than two units in the group so there is no element that exists for units _pilot select 1 and that causes the error.

Share this post


Link to post
Share on other sites

My bad!

my custom makesu.sqf

if (not (local server)) exitwith {};
rscripts=rscripts+1;

for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
_starts = ["EnemyAir01","EnemyAir01","EnemyAir01","EnemyAir01"];
_poscreate = getmarkerpos (_starts select (round random 3));

_pilot = createGroup (east);
_unit1 = _pilot createUnit ["SoldierEPilot", getmarkerpos "centerp", [], 300, "NONE"];Sleep GlobalSleep;
_unit2 = _pilot createUnit ["SoldierEPilot", getmarkerpos "centerp", [], 300, "NONE"];Sleep GlobalSleep;
[_unit1,_unit2] join _pilot;

//hint format ["%1 %2 %3",_pilot,_unit1,_unit2];
//sleep 3;

_heli = createVehicle ["Mi17", _poscreate, [], 000, "FLY"];Sleep GlobalSleep;
_heli setpos [getpos _heli select 0, getpos _heli select 1, 200]; _heli flyinheight 100;
_heli setdir (random 359);
_heli engineon true;
_sumark = [_heli] execVM "scripts\sumarker.sqf";
(units _pilot select 0) assignAsDriver _heli;
(units _pilot select 0) moveInDriver _heli;
(units _pilot select 1) assignAsCargo _heli;
(units _pilot select 1) moveInCargo _heli;
_heli setDamage .6;
sleep 6;

 _pilot setCombatMode "RED";
{_x addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}]} forEach (units _pilot);
_heli addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}];
_recy = [_pilot,"none",objNull] spawn {[_this select 0,_this select 1,_this select 2] call EVO_gRecy};				  
_handle = [_pilot] execVM "air\DMi17_rockets_RUflightpath.sqf";
sleep 1;

waitUntil  {(speed _heli == 0) or not (alive _heli)};
	sleep 2;
	 _heli setDamage 1;
	sleep 60;
if (alive (units _pilot select 0)) then {(units _pilot select 0) setdammage 1};	
	//(units _pilot select 0) setDamage 1;
	 sleep 3;
if (alive (units _pilot select 1)) then {(units _pilot select 1) setdammage 1};		 
	//(units _pilot select 1) setDamage 1;
	sleep 3;
	 //deletevehicle _heli;
sleep 30.0; //15 mins
};
//hint format["%1 %2",_unit,_type]; {_me = _this select 0; _him = _this select 1;
//_spawne = [_heli] spawn {[_this select 0] call idelSVEC};
//	if (alive (units _pilot select 0)) then {(units _pilot select 0) setdammage 1};

if (alive (units _pilot select 1)) then {(units _pilot select 1)>

That was from the wrong file I used. The many of which I tried to troubleshoot this with.

Sorry!

I believe you are correct in why it is happening!

I've tried alot of different ways and had no luck!

I saw in the hints, the game did not even see the 2nd pilot!

But can kill him if he ejects from the helo in time???

Now how do we fix it??

Edited by Cougarxr7

Share this post


Link to post
Share on other sites

hey Cougar, This is Fence try something along these lines

{_x setdammage 1} forEach units group _pilot; (accesses the array with no element preference.)

in place of these 2 lines requiring a specific element.

if (alive (units _pilot select 0)) then {(units _pilot select 0) setdammage 1};

//(units _pilot select 0) setDamage 1;

sleep 3;

if (alive (units _pilot select 1)) then {(units _pilot select 1) setdammage 1};

//(units _pilot select 1) setDamage 1;

sleep 3;

I am not sure of the syntax but I think that's close, but may require macgivering on your part.....

catch you on ts when you get your new drive issues sorted

your only friend, Fence

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  

×