Jump to content
  • 0

Dynamic text issue


Relentless

Question

Hello there,

I am currently trying to execute a script server sided and I want to send a message to all players when it's executed with a dynamic text. I am using BIS_fnc_dynamicText but that's not working for me. I tried another structure and it worked but the dynamic text not. I really want to put a local variable into that so here is what I tried:

The working format

[nil,nil,rTitleText,_msg,"PLAIN",10] call RE;

Not working format with dynamic text

['<t align=''center'' size=''0.8'' color=''#00FF00''>'+_msg+'</t>',safezoneX+0.2,safezoneY+0.465,5,1,0,3035] spawn BIS_fnc_dynamicText;

also tried

["<t color='#00FF00' size = '0.8'>" + _msg + "</t>",-1,-1,4,1,0,789] spawn BIS_fnc_dynamicText;

 

Is anyone able to help at this point?

Link to comment
Share on other sites

18 answers to this question

Recommended Posts

  • 0
48 minutes ago, JasonTM said:

Could you tell me how you fixed this? I am having the exact same issue.

I don't use BIS_fnc_dynamicText anymore because this function was too buggy for me. I fixed it but sometimes it showed up and sometimes now so I decided to create an own custom eventhandler that is called on client side. With this you can also make custom messages. Let's say I have the eventhandler called fnc_dynamicMessages and this function has 3 parameters, so I can send the text, the color and the duration to this eventhandler and it displays the message for me. That was the most easy way I guess.

Link to comment
Share on other sites

  • 0
50 minutes ago, JasonTM said:

Could you tell me how you fixed this? I am having the exact same issue.

This is what i have server sided for my sector c

if (_abort) exitWith { 
[nil,nil,"per",rTITLETEXT,"Sector C has already been activated. Come back after restart!","PLAIN DOWN"] call RE;
};

 

Link to comment
Share on other sites

  • 0
3 minutes ago, theduke said:

This is what i have server sided for my sector c


if (_abort) exitWith { 
[nil,nil,"per",rTITLETEXT,"Sector C has already been activated. Come back after restart!","PLAIN DOWN"] call RE;
};

 

Yeah but that's a titletext and in my opinion this is pretty ugly. I came to that problem when I tried to replace the default titletext WAI messages with dynamic messages because they look a lot better. So yeah, yours is working on serverside if you don't want to avoid messing with sending variables and stuff like that to the client.

Link to comment
Share on other sites

  • 0
1 minute ago, DAmNRelentless said:

Yeah but that's a titletext and in my opinion this is pretty ugly. I came to that problem when I tried to replace the default titletext WAI messages with dynamic messages because they look a lot better. So yeah, yours is working on serverside if you don't want to avoid messing with sending variables and stuff like that to the client.

yeah, basically all this does is check to make sure the static mission has been spawned during the restart, and if yes, stops them from respawning it.

Although making it better looking, i have nothing against lol...Whats your suggestion or method?

Link to comment
Share on other sites

  • 0
Just now, theduke said:

yeah, basically all this does is check to make sure the static mission has been spawned during the restart, and if yes, stops them from respawning it.

Although making it better looking, i have nothing against lol...Whats your suggestion or method?

Mentioned my methods some posts before but I guess you wrote yours the same time and didn't read it. I did it with a custom eventhandler.

Link to comment
Share on other sites

  • 0
2 minutes ago, DAmNRelentless said:

I don't use BIS_fnc_dynamicText anymore because this function was too buggy for me. I fixed it but sometimes it showed up and sometimes now so I decided to create an own custom eventhandler that is called on client side. With this you can also make custom messages. Let's say I have the eventhandler called fnc_dynamicMessages and this function has 3 parameters, so I can send the text, the color and the duration to this eventhandler and it displays the message for me. That was the most easy way I guess.

I started to work on Nox's admin tools again and the send server message function is broken. I looked over the files and I can't see what the issue is.

The public event handler looks like this.

