Jump to content
aie-boshell

Event Handler - Handleheal - Dedicated Server Help

Recommended Posts

Hello, I'm having an issue getting this event handler to fire on dedicated server.  Everything works perfect in player hosted server.  I've tried to use the event handler with "remoteexec" but cannot seem to get that to work on player hosted or dedicated servers.  I do believe "remoteexec" is the answer but I somehow have it setup wrong.  

 

Here are the codes ran from initserver.sqf

 

This one works exactly as I want it to on player hosted server but does nothing on a dedicated server.  

while {true} do {sleep 5; {_x removeallEventHandlers "Handleheal"} forEach allUnits;{_x addEventHandler ["Handleheal", {_this select 1 addScore 1; _this select 0 disableai "move"; fire_enableaimoveforheal_trigger_1 = true}]} forEach allUnits };

This one above works exactly as I want it to on player hosted server but does nothing on a dedicated server.  

while {true} do {[{_x ["Handleheal", {_this select 1 addScore 1; _this select 0 disableai "move"; fire_enableaimoveforheal_trigger_1 = true}foreach allunits]] remoteExec ["addEventHandler", 0, true]  };

This one above was my progress to get the Event Handler to work on dedicated server using "remoteexec".  I cannot get this one to even do anything on player hosted server so I'm pretty sure I have some type of error in there but I'm getting no error code.  

 

Anyone that attempts to help is very much appreciated :-)

Share this post


Link to post
Share on other sites

formatting can help a bit, 

 

it will make it easier to work with too.

 

execute on server at init

[
	[],
	{
		
		/*/ do code here /*/
	
	
	}
] remoteExec ['call',0,true];

 

Share this post


Link to post
Share on other sites
[
	[_nameofunit, ["Handleheal", {_this select 1 addScore 1; _this select 0 disableai "move"; fire_enableaimoveforheal_trigger_1 = true],
	{
		_this select 1 addScore 1;
		_this select 0 disableai "move";
		fire_enableaimoveforheal_trigger_1 = true
	
	
	}
] remoteExec ['addeventhandler',0,true];

Thank you very much for the response, Quicksilver.  Do you mean like this above?  I put that in init.sqf with _nameofunit as name of a unit and it still doesn't work.  No error message either.  

 

EDIT: I'm also reading info about commands needing to be defined in cfgremoteexec.  Might this be the issue?  I have no event handlers defined at this time and am unsure if that is necessary.

Edited by aie-boshell
Added information

Share this post


Link to post
Share on other sites

You have a problem with endless loop on every units.

run this code on each PC: (init.sqf for example)

[] spawn {

  while {true} do {

    {

      _x addEventHandler ["handleHeal", { < code> } ];

      _x setVariable ["treated", true];

    } forEach (allUnits select {!(_x getVariable ["treated",false])});
   sleep 1;

  }

};

 

The  <code> is executed locally (here server). You must be remoteExec if needed. This EH is AG EL. If you need to manage some variable or behavior on wounded:

< code>  remoteExec ["call", (_this select 0)]

on shooter:

< code>  remoteExec ["call", (_this select 3)]

Example:

{"you are healed!" remoteExec ["hint",(_this select 0)]; [_this select 1,{_this addRating 1000}] remoteExec ["call", (_this select 1)] }

 

Nota: I don't know why "handleHeal" must run on every PC (locality) but "handleDamage" can run from server only... (tested on hosted + client)

 

  • Like 1

Share this post


Link to post
Share on other sites

You guys are both fantastic, and a perfect example of why Arma is like no other experience on earth; the community :-)  

 

16 hours ago, pierremgi said:

You have a problem with endless loop on every units.

run this code on each PC: (init.sqf for example)

[] spawn {

  while {true} do {

    {

      _x addEventHandler ["handleHeal", { < code> } ];

      _x setVariable ["treated", true];

    } forEach (allUnits select {!(_x getVariable ["treated",false])});
   sleep 1;

  }

};

 

The  <code> is executed locally (here server). You must be remoteExec if needed. This EH is AG EL. If you need to manage some variable or behavior on wounded:

< code>  remoteExec ["call", (_this select 0)]

on shooter:

< code>  remoteExec ["call", (_this select 3)]

Example:

{"you are healed!" remoteExec ["hint",(_this select 0)]; [_this select 1,{_this addRating 1000}] remoteExec ["call", (_this select 1)] }

 

Nota: I don't know why "handleHeal" must run on every PC (locality) but "handleDamage" can run from server only... (tested on hosted + client)

 

This post above gave the solution to my problem, thank you very much, pierremgi :-)

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

×