I'm having great difficulty getting scripts to run on all clients. Based on Ionos suggestion, I tried the following:
1. In the script fired by the Thrown/Fired eventhandler, I used a CreateUnit with init code (where the init code should execute on all clients). It looks like this:
_obj_to_replace = _this select 0;
_obj_to_create = _this select 1;
_thrower = _this select 2;
JBOY_molo_arr = JBOY_molo_arr + [[_obj_to_replace, _obj_to_create, _thrower ]];
publicVariable "JBOY_molo_arr";
// *****************************************************************
// ** We use the init clause in a createUnit statement to call
// ** call the JBOY_molo_client.sqf once for each client (and the server).
_stmt = format["dmy=[%1] execvm ""JBOY_MOLO\JBOY_molo_client.sqf"";",(count JBOY_molo_arr)-1];;
_logic = "logic" createUnit [ [0,0,0], group this, _stmt] ;
Note that I am using a global array (JBOY_molo_arr) to pass the 3 parameters I need, but only pass the index to the global array in the init statement (_stmt) of the createUnit statement.
My understanding of the init clause of CreateUnit, is that this code will execute on every client.
2. The JBOY_molo_client.sqf looks like this:
_molo_index = _this select 0;
player globalchat format ["run client code for index %1",_molo_index];
dmy= (JBOY_molo_arr select (_molo_index)) execvm "JBOY_MOLO\JBOY_molotov2.sqf";
The called JBOY_molotov2.sqf receives the 3 input parameters from global array, and then does all the Molotov cocktail code (i.e., replace grenade with bottle, start fires, burn men and vehicles, etc.).
Problem: It works fine in single player, but not in MP. In MP with a dedicated server and two clients, each client only sees the bottles and fires he throws. Also, I am only seeing the globalchat text "run client code for index x" once per throw. I expected to see this chat text three times (once for the server, and once for each of the 2 clients). So I am convinced the JBOY_molo_client.sqf is only being called once, rather than once per client (and once for the server).
Any suggestions how to fix this?