handle disconnection when dragging

This commit is contained in:
commy2 2015-03-17 13:47:07 +01:00
parent 5f39cf213b
commit 57becc203c
3 changed files with 28 additions and 0 deletions

View File

@ -8,6 +8,7 @@ class Extended_PreInit_EventHandlers {
class Extended_PostInit_EventHandlers {
class ADDON {
clientInit = QUOTE(call COMPILE_FILE(XEH_clientInit));
serverInit = QUOTE(call COMPILE_FILE(XEH_serverInit));
};
};

View File

@ -10,3 +10,17 @@ if (isNil QGVAR(maxWeight)) then {
};
["isNotDragging", {!((_this select 0) getVariable [QGVAR(isDragging), false])}] call EFUNC(common,addCanInteractWithCondition);
// release object on player change. This does work when returning to lobby, but not when hard disconnecting.
["playerChanged", {
private ["_newPlayer", "_oldPlayer"];
_newPlayer = _this select 0;
_oldPlayer = _this select 1;
{
if (_x getVariable [QGVAR(isDragging), false]) then {
[_x, _x getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject);
};
} forEach [_newPlayer, _oldPlayer];
}] call EFUNC(common,addEventhandler);

View File

@ -0,0 +1,13 @@
// by commy2
#include "script_component.hpp"
// release object on hard disconnection.
addMissionEventHandler ["HandleDisconnect", {
private "_unit";
_unit = _this select 0;
if (_unit getVariable [QGVAR(isDragging), false]) then {
[_unit, _unit getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject);
};
}];