Home   Help Search Login Register  

Author Topic: JIP and Syncing  (Read 2517 times)

0 Members and 1 Guest are viewing this topic.

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
JIP and Syncing
« on: 16 Jul 2009, 14:44:51 »
I know there are a variety of threads with questions relating to JIP and Syncing about the place, but none of them are really comprehensive enough (and things like Mr Murray's guide don't touch on this particular topic - unless I've made a huge oversight).  Whilst I'm hoping to learn from this topic, I also hope this thread can serve as somewhat of a reference for those searching in the future.

I've always got the impression that in my MP missions, I'm not really taking advantage of the 'best' ways to sync information between clients, and to JIP'ing clients.  At the present time, I tend to update publicVariables to play a sound, or something like that (e.g. have a script waiting for a change in a publicVariable, and then responding based on the new value - but I see that's probably a long-winded way with addPublicVariableEventHandler being available...).  The majority of my scripting is either server-side, of global effect, or for single-player-esque situations... but my MP scripting often ends up buggy and inconsistent due to a lack of knowledge!

What I'm asking for are simple suggestions/code samples about JIP and Syncing scripts for MP missions.  I've listed some scenarios, and commands below, and 'tutorial-style' information and relevant examples would be welcomed.

What are the 'standard' techniques for doing tasks such as:
  • Performing local actions on all clients.
  • Propagating/Removing action menu items properly.
  • Ensuring JIP players receive the correct mission variables, and are updated to the current mission state.
  • Ensuring respawning players are updated to current mission state (e.g. re-sync'ing editor-based synchronisations, etc.)
  • etc.

Additionally, what is the usefulness/'correct' usage of commands such as:

Thanks in advance ;)
« Last Edit: 16 Jul 2009, 14:47:34 by JamesF1 »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: JIP and Syncing
« Reply #1 on: 17 Jul 2009, 14:57:39 »
The problem, I'm afraid, is that dealing with MP and MP issues is about 30% of A2 scripting (and is most of the "advanced" part of A2 scripting). Saying "just explain MP" is a bit too wide a subject.

We did cover setVehicleInit, and a lot of other topics, in our MP tutorial, but since it was written before addPublicVariableEventHandler was added to the game, a lot of the things in there are no longer relevant.

One of the goals of CBA is to provide a higher level framework for dealing with the game, including MP scripting. Many other systems have tried to provide a framework like this before (including BIS in the MP framework module), but they are often more complicated to use than doing it by hand or badly documented or not ubiquitous in the community (CBA is still not perfectly documented, but if you have problems with it, then users need to tell us; CBA is also not widespread since it is very new, but hopefully that can change!).

However, if you have a library that deals with something for you, why go crazy trying to do it yourself? (before you complain that you'd rather do it by hand, I'll ask why you are using A2 as your graphics engine if you could make an engine yourself in DirectX ;) ). And still, I'm not saying, "don't learn the low-level commands", just saying that if there were a better framework available I'd use it and not learn the low-level commands myself!

EDIT: And again, not stopping other people giving direct answers to this question. I just offered one way to go with it...
« Last Edit: 17 Jul 2009, 15:03:19 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: JIP and Syncing
« Reply #2 on: 17 Jul 2009, 15:34:59 »
Whilst I'm with you 100% on not duplicating efforts, and making use of higher-level functionality if it's available, I'm also a strong proponent of understanding the underlying methodologies that produce high-level functionality.

This particular topic was more intended at addressing two points: firstly, what a good MP-compatible mission framework would look like at a high level (and, yes, I am aware of CBA... and am already beginning to use it) and, secondly, how the underlying lower-level commands actually work to achieve MP-compatibility.

Anything from a simple planning diagram for a framework, to more detailed explanations, are fully welcome... anything that serves to help people understand MP scripting in Arma2 more fully  :good:

EDIT: Not trying to say your post is irrelevant, but merely clarifying my own POV :)

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: JIP and Syncing
« Reply #3 on: 25 Aug 2009, 21:12:27 »
I have seen some mission makers adding a blank sqf called JIPcompatible. However, is there any standard for making JIP-compatible missions?

I am just looking for the basics, but I can't find any resources or a simple template for what is required.

Offline granQ

  • Contributing Member
  • **
    • Anrop.se
Re: JIP and Syncing
« Reply #4 on: 30 Aug 2009, 11:02:36 »
it would be nice with more info on this topic.

JIP is so hard sometimes, been using publicvariables but still doesn't seem that works for the player that still missing updates in briefing and so on.
Cura Posterior

Offline sardaukar17

  • Members
  • *
Re: JIP and Syncing
« Reply #5 on: 27 Sep 2009, 02:42:40 »
My 2 cents:

My understanding is that anything that involves creating anything is typically something you want happening on the server side and anything that is available to any Player is something you want happening on all the clients.. or atleast the ones that you want to have the options.
For the server side of things I like many others I am sure use a line like this:
Code: [Select]
?!(local Server): Goto "exit"
For items where I only want a particular Player unit (or Client) I use a line like this:
Code: [Select]
?!(Player==Engineer): goto "exit"
With each of these options all the computers are running the script but most simply are forced to exit the script right at the start. (Or atleast at the line I only want the server or specific unit to execute)

Somthing else I use allot is updating local names through Global Arrays. If I have multiple scripts that need to know what the new name of a vehcile that has been respawned or more specifically a set of units, vehicles, buildings whatever I add a new line under it that redifines the global array names. The names can be local in the creation script but can be pulled out by any script from the array. Keep in mind all of this is SQS. I haven't made the jump to SQF yet.


-Edit-
I kind of forgot to explain what all this has to do with JIP... Basically if the server is doing the creating it doesn't matter who joins or when. If the scripts running on the client computer did just JIP then thier global arrays will be updated by The scripts being executed on thier machines that constantly pull the names from the global array. THus there is always up to date information to be pulled from the Global arrays.
The master array would start somthing like this:
Code: [Select]
_bunker=_this select 0
_Factory=_this select 1
_Tower=_this select 2

buildings=[_bunker,_factory,_tower]
Anything associated with the creation of any of these buildings would be redefined at the end by the last line there Just after creation
Code: [Select]
_Bunker = "WarfareBCamp" createVehicle getpos Bunkerloc
_Factory = "WarfareBDepot" createvehicle getpos Factoryloc
_Tower = "Land_telek1" createvehicle getpos Towerloc
~1
Buildings=[_Bunker,_Factory,_Tower];

your Script needs to pull the names from the array like this:
Code: [Select]
_bunker=Buildings select 0
_Factory=Buildings select 1
_Tower=Buildings select 2
goto "loop"
« Last Edit: 27 Sep 2009, 03:01:47 by sardaukar17 »