trying to fix event handlers

This commit is contained in:
Eero af Heurlin 2016-07-24 13:39:43 +03:00
parent d65d077f7d
commit 91de24aa80
5 changed files with 15 additions and 8 deletions

View File

@ -22,7 +22,7 @@ diag_log format["createObj called, _target: %1, _playerno: %2, _player: %3", _ta
//_tsk1 setSimpleTaskDestination (getPos _lzLoc);
//(playersArray select _playerno) setCurrentTask _tsk1;
_taskid = format["p%1_lz%2", _playerno, _lzLoc];
[west,[_taskid],[format["Fly to and land within %1m of the next LZ", lzSize], "Next LZ", "LZ"],(getPos _lzLoc),true,5,true, "move", true] call BIS_fnc_taskCreate;
[west,[_taskid],[format["Player %2: Fly to and land within %1m of the LZ", lzSize, _playerno], format["p%1 LZ", _playerno], "LZ"],(getPos _lzLoc),true,5,true, "move", true] call BIS_fnc_taskCreate;
taskIdsArray set [_playerno, _taskid];

View File

@ -61,8 +61,8 @@ for [{_iX = 0}, {_iX < _maxplayers}, {_iX = _iX + 1}] do
ferryingArray set [_iX, false];
landingCompleteArray set [_iX, false];
squadLoadedArray set [_iX, false];
playersArray set [_iX, null];
taskIdsArray set [_iX, null];
playersArray set [_iX, ""];
taskIdsArray set [_iX, ""];
};
publicVariable "squadMDArray";
publicVariable "enemyMDArray";
@ -70,6 +70,7 @@ publicVariable "AAMDArray";
publicVariable "ferryingArray";
publicVariable "landingCompleteArray";
publicVariable "squadLoadedArray";
publicVariable "playersArray";
publicVariable "taskIdsArray";
missionInitComplete = true;

View File

@ -3,9 +3,9 @@ diag_log format["initPlayer called, _this: %1", _this];
_target = _this select 0;
_playerno = _this select 1;
playersArray set [_playerno, _target];
_target addMPEventHandler ["mpkilled", {Null = _this, _playerno execVM "playerkilled.sqf";}];
_target addMPEventHandler ["respawn", {Null = _this, _playerno execVM "playerspawn.sqf";}];
_target addMPEventHandler ["respawn", {Null = unit, _playerno execVM "playerspawn.sqf";}];
[null, _playerno] execVM "playerspawn.sqf";
[_target, _playerno] execVM "playerspawn.sqf";

View File

@ -4,7 +4,7 @@ _playerno = _this select 1;
_taskid = taskIdsArray select _playerno;
null = [_taskid, "FAILED", False] spawn BIS_fnc_taskSetState;
taskIdsArray set [_playerno, null];
taskIdsArray set [_playerno, ""];
publicVariable "taskIdsArray";
_squadArray = squadMDArray select _playerno;

View File

@ -1,6 +1,12 @@
diag_log format["playerspawn called, _this: %1", _this];
_evt = _this select 0;
_target = _this select 0;
_playerno = _this select 1;
playersArray set [_playerno, _target];
publicVariable "playersArray";
_target addEventHandler ["killed", {Null = _this, _playerno execVM "playerkilled.sqf";}];
_target addMPEventHandler ["mpkilled", {Null = _this, _playerno execVM "playerkilled.sqf";}];
_target addEventHandler ["respawn", {Null = unit, _playerno execVM "playerspawn.sqf";}];
ferryingArray set [_playerno, false];
landingCompleteArray set [_playerno, false];