// Broadcast server message to clients
	"EAT_PVEH_serverMessage" addPublicVariableEventHandler {
		[format["<t size='0.8' color='#ff0000' font='Zeppelin33'>%1</t>", _this select 1],0,0,10,2,0,8] spawn BIS_fnc_dynamicText;
	};

The script messageDialog.sqf looks like this

Spoiler

private ["_dialog"];
SendDialogText = "";

// Sleep to make sure scroll menu is cleared
Sleep 0.2;

_dialog = createdialog "EAT_messageBox_Dialog";

ctrlSetText [1001,"Send a server message"];

waitUntil {!dialog};
if(SendDialogText == "") exitWith {};

EAT_PVEH_serverMessage = "ADMIN: " + SendDialogText;
[] spawn {publicVariable "EAT_PVEH_serverMessage";};

 

EAT_messageBox_Dialog is this

Spoiler

class EAT_messageBox_Dialog
{
	idd = -1;
	movable = 0;

	class Controls {
		class EAT_msgBox_Background: EAT_RscText
		{
			idc = 1000;
			x = 0.35677 * safezoneW + safezoneX;
			y = 0.382451 * safezoneH + safezoneY;
			w = 0.285304 * safezoneW;
			h = 0.183649 * safezoneH;
			colorBackground[] = {0,0,0,0.7};
		};
		class EAT_msgBox_RscText_1001: EAT_RscText
		{
			idc = 1001;
			text = "PLACEHOLDER";
			x = 0.35677 * safezoneW + safezoneX;
			y = 0.382451 * safezoneH + safezoneY;
			w = 0.285305 * safezoneW;
			h = 0.0247882 * safezoneH;
			colorText[] = {1,0.6392,0.196,1};
			colorBackground[] = {0,0,0,1};
		};
		class EAT_msgBox_txtBox: EAT_RscEdit
		{
			idc = 1400;
			type = 2;
			x = 0.362278 * safezoneW + safezoneX;
			y = 0.417716 * safezoneH + safezoneY;
			w = 0.274365 * safezoneW;
			h = 0.109082 * safezoneH;
			text = "";
			colorSelection[] = {1,1,1,0.25};
		};
		class EAT_msgBox_btnSend: EAT_RscShortcutButton
		{
			idc = 1700;
			text = "Send";
			x = 0.3656 * safezoneW + safezoneX;
			y = 0.518526 * safezoneH + safezoneY;
			w = 0.0596567 * safezoneW;
			h = 0.0535038 * safezoneH;
			onButtonClick = "SendDialogText = ctrlText ((ctrlParent (_this select 0)) displayCtrl 1400);((ctrlParent (_this select 0)) closeDisplay 9000);";
		};
		class EAT_msgBox_btnClose: EAT_RscShortcutButton
		{
			idc = 1701;
			text = "Close";
			x = 0.573451 * safezoneW + safezoneX;
			y = 0.518526 * safezoneH + safezoneY;
			w = 0.0596567 * safezoneW;
			h = 0.0525776 * safezoneH;
			onButtonClick = "((ctrlParent (_this select 0)) closeDisplay 9000);";
		};
	};
};

 

 

I tried different things to fix it, but nothing is working. I would appreciate you looking over the files. I am not sure how to fix it.

Link to comment
Share on other sites

  • 0
Just now, DAmNRelentless said:

Before I spend time to look over that, I want to know how you know it's broken. Is there an error or is it just not displaying? No errors in the rpt's?

No errors in the rpt's, it's just not displaying.

Link to comment
Share on other sites

  • 0

The part that causes your problem is this one I guess

SendDialogText = "";

// Sleep to make sure scroll menu is cleared
Sleep 0.2;

_dialog = createdialog "EAT_messageBox_Dialog";

ctrlSetText [1001,"Send a server message"];

waitUntil {!dialog};
if(SendDialogText == "") exitWith {};

So the SendDialogText variable is set as an empty string which is the first line. (variable = "";).
And directly before your eventhandler gets executed, this script is stopped with exitWith {};

