OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started 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
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
logic globalRadio "RadioMsg1";
sleep 2;
logic globalRadio "RadioMsg2";
Place a Game Logic named "logic". Make a trigger and put this in the activation:
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 ?
-
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:
// 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:
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!
-
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 ?
-
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.
-
@ 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 !
-
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