add_med_notification.sqf 2.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. if(!hasInterface || !local this || isServer) exitWith{};
  2. RD501_MedNotif_lastMessageTime = 0;
  3. _id = ["ace_medicalMenuOpened", {
  4. params["_player", "_target", ""];
  5. //if(_player == _target) exitWith {};
  6. if(time - RD501_MedNotif_lastMessageTime < 1) exitWith {
  7. };
  8. // if("ace_medical_pendingReopen") exitWith {diag_log format["RD501_MedNotif[DEBUG]: %1", "Pending Reopen, not displaying"]};
  9. if(isNil "RD501_MedNotif_Message" || RD501_MedNotif_Message == "") then {
  10. diag_log format["RD501_MedNotif[DEBUG]: %1", format["Message not initialised, setting to default ('%1')", "%1 is asking that you kindly hold still."]];
  11. RD501_MedNotif_Message = "%1 is asking that you kindly hold still.";
  12. };
  13. _name = [_player] call ace_common_fnc_getName;
  14. _targetName = [_target] call ace_common_fnc_getName;
  15. if(_target getVariable["ACE_Unconscious", false]) exitWith {
  16. diag_log format["RD501_MedNotif[DEBUG]: %1", format["%1 is unconscious, ignoring", _targetName]];
  17. };
  18. if([_target] call ace_common_fnc_isMedic) then
  19. {
  20. diag_log format["RD501_MedNotif[DEBUG]: %1", format["Displaying Medic Message to %1", _targetName]];
  21. _text = format[RD501_MedNotif_Message, _name];
  22. _image = "RD501_Main\ui_icons\medical_emblem.paa";
  23. _textHTML = format["<t align='center'>%1</t>", _text];
  24. _result = composeText [parseText format["<img size='2' align='center' color='%2' image='%1'/>", _image, [1,1,1] call BIS_fnc_colorRGBtoHTML], lineBreak, _text];
  25. ["ace_common_displayTextStructured", [_result, 2, _target], [_target]] call CBA_fnc_targetEvent;
  26. }else
  27. {
  28. diag_log format["RD501_MedNotif[DEBUG]: %1", format["Displaying Non Medic Message to %1", _targetName]];
  29. ["ace_common_displayTextStructured", [format[RD501_MedNotif_Message, _name], 2, _target], [_target]] call CBA_fnc_targetEvent;
  30. };
  31. RD501_MedNotif_lastMessageTime = time;
  32. }] call CBA_fnc_addEventHandler;
  33. diag_log format["RD501_MedNotif[DEBUG]: %1", format["Registered and loaded for '%1'", this call ace_common_fnc_getName]];