Jump to content
Sign in to follow this  
Poet

Script called by radio run on server only?

Recommended Posts

Hello,

I have a mission with a fairly heavy artillery strike. It works fine, in SP and MP, but in MP each piece of ordinance is duplicated for each player connected, leading to WAY TOO MUCH artillery ( looked great though tounge.gif ).

I did some searching and found Snypirs cool Multiplayer Mission Tutorial.

Got as far as this bit :

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

If you went through the previous section of the guide you'll know about init.sqs. The init.sqs file will be launched at the start of the mission, on every computer. Make another file called server_loop.sqs (can be named anything). Make sure they are both in your mission directory. In init.sqs, put:

? local(Server) : [] exec "server_loop.sqs"

In your mission, make a game logic unit and name it 'Server'.

Done! server_loop.sqs will only run on the server computer - you have my word on it. This is because game logic units are local only to the server when the mission actually starts (don't ask me for specifics, ask BIS).

In server_loop.sqs you would call other scripts as required, safe in the knowledge that they will only run on the server.

<span id='postcolor'>

So I added the line to my init.sqs no probs.

But what do I add to the server_loop.sqs so that the script/s runs only on the server when its called by Radio Alpha?

I need the exact code if possible.

All help, as always greatly appreciated.

Cheers!

Share this post


Link to post
Share on other sites

I'm no expert at scripting but i think you can't run the script from the radio trigger directly, but you could check for a global variable in server_loop.sqs and set that variable with the radio command.

Like set a global variable to false in your init.sqs and export it, set it to true with the radio command and let the server_loop.sqs wait for that variable to become true and then do the artillery stuff.

Share this post


Link to post
Share on other sites

You don't

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">? local(Server) : [] exec "server_loop.sqs"

<span id='postcolor'> will already ensure server_loop.sqs is run on the server alone.

You placed a gamelogic or object named "Server"?

Share this post


Link to post
Share on other sites

Yup got a gamelogic called "Server"

Its what I put in the server_loop.sqs thats got me puzzled.

Say I have 2 arty scripts that are both launched by Radio Alpha.

Do I just put :

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[] exec "navalstrikeV2.sqs"

[] exec "heavy_ari.sqs"

<span id='postcolor'>

in the server_loop.sqs

I get an error message when the mission loads to do with the navalstrike script, but it still works when I call it in via radio.

Or do I need to add something else to the server_loop.sqs that only launches the script on the radio call.

Sorry if I sound like a Dunce, I guess I am here. I can't get my head round it. sad.gif

Share this post


Link to post
Share on other sites

Yep, if those two are two seperate scripts you can call them from the file "server_loop.sqs", however I do not know the rest of the contents of that script so...

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Poet @ 17 May 2003,11:48)</td></tr><tr><td id="QUOTE">Yup got a gamelogic called "Server"

Its what I put in the server_loop.sqs thats got me puzzled.

Say I have 2 arty scripts that are both launched by Radio Alpha.

Do I just put :

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[] exec "navalstrikeV2.sqs"

[] exec "heavy_ari.sqs"

<span id='postcolor'>

in the server_loop.sqs

I get an error message when the mission loads to do with the navalstrike script, but it still works when I call it in via radio.

Or do I need to add something else to the server_loop.sqs that only launches the script on the radio call.

Sorry if I sound like a Dunce, I guess I am here. I can't get my head round it.  sad.gif<span id='postcolor'>

All you'll need to do is add two new variable to the init.sqs file...

Something like

NavalStrike = FALSE

HeavyAir = FALSE

Then, have the radio trigger set these to TRUE...

And in the server only script make something like...

@(NavalStrike)

[] exec "navalstrikeV2.sqs"

@(HeavyAir)

[] exec "heavy_ari.sqs"

that splits them into two seperate groupings, allowing you to call them seperately (but only in order in this case).

Does that help?

Share this post


Link to post
Share on other sites

Ok, the scripts need some arguments to run properly e.g :

[a,b,c,d] exec "arty.sqs" etc.

Putting those arguments into the server_loop.sqs like :

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">[b3,b21,b1,100,24] exec "navalstrikeV2.sqs"

["arty", 100, 2, 11, 32, 19] exec "heavy_ari.sqs" <span id='postcolor'>

stopped the error message, but now both triggers activate as soon as the mission starts, rather than when called by Radio Alpha ... sad.gif

Any ideas?

Share this post


Link to post
Share on other sites

Hmm, what are you doing with Radio Alpha trigger? You are suppost to launch the scripts from it or set a flag.

Are you talking purely about snYpirs support pack? If so you need to ask specifically for that in proper place.

EDIT: It probably says in the support pack instructions where to ask questions doesnt it?

Share this post


Link to post
Share on other sites

Ignore the above. tounge.gif

That sorted it Cosmic Evolution!

Works a charm. smile.gif

Thanks all for your help!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×