Home   Help Search Login Register  

Author Topic: Broadcasting local eventhandlers globally on dedicated server  (Read 1690 times)

0 Members and 1 Guest are viewing this topic.

Offline derogarg

  • Members
  • *
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!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
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;
};

Offline derogarg

  • Members
  • *
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?
« Last Edit: 01 May 2008, 01:09:04 by derogarg »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Code: [Select]
// init.sqf
[]spawn
{
   shooter = objNull;
   while {true} do
   {
      waitUntil {!isNull shooter};
      shooter addScore 1;
      shooter = objNull;
  };
};

Offline derogarg

  • Members
  • *
Working perfectly. Thanks so much Mandoble!