diff --git a/SQF/dayz_code/fn_localizeMessage.sqf b/SQF/dayz_code/fn_localizeMessage.sqf new file mode 100644 index 000000000..63d0e63f7 --- /dev/null +++ b/SQF/dayz_code/fn_localizeMessage.sqf @@ -0,0 +1,41 @@ +/* + Function name: fnc_localizeMessage + This function localizes and formats messages that are sent remotely to the client. Used in conjunction with fnc_remote_message. + If a user wants a string to be localized then STR_CL_ should be placed in the string name in stringtable.xml. STR_CL_MYSERVERSIDESCRIPT_ACTION. + The message can also be sent as an array or multi-dimensional array with arguments. Example: _message = ["STR_CL_Localized_String", param1, param2]; +*/ + +_type = _this select 0; +_message = _this select 1; +if (typeName _message == "TEXT") exitWith {_message}; +_multiArray = ["private","dynamic_text","ai_killfeed","hintWithImage","hintNoImage"]; // These messages can be multi-dimensional arrays + +if (_type in _multiArray) then { + { + _index = _forEachIndex; + if (typeName _x == "ARRAY") then { + { + if (["STR_",_x] call fnc_inString) then { + (_message select _index) set [_forEachIndex, localize _x]; + }; + } forEach _x; + _message set [_index, format _x]; + } else { + if (["STR_",_x] call fnc_inString) then { + _message set [_index, localize _x]; + }; + }; + } forEach _message; +} else { + if (typeName _message == "ARRAY") then { + if (["STR_",(_message select 0)] call fnc_inString) then { + _message set [0, localize (_message select 0)]; + }; + _message = format _message; + } else { + if (["STR_",_message] call fnc_inString) then { + _message = localize _message; + }; + }; +}; +_message \ No newline at end of file diff --git a/SQF/dayz_code/fn_remoteMessage.sqf b/SQF/dayz_code/fn_remoteMessage.sqf new file mode 100644 index 000000000..dba8e33d6 --- /dev/null +++ b/SQF/dayz_code/fn_remoteMessage.sqf @@ -0,0 +1,77 @@ +/* + Function name: fnc_remoteMessage + This function accepts messages sent with PublicVariable "RemoteMessage" and displays them on the screen. + It sends the messages to fnc_localizeMessage for localizing and formatting. +*/ + +private "_vars"; + +_type = _this select 0; +_message = _this select 1; +if (count _this > 2) then { + _vars = _this select 2; +}; + +// Checks for localized strings and formats messages that contain parameters +_message = [_type,_message] call fnc_localizeMessage; + +if (_type == "radio") exitWith { + if (player hasWeapon "ItemRadio") then { + if (player getVariable["radiostate",true]) then { + systemChat ("[RADIO] " + _message); + playSound "Radio_Message_Sound"; + }; + }; +}; + +if (_type == "IWAC") exitWith { + if (player hasWeapon "ItemRadio") then { + if (player getVariable["radiostate",true]) then { + _message call dayz_rollingMessages; + playSound "IWAC_Message_Sound"; + }; + }; +}; + +if (_type == "private") exitWith {if(getPlayerUID player == (_message select 0)) then {systemChat (_message select 1);};}; +if (_type == "systemChat") exitWith {systemChat _message;}; +if (_type == "titleCut") exitWith {titleCut [_message,"PLAIN DOWN",3];}; +if (_type == "titleText") exitWith {titleText [_message, "PLAIN DOWN"]; titleFadeOut 10;}; +if (_type == "rollingMessages") exitWith {_message call dayz_rollingMessages;}; +if (_type == "dynamic_text") exitWith { + [ + format["%1
%2",_message select 0,_message select 1,_vars select 0,_vars select 1,_vars select 2,_vars select 3], + (_vars select 4), // X coordinate + (_vars select 5), // Y coordinate + (_vars select 6), // Message duration + (_vars select 7) // fade in + ] spawn BIS_fnc_dynamicText; +}; +if (_type == "hintWithImage") exitWith {hint parseText format["%1

%2", + _message select 0, // Title + _message select 1, // Announcement + _vars select 0, // Image + _vars select 1, // Title Color + _vars select 2, // Title Size + _vars select 3 // Image Size +];}; +if (_type == "hintNoImage") exitWith {hint parseText format["%1
%2", + _message select 0, // Title + _message select 1, // Announcement + _vars select 0, // Title Color + _vars select 1 // Title Size +];}; +if (_type == "ai_killfeed") exitWith { + if (isNil "RM_rscLayer") then {RM_rscLayer = 750}; + [ + format["%1%2
%3",_message select 0,_message select 1,_message select 2,_vars select 0,_vars select 1,_vars select 2], + (_vars select 3), // X coordinate + (_vars select 4), // Y coordinate + (_vars select 5), // Message duration + (_vars select 6), // fade in + -1, + RM_rscLayer + ] spawn BIS_fnc_dynamicText; + RM_rscLayer = RM_rscLayer + 1; + if (RM_rscLayer == 788) then {RM_rscLayer = nil;}; +};