OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: derogarg on 30 Apr 2008, 23:26:25

Title: Broadcasting local eventhandlers globally on dedicated server
Post by: derogarg on 30 Apr 2008, 23:26:25
Trying to make a simple mission where when a popup target (t1) is "hit" by a player (p1), it does an addScore 1. Simple enough for SP and local hosted missions. However, when run on a dedicated server, I can't figure out how to get the hit eventhandler to work since it's local.

Code: (init.sqs) [Select]
shooter = "";
Code: (added to init line of popup target t1) [Select]
t1 addeventhandler ["hit",{shooter = _this select 1; publicVariable "shooter";shooter addscore 1;}];
I've also tried to stick that whole publicVariable line in a separate sqs file and launch it via "this exec" from the popup's init line. Adding it directly to init.sqs doesn't work either. I'm assuming this is because despite the publicVariable, the line is still in reference to the popup target itself and not the player, and thus still remains local?

Hopelessly stuck, help!
Title: Re: Broadcasting local eventhandlers globally on dedicated server
Post by: Mandoble on 30 Apr 2008, 23:36:21
AddScore has local effects, so probably you need to run a monitor script in every client (spawn it directly from init.sqf)

Probably something else you need something like:
Code: [Select]
shooter = objNull;
while {true} do
{
   waitUntil {!isNull shooter};
   shooter addScore 1;
   shooter = objNull;
};
Title: Re: Broadcasting local eventhandlers globally on dedicated server
Post by: derogarg on 01 May 2008, 00:21:42
AddScore has local effects, so probably you need to run a monitor script in every client (spawn it directly from init.sqf)

Can you clarify this? How would this look?
Title: Re: Broadcasting local eventhandlers globally on dedicated server
Post by: Mandoble on 01 May 2008, 01:18:31
Code: [Select]
// init.sqf
[]spawn
{
   shooter = objNull;
   while {true} do
   {
      waitUntil {!isNull shooter};
      shooter addScore 1;
      shooter = objNull;
  };
};
Title: Re: Broadcasting local eventhandlers globally on dedicated server
Post by: derogarg on 01 May 2008, 01:33:00
Working perfectly. Thanks so much Mandoble!