add_med_notification.sqf 2.6 KB

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