Look at the last line. It says when the SendDialogText is empty then stop this script (exitWith {};).

Link to comment
Share on other sites

  • 0

That did not work. I also tried to enter the message directly in the dialog and that did not work either. I looked at infistar's send message function and it has attachTo in there. I have seen a post by @ebayShopper talking about this having to do with passing things between server and client. I wonder if that has something to do with it. I don't know how that works though.

Link to comment
Share on other sites

  • 0
On 27. 5. 2017 at 4:30 PM, DAmNRelentless said:

Yeah but that's a titletext and in my opinion this is pretty ugly. I came to that problem when I tried to replace the default titletext WAI messages with dynamic messages because they look a lot better. So yeah, yours is working on serverside if you don't want to avoid messing with sending variables and stuff like that to the client.

Hi mate,

I assume you've already find out solution for your situation. But just in case, if I may, a have small notice for this subject.

I agree, WAI titletext msgs are pretty annoying (you know it when scoping target :)).
But, let's do not ivent the wheel: WAI core code base has great fully working script for remote msgs which of course uses public EH.
You can choose which type of msg you want to fire... all you need to do is use:

// src: original wai code, mission_winorfail in this case
RemoteMessage = ["radio","[RADIO] " + _msgstart];
publicVariable "RemoteMessage";

As you can see, EH takes 2 parameters: (1) type of msg; (2) msg text.
Now let's look into code bellow post and we can find out, there are these types of msgs:

  • system chat;
  • hint;
  • titleCut;
  • titleText;
  • dayz_rollingMessages;
  • BIS_fnc_dynamicText;

So, pick one to fits your needs and you good to go.
Once you have this small file installed and loaded in your init.sqf outside (!isDedicated) and (isServer) part, you can use it everywhere. Just fire pEH.

===

If you aim with your question was scoped on problem which you faced and you want to know what was wrong, the context is important.
I mean, even if your one line of code is correct, from the momment you passed an argument to it without showing context - nobody can answer your question I think.
You know it well, there could be no bug in your code, but other server settings (antihack included) can broke your work.
For example: I use almost exactly the same as you do, but there is no problem on my side.

Cheers guys...

EDIT: I'm sorry, I've just looked at WAI github src code and there is basic remote only. Seems I updated and expanded code before (I'm not sure...).
          Just tested (so be sure it's really working) and it is - if you use this code, be carefull about BIS dynTxt - it takes msg text parameter
         as array with two elements (see src)

EDIT2: Mystery about source code bellow solved: it comes from ZSC from @salival. You can see original here.

Just in case the code is here:

 

 

fnc_remote_message = {
  private ["_type","_message"];
  _type = _this select 0;
  _message = _this select 1;
  call {
    if (_type == "radio") exitWith {
      if (player hasWeapon "ItemRadio") then {
        if (player getVariable["radiostate",true]) then {
          systemChat _message;
          playSound "Radio_Message_Sound";
        };
      };
    };
    if (_type == "private") exitWith {if(getPlayerUID player == (_message select 0)) then {systemChat (_message select 1);};};
    if (_type == "global") exitWith {systemChat _message;};
    if (_type == "hint") exitWith {hint _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["<t size='0.40' color='#FFFFFF' align='center'>%1</t><br /><t size='0.70' color='#d5a040' align='center'>%2</t>",_message select 0,_message select 1],
        0,
        0,
        10,
        0.5
      ] spawn BIS_fnc_dynamicText;
    };
  };
};

"RemoteMessage" addPublicVariableEventHandler {(_this select 1) spawn fnc_remote_message;};
Link to comment
Share on other sites

  • 0
Just now, DAmNRelentless said:

@iben

This could be helpful for some people who wanna also change the ugly titletext but as I said, I have custom messages now. :)

Pointed. Well, done! And as I said, it could be helpful for you so you don't need to invent the wheel if code it's already there. It's of course valid just in case you have WAI isntalled (which I suppose you do in relation to your text).
Anyway, good for you buddy,

Cheers

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...