add_med_notification.sqf 2.7 KB

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