mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Dogtags - Fix arsenal not showing dogtag info in multiplayer (#10095)
* Broadcast dogtag info globally so that arsenal can use it * Broadcast changes incrementally * Update addons/dogtags/XEH_postInit.sqf Co-authored-by: PabstMirror <pabstmirror@gmail.com> * Update addons/dogtags/functions/fnc_getDogtagItem.sqf Co-authored-by: PabstMirror <pabstmirror@gmail.com> * Add EH only on necessary machines --------- Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
parent
4d0641abb8
commit
3745305323
@ -5,10 +5,8 @@ PREP(bloodType);
|
|||||||
PREP(canCheckDogtag);
|
PREP(canCheckDogtag);
|
||||||
PREP(canTakeDogtag);
|
PREP(canTakeDogtag);
|
||||||
PREP(checkDogtag);
|
PREP(checkDogtag);
|
||||||
PREP(checkDogtagItem);
|
|
||||||
PREP(getDogtagData);
|
PREP(getDogtagData);
|
||||||
PREP(getDogtagItem);
|
PREP(getDogtagItem);
|
||||||
PREP(sendDogtagData);
|
|
||||||
PREP(showDogtag);
|
PREP(showDogtag);
|
||||||
PREP(ssn);
|
PREP(ssn);
|
||||||
PREP(takeDogtag);
|
PREP(takeDogtag);
|
||||||
|
@ -1,10 +1,29 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
[QGVAR(showDogtag), LINKFUNC(showDogtag)] call CBA_fnc_addEventHandler;
|
[QGVAR(showDogtag), LINKFUNC(showDogtag)] call CBA_fnc_addEventHandler;
|
||||||
[QGVAR(sendDogtagData), LINKFUNC(sendDogtagData)] call CBA_fnc_addEventHandler;
|
|
||||||
[QGVAR(getDogtagItem), LINKFUNC(getDogtagItem)] call CBA_fnc_addEventHandler;
|
[QGVAR(getDogtagItem), LINKFUNC(getDogtagItem)] call CBA_fnc_addEventHandler;
|
||||||
[QGVAR(addDogtagItem), LINKFUNC(addDogtagItem)] call CBA_fnc_addEventHandler;
|
[QGVAR(addDogtagItem), LINKFUNC(addDogtagItem)] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
|
if (hasInterface || isServer) then {
|
||||||
|
[QGVAR(broadcastDogtagInfo), {
|
||||||
|
GVAR(dogtagsData) set _this;
|
||||||
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
|
if (isServer) then {
|
||||||
|
// Sync dogtag data from server to client
|
||||||
|
[QGVAR(requestSyncDogtagDataJIP), {
|
||||||
|
params ["_clientOwner"];
|
||||||
|
|
||||||
|
{
|
||||||
|
[QGVAR(broadcastDogtagInfo), [_x, _y], _clientOwner] call CBA_fnc_ownerEvent;
|
||||||
|
} forEach GVAR(dogtagsData);
|
||||||
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
} else {
|
||||||
|
// To be here, hasInterface must be true
|
||||||
|
[QGVAR(requestSyncDogtagDataJIP), clientOwner] call CBA_fnc_serverEvent;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// Add actions and event handlers only if ace_medical is enabled
|
// Add actions and event handlers only if ace_medical is enabled
|
||||||
// - Adding actions via config would create a dependency
|
// - Adding actions via config would create a dependency
|
||||||
["CBA_settingsInitialized", {
|
["CBA_settingsInitialized", {
|
||||||
@ -56,8 +75,6 @@ if (["ace_arsenal"] call EFUNC(common,isModLoaded)) then {
|
|||||||
if (_leftPanelIDC in [2010, 2012, 2014] && {_rightPanelIDC == 38}) then {
|
if (_leftPanelIDC in [2010, 2012, 2014] && {_rightPanelIDC == 38}) then {
|
||||||
LOG("passed");
|
LOG("passed");
|
||||||
private _rightPanel = _display displayCtrl 15;
|
private _rightPanel = _display displayCtrl 15;
|
||||||
private _allDogtags = missionNamespace getVariable [QGVAR(allDogtags), []];
|
|
||||||
private _allDogtagsData = missionNamespace getVariable [QGVAR(allDogtagDatas), []];
|
|
||||||
private _cfgWeapons = configFile >> "CfgWeapons";
|
private _cfgWeapons = configFile >> "CfgWeapons";
|
||||||
private _item = "";
|
private _item = "";
|
||||||
private _dogtagData = [];
|
private _dogtagData = [];
|
||||||
@ -66,7 +83,7 @@ if (["ace_arsenal"] call EFUNC(common,isModLoaded)) then {
|
|||||||
_item = _rightPanel lnbData [_i, 0];
|
_item = _rightPanel lnbData [_i, 0];
|
||||||
|
|
||||||
if (_item isKindOf ["ACE_dogtag", _cfgWeapons]) then {
|
if (_item isKindOf ["ACE_dogtag", _cfgWeapons]) then {
|
||||||
private _name = (_allDogtagsData param [_allDogtags find _item, []]) param [0, ""];
|
private _name = (GVAR(dogtagsData) getOrDefault [_item, []]) param [0, ""];
|
||||||
|
|
||||||
// If data doesn't exist or body has no name, set name as "unknown"
|
// If data doesn't exist or body has no name, set name as "unknown"
|
||||||
if (_name == "") then {
|
if (_name == "") then {
|
||||||
|
@ -8,4 +8,12 @@ PREP_RECOMPILE_END;
|
|||||||
|
|
||||||
GVAR(disabledFactions) = createHashMap;
|
GVAR(disabledFactions) = createHashMap;
|
||||||
|
|
||||||
|
if (hasInterface || isServer) then {
|
||||||
|
GVAR(dogtagsData) = createHashMap;
|
||||||
|
|
||||||
|
if (!isServer) exitWith {};
|
||||||
|
|
||||||
|
GVAR(idCounter) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
ADDON = true;
|
ADDON = true;
|
||||||
|
@ -27,7 +27,9 @@ private _fnc_getActions = {
|
|||||||
private _displayName = getText (_config >> "displayName");
|
private _displayName = getText (_config >> "displayName");
|
||||||
private _picture = getText (_config >> "picture");
|
private _picture = getText (_config >> "picture");
|
||||||
|
|
||||||
private _action = [_x, _displayName, _picture, FUNC(checkDogtagItem), {true}, {}, _x] call EFUNC(interact_menu,createAction);
|
private _action = [_x, _displayName, _picture, {
|
||||||
|
[GVAR(dogtagsData) getOrDefault [_this select 2, []]] call FUNC(showDogtag);
|
||||||
|
}, {true}, {}, _x] call EFUNC(interact_menu,createAction);
|
||||||
_actions pushBack [_action, [], _player];
|
_actions pushBack [_action, [], _player];
|
||||||
};
|
};
|
||||||
} forEach (_player call EFUNC(common,uniqueItems));
|
} forEach (_player call EFUNC(common,uniqueItems));
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
#include "..\script_component.hpp"
|
|
||||||
/*
|
|
||||||
* Author: SzwedzikPL
|
|
||||||
* Check dogtag self menu action.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Player <OBJECT>
|
|
||||||
* 1: Target <OBJECT>
|
|
||||||
* 2: Item class <STRING>
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
* [player, unit, "itemClass"] call ace_dogtags_fnc_checkDogtagItem
|
|
||||||
*
|
|
||||||
* Public: No
|
|
||||||
*/
|
|
||||||
|
|
||||||
params ["_player", "_target", "_item"];
|
|
||||||
|
|
||||||
[QGVAR(sendDogtagData), [_player, _item]] call CBA_fnc_serverEvent;
|
|
@ -21,19 +21,15 @@ if(!isServer) exitWith {};
|
|||||||
params ["_player", "_target"];
|
params ["_player", "_target"];
|
||||||
TRACE_2("getDogtagItem",_player,_target);
|
TRACE_2("getDogtagItem",_player,_target);
|
||||||
|
|
||||||
private _allDogtags = missionNamespace getVariable [QGVAR(allDogtags), []];
|
GVAR(idCounter) = GVAR(idCounter) + 1;
|
||||||
private _allDogtagDatas = missionNamespace getVariable [QGVAR(allDogtagDatas), []];
|
|
||||||
|
|
||||||
private _nextID = count _allDogtags + 1;
|
if (GVAR(idCounter) > 999) exitWith {ERROR("Ran out of IDs");};
|
||||||
|
|
||||||
if (_nextID > 999) exitWith {ERROR("Ran out of IDs");};
|
|
||||||
|
|
||||||
private _dogTagData = [_target] call FUNC(getDogTagData);
|
private _dogTagData = [_target] call FUNC(getDogTagData);
|
||||||
private _item = format ["ACE_dogtag_%1", _nextID];
|
private _item = format ["ACE_dogtag_%1", GVAR(idCounter)];
|
||||||
_allDogtags pushBack _item;
|
|
||||||
_allDogtagDatas pushBack _dogTagData;
|
|
||||||
|
|
||||||
missionNamespace setVariable [QGVAR(allDogtags), _allDogtags];
|
|
||||||
missionNamespace setVariable [QGVAR(allDogtagDatas), _allDogtagDatas];
|
|
||||||
|
|
||||||
[QGVAR(addDogtagItem), [_item, _dogTagData], [_player]] call CBA_fnc_targetEvent;
|
[QGVAR(addDogtagItem), [_item, _dogTagData], [_player]] call CBA_fnc_targetEvent;
|
||||||
|
|
||||||
|
// Broadcast data globally, so that clients can use it where needed
|
||||||
|
[QGVAR(broadcastDogtagInfo), [_item, _dogTagData]] call CBA_fnc_globalEvent;
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
#include "..\script_component.hpp"
|
|
||||||
/*
|
|
||||||
* Author: SzwedzikPL
|
|
||||||
* Server: returns to client data on given dogtag.
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* 0: Player <OBJECT>
|
|
||||||
* 1: Target <OBJECT>
|
|
||||||
*
|
|
||||||
* Return Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
* [player, unit] call ace_dogtags_fnc_sendDogtagData
|
|
||||||
*
|
|
||||||
* Public: No
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!isServer) exitWith {};
|
|
||||||
|
|
||||||
params ["_target", "_item"];
|
|
||||||
TRACE_2("sendDogtagData",_target,_item);
|
|
||||||
|
|
||||||
private _allDogtags = missionNameSpace getVariable [QGVAR(allDogtags), []];
|
|
||||||
private _allDogtagDatas = missionNameSpace getVariable [QGVAR(allDogtagDatas), []];
|
|
||||||
|
|
||||||
private _dogtagData = [];
|
|
||||||
private _index = _allDogtags find _item;
|
|
||||||
if (_index >= 0) then {
|
|
||||||
_dogtagData = _allDogtagDatas select _index;
|
|
||||||
};
|
|
||||||
|
|
||||||
[QGVAR(showDogtag), [_dogtagData], [_target]] call CBA_fnc_targetEvent;
|
|
Loading…
Reference in New Issue
Block a user