Jump to content
Sign in to follow this  
Nicolas Eymerich

Add Action In Mp Games

Recommended Posts

Hi guys! This is my first time here biggrin_o.gif

I've some problems I can't solve so I'm requesting a little help.

I've done a script allow the player to call a particular support (Air Strike, HeliCas, and so on) by tha action command. It's my intention make it fully compatible with Mp mission... and here comes the problems.

1)Suppose two person are playing in the same group (P1 and P2). Suppose p1 is the leader of the group. In my script he is the only one who can call a support. How Can I give the same ability to p2 after p1 dies (being the new leader group?)

2) If I use a Gloabal variable (in my script I've used this variable: P_G_Base = [west,"base"]) for sidechat radio msg, will the radio message be displayed on every client?

3) Any useful rules to keep in mind when someone design mission and script for multiplayer?

Thanks in advance... smile_o.gif

Share this post


Link to post
Share on other sites

1. Make trigger !alive P1 && P2==player && alive P2 : P2 addaction ["Call for mommy", "support.sqs"];

2. I don't think so if the script isn't executed on all clients.

3. Rule A: Making MP missions is a bitch. crazy_o.gif Rule B: see Rule A. smile_o.gif

Share this post


Link to post
Share on other sites

Thanks a lot for the replies smile_o.gif

But, about answer number 1, that will not solve my problem.

That's because I've just exemplified the situation using only two persons playing in the same session. But How can I Know how many players will play on a Mp mission on internet?

Suppose I'm hosting a game and 10 people play in the same group. There will be a leader who can call a support (p1). When He dies there'll be another (p2) and so on.

About question number 2. So I need to use a script runned on every client to have them displayed the radio messages is'nt?

About question number 3:Can You suggest any Mp editing tutorial (I've just take all the material by the Opfec editing

center)?

By the way: I've read that there're some problems in Mp games when you use the Function onmapsingleclick. Do you know any of them and how to solve them?

Thanks again...

Share this post


Link to post
Share on other sites

1. Make a script what will add action to first living player in array of all playable units using the same logic. So say 1,2 and 4 are down, 3 gets action. Define array like this playableunits = [P1, P2, P3, P4, P5, P6]; or use trigger _thislist parameter.

2. Yes, or a trigger. If you do player sidechat "Hello world" in MP the message isn't transmitted to others.

3. I guess OFPEC's got about everything you could need and more.

Share this post


Link to post
Share on other sites

I can help, but I need to know a few things first.

1) Is there respawn?

2) Do you want the messages to show up on all screens?

3) Do you have any problem with adding a script package to your mission that will make it easier to code MP stuff? or would you rather do everything from scratch?

Share this post


Link to post
Share on other sites

Thanks CrashDome biggrin_o.gif

1) respawn would be prefereble;

2) yes, the radio messages have to be displeyed on every cliens;

3) I'm terrible sorry CrashDome and accept my apologies but I haven't understood your third request.

Thanks again however.

wink_o.gif

Share this post


Link to post
Share on other sites

Just thinking out loud once again, but couldn't you use

leader grp1 addaction ["Scriptname", "yourscript.sqs"]

so you would not need to define an array of possible units that could become the leader?

Syntax not checked, but you should get the idea.

Wadmann

Share this post


Link to post
Share on other sites
Just thinking out loud once again, but couldn't you use

leader grp1 addaction ["Scriptname", "yourscript.sqs"]

so you would not need to define an array of possible units that could become the leader?

Syntax not checked, but you should get the idea.

Wadmann

It's a worthy suggestion, but the flaw is that it isn't a persistant command.. it'll work when it's first called and the leader will get the action, but if any changes occur ... i.e. the leader dies... nothing will happen for the new leader.

What he needs is a method to determine when a leader dies and call that command again only on the leaders machine which is why MP coding is so difficult.

A set of triggers would work... but it doesn't solve the message issue or in the case of respawn. It also will show the action attached to the leader and people can walk up to the leader and execute it. Which is why I asked the above questions before I provided a complete solution.  wink_o.gif

I am working on a solution for you. Expect one shortly!

Share this post


Link to post
Share on other sites

OK... first, I suggest you download CoC Network Services. It has been an absolute essential set of scripts when doing ANY kind of MP missions. It is small and yet very useful.

This is what I meant by question 3.

Once you download it, extract it somewhere and open the folder inside titled "CoCNS_2_0_ScriptsCore". Copy all contents to your mission folder. If you have an init.sqs already, you may want to merge the two by copy/pasting the code inside the CoC_NS init.sqs to your existing init.sqs instead of overwriting it.

This handy little pack will allow you to call MP functions that people try to produce on their own and ultimately spend way too much time and effort. This is like a very nice shortcut!

There... now we are all set to do some MP coding!

First, we need a script to handle the beginning of the mission or when a unit respawns:

Add a trigger and make it REPEAT

Condition: alive player

Action: [player] exec "Spawn.sqs"

Spawn.sqs (every line is commented)

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

Private ["_unit","_actionID"]

 ;Assigns the player executing this script to local variable _unit

_unit = _this select 0

 ;Exit if for some reason this script executed by AI (for safety)

? (_unit != player) : exit

 ;A label we can return to in case we need to start over

#LeaderCheck

 ;Wait until player becomes leader

@(player == leader player)

 ;Apply action (be sure to use your script name etc..)

_actionID = _unit addaction ["My Action", "action.sqs"]

 ;Wait for player to either not be leader or in the case player dies

@((player != leader) || (!alive player))

 ;Remove the action - we are no longer the leader

_unit removeaction _actionID

 ;If I am still alive - go back and run check

? (alive player) : goto "LeaderCheck"

 ;Else we MUST exit... because if a player dies, we

 ;must wait until player fully respawns before beginning to check

 ;again. This is what the trigger is for. We could place another

 ;condition here and simply loop back instead, but I find it

 ;much more stable to exit this script in the event of death

 ;and start a new one when the player respawns via a trigger.

 ;Also, in the event of no respawn.. then the script doesn't waste resources.

Exit

OK.. that covers the leader bit.. now lets cover the sending of messages to everyone - this is where the CoC_NS comes in.

Message.sqf (note: this is a Function..not a script so save as an sqf file!!wink_o.gif

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

private ["_callee","_message"];

_callee = _this select 0;

_message = _this select 1;

_callee sidechat _message;

add to the Init.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> MessageFunction = preprocessfile "Message.sqf"

replace all your code that calls messages and change it according to the example below:

example:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player sideChat "Hello..who can read this?"

change to: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[[], [player,"Hello..who can read this?"],"MessageFunction"] call fNSendGlobal

fNSendGlobal will make every 'node' or player's machine execute that command line. It seems like a bit much to add all those CoC_NS folders to your mission for this one thing, but trust me, once you begin using it, you will find more and more neat things to do in MP that you would've thought very difficult to accomplish before.

Also, the two brackets '[]' means to send to everyone. You can actually send to specific machines but that involves a little more. If you are making MP mission that is NOT strictly coop.. you may want to add side info when calling the function

Alternate message.sqf

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

private ["_callee","_message","_side"];

_callee = _this select 0;

_message = _this select 1;

_side = _this select 2;

if (_side == side player) then

{

    _callee sidechat _message;

}

new example:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[[],[player,"Only my team can see this!",side player],"MessageFunction"] call fNSendGlobal

Hope this helps!!! I will answer ANY questions!

Please see the Documentation of CoC_NS for more NS commands.

Share this post


Link to post
Share on other sites

Firts of all.. thank to all of your help! yay.gif

I've appreciated it very much (This is a page to download) wink_o.gif

I'll try this evening your suggestions.

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  

×