OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Alan34 on 30 Nov 2002, 17:32:56
-
Has anyone had trouble using Skumballs airstrike script in a MP mission? Seems that on the host (server) can use the script. When a client machine player trys to call the airstrike, the plan never comes in. I remember an old issue with scripts on host vs client machines that was fixed in a patch a long time back. We are using Resistance 1.90 and maybe this problem is back.
-
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
-
Hey, thanks a ton for the detailed explanation and solution. I did a quick test and when the strike is called it does everything right away, all sidechats and the bombs dropped before any Mapclick to designate where the bombs should go. I will check/test some more in case I messed up making the modifications. Look forward to seeing your sample mission when you have time. Thanks again:)
-
hmmm - issues.
are you sure you have the unit named strikePilot on your map somewhere?
remember also that there will be two triggers.
1) The original trigger (with the onmapclick event), that calls triggerstrike.sqs, and
2) The new trigger that activates on 'var_doairstrike'.
Like I said, I am still cuffing this because I don't have access to my game PC until next Monday.
I struggled with it for awhile, but eventually found a method that works. It's been two weeks since your original post anyway, so i guess another couple of days won't matter too much ;D
rest assured it can be done, because I use it in my latest 'nam team DM mission and it works.
until next monday,
snYpir :-*
-
Ok, my bad. I had set up one of the triggers wrong. Works fine in the editor now. Will test in MP next. Thanks again:)
-
I noticed your topic and got a few questions.
Where do I get that airstrike script and isn't there a chance that the fuel will run out for the pilot? And can I place out a plane and pilot on a airfield where he would start from? :P
-
Hey Commando, the script should be in the code snipets section. No worry as to fuel because the A10 is camcreated when u call the strike. If u run into any other problems, let me know. One thing, u may need to play around with the starting height value of the script as the A10 needs a minimum startiing altitude (depending on the terrain) or it will crash soon after it is created.
-
nice thanks
-
here i am again :)
i'm still working on the Scumball airstike to get it to work in multiplayer !!!
>>>the radio commands has something to do with assigning variables(still not figured out )
>>>use CreateVehicle insted of CamCreate !!!(this will make them show up for all players !!!
>>>after 1 airstrike still not able to call again
Hope some more of u guys start wondering about this
dont be afraid i wont give up :)
Greetings Allie :)
ps.we need to open up this editor stuff for multiplay pls pls !!!
-
Nice to know :D
-
I'm also very interested in this topic since I've put airstrike support on hold in my mission until I can get it to work in MP.
I have one small request to all great script wizards... It would be nice if something was written in the comments of the acctual script if it was written/tested for SP, MP or maybe both.
/Christer (a.k.a KeyCat)
-
I hear u all - the script works in multiplayer with minor modification.
i am at home the christmas break with only a laptop, and no multiplayer capability.
i do have the mission here though, and i'll post it here tomorrow morning (have to extract only the relevant triggers and re-save).
rest assured that it CAN be used in multiplayer, and works fine. You just have to set the triggers up correctly.
until tomorrow... ;)
-
Thanks for offering your extended help snYpir and Merry Christmas to all!
/Christer (a.k.a KeyCat)
-
Attached is an example mission showing how to use the airstrike script (LGB and napalm) in MP.
This is still under testing, I have only tested it in a server - client environment so far.
The trick is to make the server control the strike, but to still allow the clients to follow what is happening.
All of the scripts in this example mission are required for an airstrike in MP, including message_loop.sqs (ensures messages are displayed on all computers) and server_loop.sqs (allows the server to monitor for a map click event).
Napalm.pbo (in the attached zip) needs to go to your Res/Addons directory for the napalm strike to work (this is the same addon as is available in the editors depot in LCD's script).
Getting complicated scripts to work in MP is a matter of trial and error. I am interested to know if this MP version works in an environment with multiple clients.
Bugs/limitations:
- The attached version will only work for a single strike. I have not got around to implementing multiple strikes, but i will eventually. It shouldn't be hard - u would simply need to reset radio messages on all computers and re-init variables.
- The 'request strike at coords' message will always look as though it was sent by the local player. This is because I don't know a way to detect which unit triggered the map click event.
I will have trouble fixing bugs at the moment because i only have my damn slow laptop and no multiplayer capability.
Questions?
-
Merry X-mas to you all :)
thank you very much MR.snYper, for fixxing us the mission on this short notice :)
-
Hey snYper,
What's the latest on making the script repeating?
Rudedog
-
I've been flat out with getting this forum up, so there hasn't been much progress.
I'll do it today if I get time... ::)
-
I've been flat out with getting this forum up, so there hasn't been much progress.
I'll do it today if I get time... ::)
Cool, thanks man!
-
Ok, here is a version that works over and over again.
Not many changes, just made the triggers repetitive and made all variable re-init once a strike is complete.
You can alternate between LGB and napalm as required.
No real usage or implementation changes at all, really. if no-one has any problems with this i'll up it to the script snippets alongside the Skumball's original.
;D
(sorry it took so long, i was busy with other stuff)
-
very nice well done im new to scripting and this forum!
question for you have used this in one of my co-op missions
works great however is possible to have only a specific player
be able to call the script ?
i tried (pl1): 1 setRadioMsg "NULL"
but yur scripts seem to over ride it ?
sorry spoke to soon i got it to work 8)