OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: Wiggum on 04 Jul 2010, 20:21:34

Title: How to get "globalRadio" working in MP ?
Post by: Wiggum on 04 Jul 2010, 20:21:34
I do some conversation with globalRadio in my mission:

Define the messages in the description.ext
Code: [Select]
class CfgRadio
{
 sounds[] = {};
  class RadioMsg1
  {
   name = "";
    sound[] = {};
    title = "John Doe: Hey!";
  };

  class RadioMsg2
  {
   name = "";
   sound[] = {};
   title = "Bob: How's it going?";
  };
};

Make a chat.sqf
Code: [Select]
logic globalRadio "RadioMsg1";
sleep 2;
logic globalRadio "RadioMsg2";

Place a Game Logic named "logic". Make a trigger and put this in the activation:
Code: [Select]
nul=execVM "chat.sqf";
[/QUOTE]

It works fine in SP but for some reason it will only show up on the Host in MP.
So how to get it working in MP too ?
Title: Re: How to get "globalRadio" working in MP ?
Post by: Loyalguard on 05 Jul 2010, 04:44:28
I would recommend using the trigger to broadcast a public variable to all machines that will in turn fire a public variable event handler that will execute the chat script. 

1) Add the following to the init.sqf:

Code: [Select]
// init.sqf

// Add a public variable event handler that will execute chat.sqf when the public variable startChat is broadcasted. 

"startChat" addPublicVariableEventHandler {_nul = [] execVM "chat.sqf";};

You can name startChat anything as long as it is a global variable. Just be consistent and use of a tag is recommended

2) Make your trigger activation look like this:

Code: [Select]
nul = [] execVM "chat.sqf"; startChat = true; publicVariable "startChat";

So, your activation line now does the following. 1. Executes the chat script locally since public variable event handlers do not fire on the same machine that broadcasts the PV.  This also ensures SP compatiblity again since PVEHs don't work in SP. 2. Initializes a PV to broadcast. 3. Broadcast the PV so that the PVEH created in the init.sqf will fire and execute chat.sqf on all machines. 

This is untested and excuse any typos but should work. Good luck!
Title: Re: How to get "globalRadio" working in MP ?
Post by: Wiggum on 05 Jul 2010, 14:54:14
Thanks Loyalguard !
It works but i still have a problem...

The message is show twice on the host and at the client. I checked if i started the script twice accidently but no, should be correct.

Any ideas ?
Title: Re: How to get "globalRadio" working in MP ?
Post by: nominesine on 05 Jul 2010, 15:00:10
A game logic only exists on the server. That was most likely the cause behind your original problem. Solution: Place a regular unit on the map and let him say the globalRadio command instead. Execute the order from a trigger. That always works for me. Even in MP.
Title: Re: How to get "globalRadio" working in MP ?
Post by: Wiggum on 05 Jul 2010, 15:29:03
@ nominesine

Yes, now it works...
I did everything like in my first post exept that i changed the Game Logic with a Chicken... :D

Thanks !
Title: Re: How to get "globalRadio" working in MP ?
Post by: nominesine on 06 Jul 2010, 10:09:22
Chickens are underestimated in the ArmA universe  ;)

EDIT: If it's a really important chicken you may want to place him in a remote corner of the map (to prevent the players from killing him/her/it with a stray shot). Or make the little critter invulnerable with allowDamage false