Jump to content
fawlty

Scripting question about dedicated server

Recommended Posts

Hey guys; I've been hosting missions from in game rather than on a dedicated server over the years.

I decided to try setting up my dedicated server on a spare system with lots of bandwidth that can easily handle the task.

 

My question is I understand scripts with the reference 'player' do not work on dedicated servers such as this example.

 

{_x in heli_1} count (units group player) == {alive _x} count (units group player)

 

Using this in the trigger condition field

I have a huge amount of compositions made this way is there something I can replace 'player' with or whatever to make these work?

 

Share this post


Link to post
Share on other sites

In the player's init:

 

playersGroup = group this;

 

Then:

 

{_x in heli_1} count (units playersGroup ) == {alive _x} count (units playersGroup )

 

  • Thanks 1

Share this post


Link to post
Share on other sites

I just did a quick test and that certainly worked nicely, thanks DP.

 

Further question, do I need to add   "playersGroup = group this;"    to only the group leader or to all of the players init. I'm thinking only the group leader but I'm probably wrong. 

Share this post


Link to post
Share on other sites
2 minutes ago, fawlty said:

do I need to add   "playersGroup = group this;"    to only the group leader or to all of the players init.

Only to one unit in the group.

 

With dedicated server you have to use direct unit references instead of Player, and group references from some unit rather than relying on (Group Player ).

 

Unit reference is as simple as naming units in editor.  @dreadpirate provides example above of setting a group reference and using it.

  • Thanks 1

Share this post


Link to post
Share on other sites

Is there a universal way of doing this in the initServer.sqf so that I can leave the compositions as they are?

Share this post


Link to post
Share on other sites

Not to my knowledge.

 

Player is a command (I would say a local command though wiki has no indicator for it), and the return is different on each machine.  Dedicated server has no user.  The command's use has to be reviewed in each 'composition' you have, with an eye toward the objNull returned by dedicated server.

 

Multiplayer Scripting

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks to you both, looks like I won't be hosting via dedicated. Three mission builders in the group, way to many composition to adjust.

Share this post


Link to post
Share on other sites

Maybe it’s a good idea to start aligning to MP missions in your future missions? If you’re used scripting for SP it’s not that hard to start scripting for MP. You need to learn and think about ”locality”.

  • Like 1

Share this post


Link to post
Share on other sites
On 5/30/2020 at 7:13 PM, fawlty said:

way to many composition to adjust

 

If you're careful (and make backups of your sqm files!), there's no reason why you couldn't do a "replace all in files" in Notepad++. You'd have all your missions fixed in a few seconds. You'd need to re-pbo them for your server, but that's trivial as well.

Share this post


Link to post
Share on other sites

Ran into a problem with this script used with a trigger on a d-server for a heli extract

After the player is killed in game the extract does not work, any suggestions?

 

In the player's init:

playersGroup = group this;

Then:

{_x in heli_1} count (units playersGroup ) == {alive _x} count (units playersGroup )

Share this post


Link to post
Share on other sites

Try this:

(if (isNull playersGroup || {Count (Units playersGroup) < 1}) then {false} else {{_x in heli_1} Count (Units playersGroup) == {Alive _x} Count (Units playersGroup)})

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Opusfmspol;    unfortunately that did not work, I tried it before respawn and everything worked as it should but after respawn/being killed it was a no go.

Once I get this working I'd like for the heli after drop off, to leave as well.

I have the waypoints set up properly and everything works as it should but the after death thing is just not working.

Share this post


Link to post
Share on other sites

Check to see if the respawned unit belongs to a different group.  If that's the case, use respawn event handler to have him joinSilent the playersGroup, so long as the group still exists.  Or redefine playersGroup as the respawn unit's group if it no longer exists.

Share this post


Link to post
Share on other sites

I was testing this myself on my own d-server, If I had other players in maybe it would have worked?

 

Also to have all players leave the heli do I only need to change the < 1 to > 1 ?

Share this post


Link to post
Share on other sites

Maybe I'm misunderstanding the scenario and the {false} should instead be {true} for trigger condition.

Certain MP behavior with Units and Group commands may also need to be considered, see Kronzky's note at the bottom of the Units biki page.

The alternate detection might need to be: if (isNull playersGroup || {{Alive _x} Count (Units playersGroup) < 1}).

 

What exactly is the extract setup/scenario using the trigger?

Are all the player/playable units in one group (playersGroup), or are there multiple groups with playable units being extracted?

What respawn type is used (Instant, base, group, etc)?

 

< 1 is same as == 0, meaning no Units are detected in a group.  Reversing that would be > 0 Units, meaning Units are still detected in a group.

 

 

Share this post


Link to post
Share on other sites

Ya calling in a heli for extraction and insert using waypoints and triggers. The heli waits with engine on (fly zero alt.) after we load up the trigger allows the next waypoint by fly at 75m or whatever.

All players are payable and in one group

The respawn is usually on group but I was testing on respawn placed in the editor.

 

I can dropbox the mission if need be

 

Share this post


Link to post
Share on other sites
16 hours ago, fawlty said:

Ran into a problem with this script used with a trigger on a d-server for a heli extract

After the player is killed in game the extract does not work, any suggestions?

 

In the player's init:

playersGroup = group this;

Then:

{_x in heli_1} count (units playersGroup ) == {alive _x} count (units playersGroup )

 

count allPlayers > 1 && ({_x in heli_1} count (units playersGroup ) == {alive _x} count (units playersGroup ))

 

in your case units playersGroup is the same as (switchableUnits + playableUnits) (for SP/MP) . So, you can avoid naming this group.

  • Thanks 1

Share this post


Link to post
Share on other sites

Ok the combination of this

 

In the player's init:

playersGroup = group this;

 

and this

 

(if (isNull playersGroup || {Count (Units playersGroup) < 1}) then {false} else {{_x in heli_1} Count (Units playersGroup) == {Alive _x} Count (Units playersGroup)})

 

Gave me what I needed.

Opusfmspol, the reason I thought it wasn't working before was I was testing with no ai or player group, just on my own on the D-Server

Now after being killed or respawning it works as it should.

 

Thanks so much for your help opusfmspol and from everyone.

 

 

 

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

×