Jump to content
chasEE

Sharing variables between event handlers on dedicated servers.

Recommended Posts

Hello! Recently, I've been trying to do a remake of my "kill-feed" script, but have ran into some difficulties.

When trying out my script in single-player and on a locally hosted server, it works fine, but when I try my script on a dedicated server, it for some reason doesn't work. Let me explain.

 

 

Here is the code for a function called fn_killfeedAIEH.sqf, which assigns two event handlers to an AI passed in a previous function.

params ["_ai"];

if (isNull _ai) exitWith {};

_ai addEventHandler ["HitPart", {
	killfeedAIArray = _this;
}];

_ai addEventHandler ["Killed", {
	_killed = _this select 0;
	_killer = _this select 1;
	_array = killfeedAIArray;
	(format ["%1",_array]) remoteExec ["hint", _killer]; // Used to see if _array is defined (debug thing)
	[_killed,_killer,_array] remoteExec ["kill_fnc_killfeedCompile", _killer];
	//[_killed,_killer,killfeedAIArray] spawn kill_fnc_killfeedCompile; (ORIGIONAL)
}];

As I said before, this part works fine in single-player and on a locally hosted server, but as soon as I try to host it on a dedicated server, the "killfeedAIArray" will not transfer to the other event handler. I found this out when I added "(format ["%1",_array]) remoteExec ["hint", _killer];" to the "Killed" event-handler and it displays "any" instead of the HitPart array you would usually get.

 

 

One thing to note is that the event-handler HitPart IS working on a dedicated server; I found this out by adding "hint str _this" to the code:

_ai addEventHandler ["HitPart", {
	killfeedAIArray = _this;
	hint str _this;
}];

This would display the array on the client showing that it is in fact working as intended.

 

 

I have already tried "slowing" down the function to see if maybe "HitPart" was executing after "Killed". I used this alteration of the code to test it:

params ["_ai"];

if (isNull _ai) exitWith {};

_ai addEventHandler ["HitPart", {
	killfeedAIArray = _this;
}];

_ai addEventHandler ["Killed", {
	_killed = _this select 0;
	_killer = _this select 1;
	// Spawn a function to delay
	[_killed,_killer] spawn {
		_killed = _this select 0;
		_killer = _this select 1;
		sleep 1;
		_array = killfeedAIArray;
		(format ["%1",_array]) remoteExec ["hint", _killer];
		[_killed,_killer,_array] remoteExec ["kill_fnc_killfeedCompile", _killer];
	};
}];

The array still displayed "any", and after hours of messing around with no success, I've reached out to see if maybe one of you guys could provide me some insight. If you want to see the whole code, PM me or if there is enough requests I will edit the post.

Thanks! -chasEE

Share this post


Link to post
Share on other sites
18 hours ago, chasEE said:

_ai addEventHandler ["HitPart", { killfeedAIArray = _this; }];

This is AG,EL and must be assigned on the shooters machine.

 

18 hours ago, chasEE said:

_ai addEventHandler ["Killed", { _killed = _this select 0; _killer = _this select 1; // Spawn a function to delay [_killed,_killer] spawn { _killed = _this select 0; _killer = _this select 1; sleep 1; _array = killfeedAIArray; (format ["%1",_array]) remoteExec ["hint", _killer]; [_killed,_killer,_array] remoteExec ["kill_fnc_killfeedCompile", _killer]; }; }];

This is AL,EL and must be assigned where the unit is local.

 

19 hours ago, chasEE said:

One thing to note is that the event-handler HitPart IS working on a dedicated server; I found this out by adding "hint str _this" to the code:


_ai addEventHandler ["HitPart", {
	killfeedAIArray = _this;
	hint str _this;
}];

This would display the array on the client showing that it is in fact working as intended.

 

That will NOT work from a dedicated server as HitPart will not fire unless added on the shooters machine. Plus your using hint so it must of been added on the client for you to see the hint.

 

If you are running this server side where the AI is spawning then HitPart is never going to fire when on dedicated so killFeedAIArray is undefined.

You need to run HitPart on each client and Killed on the server ( HC, Where ever AI is spawned ).

From the kill_fnc_killFeedCompile on the client then grab the contents of killFeedAIArray.

Or use a MPEventHandler of MPKilled on the clients machine to keep both events firing local to the shooter and only process the event if the shooter is the local client.

Share this post


Link to post
Share on other sites

Just for clarification on Larrow's post:

 

Arguments of this scripting command have to be local to the client the command is executed on - AL means the arguments of the command must be local to the client executing it.

Arguments of this scripting command don't have to be local to the client the command is executed on - AG means the arguments of the command can be global.

 

Effects of this scripting command are not broadcasted over the network and remain local to the client the command is executed on - EL means the effects of the command will be local.

Effects of this scripting command are broadcasted over the network and happen on every computer in the network - EG means the effects of the command will be global.

 

The above icons can be found on the relevant Wiki pages for commands/event handlers.

  • Like 2

Share this post


Link to post
Share on other sites
On 3/28/2017 at 3:50 AM, chasEE said:

addEventHandler ["Killed"

 

for starters you can use addMPEventHandler and "MPKilled" to avoid remoteExec unnescessary

Share this post


Link to post
Share on other sites
On 3/29/2017 at 11:05 AM, killzone_kid said:

 

for starters you can use addMPEventHandler and "MPKilled" to avoid remoteExec unnescessary

Hi killzone, I'm willing to do this myself on my end since I'm seeing the remoteExec being filtered by wasteland, I assume if I were to replace all addEventHandler ["Killed" with addMPEventHandler ["MPKilled" that will stop the remoteExec?

Apologies for my ignorance!

Share this post


Link to post
Share on other sites

This is ChasEE's Script http://www.armaholic.com/page.php?id=31562

Im wondering if it were possible to create more lines in the killfeed, for example when you kill an ai you get one line that shows

you killed the ai his name and the gun you are using or what killed him, what i'd like to do is add more instances of the same line, so for each new kill a new line would be added, so say

i killed 4 guys in a small area and the first kill would be at the top while the others are added below, the settings for the time of display you can set:

 

killfeed_board_time = 3; // How many seconds one name can be on the board. DEFAULT: 6

on the same script and below this line is the following:

if (killfeed_switch isEqualTo 1) then {
    killfeed_board = [];
    killfeed_picture = [];
    201 cutRsc ["killfeed_board", "PLAIN"];
    200 cutRsc ["killfeed_picture", "PLAIN"];
    [] spawn kill_fnc_killfeedMain;
};

can someone tell me what the      if (killfeed_switch isEqualTo 1) then {

isEqualTo 1 means?

Does that mean if i were top change that number it would add more feeds, or does it mean something else?

 

I know its ChasEE script and my only intention is to update it for my mission im working on, but chasEE hasn't been around

since 2017 unless someone has an email, then i'll contact him.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×