- Add random service number and bloodtypes to all units.

- Leave up to CBA to decide if events should be local or remote
- Imp
This commit is contained in:
esteldunedain 2016-06-20 15:51:36 -03:00
parent e58d829927
commit 0d30bf1de8
7 changed files with 58 additions and 25 deletions

View File

@ -4,6 +4,7 @@ PREP(canCheckDogtag);
PREP(canTakeDogtag);
PREP(checkDogtag);
PREP(checkDogtagItem);
PREP(getDogtagData);
PREP(getDogtagItem);
PREP(sendDogtagData);
PREP(showDogtag);

View File

@ -4,7 +4,7 @@
*
* Arguments:
* 0: Item class <STRING>
* 1: Nickname on dogtag <STRING>
* 1: Dogtag data <ARRAY>
*
* Return Value:
* None
@ -13,11 +13,12 @@
*/
#include "script_component.hpp"
params ["_item", "_nickname"];
params ["_item", "_dogtagData"];
if (_item == "") exitWith {};
[ace_player, _item] call CBA_fnc_addItem;
private _displayText = format [localize LSTRING(takeDogtagSuccess), _nickname];
_dogtagData params ["_nickName"];
private _displayText = format [localize LSTRING(takeDogtagSuccess), _nickName];
[_displayText] call EFUNC(common,displayText);

View File

@ -16,5 +16,6 @@
params ["_player", "_target"];
private _doubleTags = !(_target getVariable [QGVAR(dogtagTaken), false]);
private _nickname = [_target, false, true] call EFUNC(common,getName);
[QGVAR(showDogtag), [_nickname, _doubleTags]] call CBA_fnc_localEvent;
private _dogTagData = [_target] call FUNC(getDogTagData);
[QGVAR(showDogtag), [_dogTagData, _doubleTags]] call CBA_fnc_localEvent;

View File

@ -0,0 +1,32 @@
/*
* Author: esteldunedain
* Get unit dogtag data
*
* Arguments:
* 0: Target <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_target"];
// Check if the data was already created
private _dogTagData = _target getVariable QGVAR(dogtagData);
if (!isNil "_dogTagData") exitWith {_dogTagData};
// Create dog tag data once for the unit: nickname, code (eg. 135-13-900) and blood type
private _dogTagData = [
[_target, false, true] call EFUNC(common,getName),
str(floor random 9) + str(floor random 9) + str(floor random 9) + "-" +
str(floor random 9) + str(floor random 9) + "-" +
str(floor random 9) + str(floor random 9) + str(floor random 9),
selectRandom ["O POS", "O NEG", "A POS", "A NEG", "B POS", "B NEG",
"AB POS", "AB NEG"]
];
// Store it
_target setVariable [QGVAR(dogtagData), _dogTagData, true];
_dogTagData

View File

@ -15,26 +15,22 @@
if(!isServer) exitWith {};
params ["_target", "_unit"];
TRACE_2("getDogtagItem",_target,_unit);
params ["_player", "_target"];
TRACE_2("getDogtagItem",_player,_target);
private _allDogtags = missionNamespace getVariable [QGVAR(allDogtags), []];
private _allDogtagNicknames = missionNamespace getVariable [QGVAR(allDogtagNicknames), []];
private _allDogtagDatas = missionNamespace getVariable [QGVAR(allDogtagDatas), []];
private _nextID = count _allDogtags + 1;
if (_nextID > 999) exitWith {};
private _nickname = [_unit, false, true] call EFUNC(common,getName);
private _dogTagData = [_target] call FUNC(getDogTagData);
private _item = format ["ACE_dogtag_%1", _nextID];
_allDogtags pushBack _item;
_allDogtagNicknames pushBack _nickname;
_allDogtagDatas pushBack _dogTagData;
missionNamespace setVariable [QGVAR(allDogtags), _allDogtags];
missionNamespace setVariable [QGVAR(allDogtagNicknames), _allDogtagNicknames];
missionNamespace setVariable [QGVAR(allDogtagDatas), _allDogtagDatas];
if(isMultiplayer) then {
[QGVAR(addDogtagItem), [_item, _nickname], [_target]] call CBA_fnc_targetEvent;
} else {
[QGVAR(addDogtagItem), [_item, _nickname]] call CBA_fnc_localEvent;
};
[QGVAR(addDogtagItem), [_item, _dogTagData], [_player]] call CBA_fnc_targetEvent;

View File

@ -1,6 +1,6 @@
/*
* Author: SzwedzikPL
* Server: returns to client nickname on given dogtag
* Server: returns to client data on given dogtag
*
* Arguments:
* 0: Player <OBJECT>
@ -19,12 +19,12 @@ params ["_target", "_item"];
TRACE_2("sendDogtagData",_target,_item);
private _allDogtags = missionNameSpace getVariable [QGVAR(allDogtags), []];
private _allDogtagNicknames = missionNameSpace getVariable [QGVAR(allDogtagNicknames), []];
private _allDogtagDatas = missionNameSpace getVariable [QGVAR(allDogtagDatas), []];
private _nickname = "";
private _dogtagData = [];
private _index = _allDogtags find _item;
if (_index >= 0) then {
_nickname = _allDogtagNicknames select _index;
_dogtagData = _allDogtagDatas select _index;
};
[QGVAR(showDogtag), [_nickname], [_target]] call CBA_fnc_targetEvent;
[QGVAR(showDogtag), [_dogtagData], [_target]] call CBA_fnc_targetEvent;

View File

@ -3,7 +3,8 @@
* Shows dogtag
*
* Arguments:
* 0: Nickname <STRING>
* 0: Dog tag data <ARRAY>
* 1: Display as double tag <BOOLEAN>
*
* Return Value:
* None
@ -14,9 +15,9 @@
disableSerialization;
params ["_nickname", ["_doubleTags", false, [false]]];
params ["_dogtagData", ["_doubleTags", false, [false]]];
if (!hasInterface || {_nickname == ""}) exitWith {};
if (!hasInterface || {_dogtagData isEqualTo []}) exitWith {};
if (_doubleTags) then {
(QGVAR(tag) call BIS_fnc_rscLayer) cutRsc [QGVAR(doubleTag), "PLAIN", 1, true];
@ -27,4 +28,5 @@ private _display = uiNamespace getvariable [QGVAR(tag), displayNull];
if(isNull _display) exitWith {};
private _control = _display displayCtrl 1001;
_control ctrlSetStructuredText parseText format ["%1<br/>%2<br/>%3", toUpper _nickName, "135-13-9001", "O POS"];
_dogtagData params ["_nickName", "_code", "_bloodType"];
_control ctrlSetStructuredText parseText format ["%1<br/>%2<br/>%3", toUpper _nickName, _code, _bloodType];