Jump to content
DChristy87

Multiplayer - How to activate a trigger with players only?

Recommended Posts

As the title says, how can I activate a trigger by a players only in multiplayer? Thanks in advance!

Share this post


Link to post
Share on other sites

if (isServer) exitWith {};

**EDIT**

I see you needed it for a trigger, so something like

!(isServer) && (something) && (something) 

Should work.

(I've never really made triggers before, but I know the general idea of how they work)

Edited by bob100101

Share this post


Link to post
Share on other sites

would it be something like

count (playableunits in thislist) >0

can't remember the right order at this time. too late or early or just too drunk!

Share this post


Link to post
Share on other sites

ahhh, Would I just leave none and none with present and condition as

{_x in thisList} count (playableUnits + switchableUnits) > 0
?

Share this post


Link to post
Share on other sites

Depends what you want the trigger to do. "ANYBODY" will add to thislist any unit that gets inside the trigger. "WEST" would only add to thislist units that are on west side. NONE will add none so thislist will always be empty...

The above code will then iterate over all playable and switchable units and only count those that are in thislist.

https://community.bistudio.com/wiki/count

Share this post


Link to post
Share on other sites

To add to galzohar's post, As galzohar says if you were to leave the trigger as NONE thisList will be empty as its not checking for anyone but you can still use the triggers area to check for things for example

playersInTrigger = [];
{
if ( [myTrigger, _x] call BIS_fnc_inTrigger ) then {
	playersInTrigger = playersInTrigger + [_x];
};
}forEach playableUnits;

playersInTrigger will hold all playableUnits that are in the triggers area. A nice little up shot to this is that because inTrigger checks against a position it will also detect dead units aswell.

Remember playableunits also includes any AI that are currently using a playable slot, if you only want actual players you would need to check against isPlayer aswell.

Share this post


Link to post
Share on other sites

Just a tip, but use playableUnits + switchableUnits to avoid everything failing in the Editor since playableUnits doesn't exist in Single Player (and therefore the editor) and you do test your missions, right? :)

playableUnits returns all playable units in multiplayer and nothing in single player. switchableUnits returns all playable units in single player and nothing in multiplayer. So add them together to always know how many playable units you have in editor or multiplayer.

Share this post


Link to post
Share on other sites

Well, I found it's usually best to just go straight to testing in the MP editor (multiplayer->new->create the server->open editor or edit a mission). That way you can test stuff like MP parameters and other things that work differently in multiplayer even when there is only 1 player. After that, I test with some more players, and then if all works then I PBO the mission and test on dedicated (usually my functions work fine on both, but rarely you do find out you missed something that is needed only on dedicated).

Share this post


Link to post
Share on other sites

Currently in triggers I have {isPlayer _x} count thisList > 0 so trigger is only activated by human playes on our dedi server and it works fine.

Now heres the bit I cant work out

How would I go about so that ALL human blue playes (there is no blue ai) have to be in trigger area to activate it keeping in mind that sometimes there are three of us playing other times eight

Thanks in advance

Share this post


Link to post
Share on other sites

 [color=#333333]{isPlayer _x} count thisList == count ( playableunits)[/color]

assuming there are no enemy human players that is

Share this post


Link to post
Share on other sites

Correct no human enemy -

Thanks for this been bugging me for a while

Share this post


Link to post
Share on other sites

Of course if you want to have human enemy you can use

{isPlayer _x} count thisList == {side _x == WEST} count (playableunits)

Also you need to make sure to disable the "sideEnemy" thing or your mission may break if someone does a teamkill (and teamkill punishing is fine, but breaking the mission on teamkills is not fine :P).

Share this post


Link to post
Share on other sites

Can anyone help with the following - I am using this {isPlayer _x} count thisList == count ( playableunits)

in triggers so all human players on dedi server have to be in trigger to "activate" it - Problem is this doesnt work in editor mode (guess cos Player doesnt exist in editor?) anyhow is there something I can add to this so it will work in editor/sp for testing?

Cheers in advance

Share this post


Link to post
Share on other sites

doodle check Kylania's post a few up, use switchableunits + playableunits

Edited by KevsnoTrev
spelling error

Share this post


Link to post
Share on other sites
doodle check Kylania's post a few up, use swtichableunits + playableunits

Thanks for the heads up - not tested on dedi but has solved the "not working in editor" issue I was having.

Share this post


Link to post
Share on other sites
{_x in thisList} count (playableUnits + switchableUnits) > 0

for some reason this code is not working for the editor. Has something changed with ARMA?

I have the trigger set up with none,none, once, present, condition:

{_x in thisList} count (playableUnits + switchableUnits) > 0

Share this post


Link to post
Share on other sites
for some reason this code is not working for the editor. Has something changed with ARMA?

I have the trigger set up with none,none, once, present, condition:

{_x in thisList} count (playableUnits + switchableUnits) > 0

thisList is defined by units that satisfy the trigger's condition/activation, right now you have it set as None, so thisList is undefined/empty, try: none, anybody, once, present, and the same condition.

Share this post


Link to post
Share on other sites

I managed to make them work (locally at least, but only with human players) using:

this && (local player) && (vehicle player in thisList)

Borrowed from somewhere in AltisLife code, can't remember author.

Share this post


Link to post
Share on other sites

Is it possible to figure out who precisely has been activated trigger?

I would like to have an area which player can left and automatically save his gear.

But how to check which of them (this is MP mission) just left area of trigger?

Share this post


Link to post
Share on other sites

cond = {isplayer _x && local _x} count list thistrigger > 0

expr = (name player) remoteExec ["hint",0,false]

now all players and the server knows who was stealing the cookie ;)

Share this post


Link to post
Share on other sites
On 2013-8-24 at 7:36 AM, kylania said:

{_x in thisList} count (playableUnits + switchableUnits) > 0
 

 

would that work if player is being transported in a vehicle, say a medevac helicopter?

Share this post


Link to post
Share on other sites

Yes it should work.

 

For missions without AI which uses player slots (playableUnits) and without switchable slots where you only need to have current alive players to be affected I would suggest this:

{alive _x and _x in thisList} count (allPlayers - entities "HeadlessClient_F");

 

 

Share this post


Link to post
Share on other sites

Why don't you use "any player" in the trigger activation?

  • Like 1

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

×