Home   Help Search Login Register  

Author Topic: createVehicled objects and Say command in multi-player  (Read 1757 times)

0 Members and 1 Guest are viewing this topic.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Greetings,

Benamaina has reported the following MP problems with my Molotov Cocktail script.  The problems are:

Quote
people only see their own flame or bottle, not the rest of the people's, also the sounds dont work,

A few MP questions:

1.  The main script JBOY_molotov.sqf is called via a FIRED eventhandler.  I see in the BIKI that Fired EHs are Global. So that means they should run on all clients correct?

2. The bottle object (and a gamelogic and a bullet) are created by this script via CreateVehicle, which the BIKI also says is Global.  So shouldn't these objects be created on all clients?

Note that at the top of main script I have this line:

Code: [Select]
if (local _obj_to_replace) then {exit;};

This should guarantee the code only executes on the server, and since CreateVehicle is global, all clients should see the objects?

What about the code that sets the setdirs, setvelocitys, and setposs the objects along?  Currently I only execute that on the server...

3. I see that Say command is local, and since my scripts currently only execute on the server, I understand now why the clients don't hear everything.

Do I have to add conditional logic all through my scripts so that some code executes on server once, and others execute on all clients?

Any suggestions would be appreciated.

I tried to download the MP guide from OFPEC Editing Resources page, but that download is not working for me (in IE or Firefox).  The download launches a second page that provides little info and says "Done", but I do not get the download.

Thanks all!
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline i0n0s

  • Former Staff
  • ****
Re: createVehicled objects and Say command in multi-player
« Reply #1 on: 22 Dec 2008, 19:25:31 »
To 1: The Throw-Fire-Eventhandler is not global and is only fired when local to the unit.
Is a bug which was encountered when creating the "AI can't see me smoke".

To 2:
createVehicle is global, so every one sees the bottle.

setDir, setPos etc. are global.

And say is local.

To solve all of this:
#Start, no script active
#Client throws grenade:
  #Grenade gets replaced by bottle, code runs on that client
  Either this special client or the server is now making sure that the bottle flies like it should do.
  #You use the init of the createVehicle to run the FX on all clients
  #Server/"throw client" is looking after AI and makes the damage


Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: createVehicled objects and Say command in multi-player
« Reply #2 on: 02 Jan 2009, 02:23:16 »
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:

Code: [Select]
_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:

Code: [Select]
_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?
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: createVehicled objects and Say command in multi-player
« Reply #3 on: 02 Jan 2009, 02:50:15 »
Crate your vehicle, then use SetVehicleInit to set the command you want to be executed everywhere and then execute processInitCommands.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: createVehicled objects and Say command in multi-player
« Reply #4 on: 02 Jan 2009, 06:35:35 »
Edit:  Thanks Mandoble.  Using your suggestions, I have now proved to myself that code executes 3 times (2 clients, one server).
« Last Edit: 02 Jan 2009, 06:58:21 by johnnyboy »
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...