Jump to content
  • 0

Why 'dayz_rollingMessages' not work?


WLF

Question

Anybody home? :)

This is part of Donnovan's Convoy script:

//Protect Vehicles from players until all crew is off
donn_casca_getIn = {
	_motor = _this select 0;
	_unit = _this select 2;
//	_msg = "This vehicle will disappear on server restart!";
	if (isPlayer _unit) then {
		_carGroup = _motor getVariable ["car_group",GrpNull];
		_allOff = true;
		{if (alive _x && assignedVehicle _x == _motor) then {_allOff = false;};} forEach units _carGroup;
		if (!_allOff) then {_unit action ['getOut', _motor];};
		if (_allOff) then {
			_motor setFuel 0.5;
			_motor removeAllEventHandlers "handleDamage";
			_motor removeAllEventHandlers "Killed";
			_motor removeAllEventHandlers "getIn";
			_motor removeAllEventHandlers "getOut";
			_motor addeventhandler ["handleDamage",{_this call fnc_veh_handleDam}];
			_motor addeventhandler ["killed",{_this call fnc_veh_handleKilled}];
			PVDZE_veh_Init = _motor;
			publicVariable "PVDZE_veh_Init";
			_nil = [nil,_unit,"loc",rTITLETEXT,"\n\nThis vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
//			_msg call dayz_rollingMessages;
			_motor addEventHandler ["getIn",{
				_unit = _this select 2;
				_nil = [nil,_unit,"loc",rTITLETEXT,"\n\nThis vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
//				_msg call dayz_rollingMessages;
			}];
		};
	};
};

WHY??? Why when I change the messsage output to "call dayz_rollingMessages" (commented now) it doesn't work? I don't see this messages.

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0
11 hours ago, WLF said:

Anybody home? :)

This is part of Donnovan's Convoy script:


//Protect Vehicles from players until all crew is off
donn_casca_getIn = {
	_motor = _this select 0;
	_unit = _this select 2;
//	_msg = "This vehicle will disappear on server restart!";
	if (isPlayer _unit) then {
		_carGroup = _motor getVariable ["car_group",GrpNull];
		_allOff = true;
		{if (alive _x && assignedVehicle _x == _motor) then {_allOff = false;};} forEach units _carGroup;
		if (!_allOff) then {_unit action ['getOut', _motor];};
		if (_allOff) then {
			_motor setFuel 0.5;
			_motor removeAllEventHandlers "handleDamage";
			_motor removeAllEventHandlers "Killed";
			_motor removeAllEventHandlers "getIn";
			_motor removeAllEventHandlers "getOut";
			_motor addeventhandler ["handleDamage",{_this call fnc_veh_handleDam}];
			_motor addeventhandler ["killed",{_this call fnc_veh_handleKilled}];
			PVDZE_veh_Init = _motor;
			publicVariable "PVDZE_veh_Init";
			_nil = [nil,_unit,"loc",rTITLETEXT,"\n\nThis vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
//			_msg call dayz_rollingMessages;
			_motor addEventHandler ["getIn",{
				_unit = _this select 2;
				_nil = [nil,_unit,"loc",rTITLETEXT,"\n\nThis vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
//				_msg call dayz_rollingMessages;
			}];
		};
	};
};

WHY??? Why when I change the messsage output to "call dayz_rollingMessages" (commented now) it doesn't work? I don't see this messages.

I'm guessing because that script is running server side and not client side like dayz_rollingMessages would be.

Link to comment
Share on other sites

  • 0
6 minutes ago, WLF said:

Ok, thanx!

Worth noting, if you run my ZSC or @JasonTM WAI updates, you can use something similar to this instead:

RemoteMessage = ["rollingMessages","This vehicle will disappear on server restart!"];
(owner _unit) publicVariableClient "RemoteMessage";

 

Link to comment
Share on other sites

  • 0
22 hours ago, salival said:

Worth noting, if you run my ZSC or @JasonTM WAI updates, you can use something similar to this instead:


RemoteMessage = ["rollingMessages","This vehicle will disappear on server restart!"];
(owner _unit) publicVariableClient "RemoteMessage";

 

Yes, I'll try it, thanx.

Link to comment
Share on other sites

  • 0

also it may be  because "_msg = ***;" and "_msg call dayz_rollingMessage" are commented out everywhere .

 

//Protect Vehicles from players until all crew is off
donn_casca_getIn = {
	_motor = _this select 0;
	_unit = _this select 2;
//	_msg = "This vehicle will disappear on server restart!";
	if (isPlayer _unit) then {
		_carGroup = _motor getVariable ["car_group",GrpNull];
		_allOff = true;
		{if (alive _x && assignedVehicle _x == _motor) then {_allOff = false;};} forEach units _carGroup;
		if (!_allOff) then {_unit action ['getOut', _motor];};
		if (_allOff) then {
			_motor setFuel 0.5;
			_motor removeAllEventHandlers "handleDamage";
			_motor removeAllEventHandlers "Killed";
			_motor removeAllEventHandlers "getIn";
			_motor removeAllEventHandlers "getOut";
			_motor addeventhandler ["handleDamage",{_this call fnc_veh_handleDam}];
			_motor addeventhandler ["killed",{_this call fnc_veh_handleKilled}];
			PVDZE_veh_Init = _motor;
			publicVariable "PVDZE_veh_Init";
			_nil = [nil,_unit,"loc",rTITLETEXT,"\n\nThis vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
//			_msg call dayz_rollingMessages;
			_motor addEventHandler ["getIn",{
				_unit = _this select 2;
				_nil = [nil,_unit,"loc",rTITLETEXT,"\n\nThis vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
//				_msg call dayz_rollingMessages;
			}];
		};
	};
};
Link to comment
Share on other sites

  • 0

and, if you uncomment them, it may still not work.

the "scope" of variable _msg is different, so _msg in EventHandler 

			_motor addEventHandler ["getIn",{
				_unit = _this select 2;
				_nil = [nil,_unit,"loc",rTITLETEXT,"\n\nThis vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
//				_msg call dayz_rollingMessages;
			}];

may be different variable from others.

 

Link to comment
Share on other sites

  • 0
On 4/26/2019 at 1:15 PM, Schalldampfer said:

also it may be  because "_msg = ***;" and "_msg call dayz_rollingMessage" are commented out everywhere .

Because its added, verifying and then commented by me.

On 4/26/2019 at 1:17 PM, Schalldampfer said:

and, if you uncomment them, it may still not work.

the "scope" of variable _msg is different, so _msg in EventHandler 

may be different variable from others.

 

No. Variables into the "root" scopes have access to "child" scopes, but not vice versa.

 

Link to comment
Share on other sites

  • 0

Schalldampfer is correct. An eventhandler cannot see from its sopce a private variable like this.

_motor addEventHandler ["getIn",{
	_unit = _this select 2;
	_nil = [nil,_unit,"loc",rTITLETEXT,"\n\nThis vehicle will disappear on server restart!","PLAIN DOWN",5] call RE;
	_msg call dayz_rollingMessages;
}];

If you still would like to fix it you have to hardcode it there. Like this:

_motor addEventHandler ["getIn",{ 
	_unit = _this select 2; 
	_nil = [nil,_unit,"loc",rTITLETEXT,"\n\nThis vehicle will disappear on server restart!","PLAIN DOWN",5] call RE; 
	"This vehicle will disappear on server restart!" call dayz_rollingMessages; 
}];

But in this script it does not matter because it is called from the server. dayz_rollingMessages is a client only function which cannot be called from the server. Salival said this already.

Link to comment
Share on other sites

  • 0
On 4/25/2019 at 1:15 PM, salival said:

Worth noting, if you run my ZSC or @JasonTM WAI updates, you can use something similar to this instead:


RemoteMessage = ["rollingMessages","This vehicle will disappear on server restart!"];
(owner _unit) publicVariableClient "RemoteMessage";

 

Ok, I use RemoteMessage and it work fine for simple string. But how send to RemoteMessage concatenated localized strings?

stringTable.xml:
<Key ID="STR_CL_AC_GENERAL_SON">
	<English>You killed the general son!</English>
	<Russian>Вы убили сына генерала!</Russian>
</Key>
<Key ID="STR_CL_AC_COMBO">
	<English>Combo kill level</English>
	<Russian>Комбо x</Russian>
</Key>
_genSonTxt = "";
if (random 100 > 90) then {
	_genSonTxt = (localize "STR_CL_AC_GENERAL_SON") + " ";
};
_comboTxt = "";
...
_newLvl = 333; // for example
_comboTxt = (localize "STR_CL_AC_COMBO") + " " + str _newLvl + "!";
...
_txt = "";
_txt = _genSonTxt + _comboTxt;
if (_txt != "") then {
	RemoteMessage = ["rollingMessages",_txt];
	(owner _player) publicVariableClient "RemoteMessage";
};

 

Link to comment
Share on other sites

  • 0

You cannot localize and concatenate the strings server side. Doing that will localize to the server's location, not the client. The string names and arguments have to be sent to the client. I wrote a function for the remote messaging system that will detect localized strings and format them if they are sent as an array with arguments.

https://github.com/worldwidesorrow/WICKED-AI/blob/master/dayz_code/compile/remote_message.sqf#L1-L37

Add %1 to the "Combo kill level" string and include the exclamation point.

<Key ID="STR_CL_AC_GENERAL_SON">
	<English>You killed the general son!</English>
	<Russian>Вы убили сына генерала!</Russian>
</Key>
<Key ID="STR_CL_AC_COMBO">
	<English>Combo kill level %1!</English>
	<Russian>Комбо x %1!</Russian>
</Key>

I'm not quite sure of your code to send the messages. Rolling messages are not set up for multi-dimensional arrays so two messages will have to be sent. This code should work if I understand what you are trying to do. One message will appear over the top of the other instead of on one line.

if (random 100 > 90) then {
	RemoteMessage = ["rollingMessages","STR_CL_AC_GENERAL_SON"];
	(owner _player) publicVariableClient "RemoteMessage";
};

_newLvl = 333; // for example

RemoteMessage = ["rollingMessages",["STR_CL_AC_COMBO",_newLvl]];
(owner _player) publicVariableClient "RemoteMessage";

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...