Skip to content

Instantly share code, notes, and snippets.

@commy2
Last active January 9, 2018 13:06
Show Gist options
  • Save commy2/d112f77e9fd32980fc112914bd3952ff to your computer and use it in GitHub Desktop.
Save commy2/d112f77e9fd32980fc112914bd3952ff to your computer and use it in GitHub Desktop.
// server preInit
if (!isServer) exitWith {};
commy_ZeusWhitelist = ["76561198032991179"]; // <<< edit this line
commy_ZeusModules = [];
commy_ZeusLoops = [];
commy_ZeusGroup = createGroup sideLogic;
addMissionEventHandler ["PlayerConnected", {
params ["_id", "_uid", "_name", "_jip", "_owner"];
if !(_uid in commy_ZeusWhitelist) exitWith {};
private _index = commy_ZeusWhitelist find _uid;
// handle player connecting with multiple instances
if (!isNull (commy_ZeusModules param [_index, objNull])) exitWith {};
private _logic = commy_ZeusGroup createUnit ["ModuleCurator_F", [0,0,0], [], 0, "NONE"];
commy_ZeusModules set [_index, _logic];
private _loop = [_uid, _logic] spawn {
params ["_uid", "_logic"];
private _unit = objNull;
waitUntil {
{
if (getPlayerUID _x == _uid) exitWith {
_unit = _x;
};
} forEach allPlayers;
!isNull _unit
};
_unit assignCurator _logic;
};
commy_ZeusLoops set [_index, _loop];
//_logic addCuratorEditableObjects [allMissionObjects "", true];
}];
addMissionEventHandler ["PlayerDisconnected", {
params ["_id", "_uid", "_name", "_jip", "_owner"];
if !(_uid in commy_ZeusWhitelist) exitWith {};
private _index = commy_ZeusWhitelist find _uid;
private _logic = commy_ZeusModules select _index;
deleteVehicle _logic;
private _loop = commy_ZeusLoops select _index;
terminate _loop;
}];
@Cuel
Copy link

Cuel commented Oct 16, 2017

needs to be reassigned on respawn

@neilzar
Copy link

neilzar commented Jan 9, 2018

With JIP, if groups are set to be deleted when empty, it will delete the ZeusGroup. This means that if a player joins in JIP, the group will be null and createUnit returns null. Fixed by adding if (isNull ZeusGroup) then { ZeusGroup = createGroup sideLogic }; before createUnit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment