I was thinking of writing a tutorial on this, because it took awhile to figure out.
Suppose you have a dedicated server, right?. A client activates the radio command for an airstrike, and then clicks on the map.
The map click is registered on the client computer, and the server doesn't know anything about it. You need to let the server know that a map click has occurred.
Rather than the radio trigger calling airstrike.sqs, make it call a new script called 'triggerstrike.sqs' and in that script have something like the following:
; the event handler thingy is here (can't remember it exactly)
onmapclick{}
_pos = _this select 0
var_x = _pos select 0
var_y = _pos select 1
var_triggerstrike = true
publicvariable "var_x"
publicvariable "var_y"
publicvariable "var_triggerstrike"
now, make another file called 'server_loop.sqs', and in that file put:
? !(local Server) : exit
var_triggerstrike = false
#loop
? !var_triggerstrike : goto "nostrike"
; a call for an airstrike has been received
[[var_x,var_y]] exec "airstrike.sqs"
; this will activate the trigger (on all machines) that will launch the airstrike on the clients
var_doairstrike = true
publicvariable "var_doairstrike"
var_triggerstrike = false
#nostrike
~0.1
goto "loop"
Call server_loop.sqs from init.sqs (so it starts running right at the start of the mission). Also make a game logic unit in the mission editor and name it 'Server'. server_loop.sqs will only run on the server computer.
now make another trigger in the actual mission, and make it activate on 'var_doairstrike'. In the on activation field put:
var_doairstrike = false; [[var_x,var_y]] exec "airstrike.sqs"
Finally, you need to edit airstrike.sqs. We need to do this so that the server does not run the airstrike script twice (once in server_loop.sqs and once thanks to the above trigger).
Put the following at the very top:
? var_airstrike_done : exit
var_airstrike_done = true
So, to summarise:
- Two triggers, one that calls triggerstrike.sqs when the map is clicked and another that calls airstrike.sqs when var_doairstrike == true.
- Three new/modified scripts, triggerstrike.sqs (sends global variables containing details of the strike to the server), server_loop.sqs (called from init.sqs and detects the global variables and triggers the strike on the server, and then triggers the strike on all clients), and airstrike.sqs (slightly modified so it can't be executed twice).
- One gamelogic unit named 'Server' to be used by server_loop.sqs.
This is all written from memory, but i can put together an example mission this weekend if you would like.
Two points to remember:
- You should only be creating new vehicles on the server (with the createVehicle command, not camCreate as is used in the airstrike script).
- Events (like the map click event) happen only on a single client computer, you need to use publicvariable somehow to make the server aware of what is going on.
It doesn't hurt to run airstike.sqs on all clients however because that way everyone sees the sideChat messages.
I got the napalm version working in multiplayer also, but that was a little more complicated (the napalm has to be created on the the clients for some reason, but the clients need to track the bombs created on the server to know when to launch the napalm. messy). :-X
Like I said, this is all off-the-cuff, but i'll post an example mission with both MP LGB's and napalm in the next few days (when I get a chance).
Clear as mud? :-\
ps you'll need to add some more variables and checks if you want the airstrike to work multiple times in MP - what i have put here will only work once (if at all given it is all from memory). :P