Jump to content
Sign in to follow this  
clydefrog

Counting players from a group for MP mission

Recommended Posts

I'm using the code

 {_x in thisList} count units alpha > 0 or {_x in thisList} count units bravo > 0; 

on a mission to count if there are is at least 1 player from either of 2 groups in the trigger area to trigger the task complete. This works fine when I try it by myself (preview in the editor) but when I host it it won't work, even with a player from both groups in the area it won't fire the trigger. I've been told it's the "_x" thing but can't remember what else the guy said about it. How do I make this code multiplayer compatible?

Another problem I'm having in the same mission is a hint and a Task Accomplished message only coming up for the person who uses the action menu to "take" an object, and not for the rest of the team, any help with either of these problems would be greatly appreciated. I guess it's something to do with locality but I really don't have a good understanding of it at all yet. Thanks

Edited by clydefrog

Share this post


Link to post
Share on other sites

Well I think I've actually solved the first problem myself, if there is nobody present in any one of the groups listed in the triggers condition field, then the trigger won't work. I found this out because I hosted the mission and the trigger worked when I had AI enabled but when I disabled them and I was by myself the trigger wouldn't fire as there were no players in the other group. I then tried making the trigger only for my group (1 person group) and tried with all the other AI in the other 2 groups disabled, and it fired when I walked into it, so hopefully that's that one sorted. If you know otherwise and that code isn't actually MP compatible please let me know.

Still if anybody could help me with the second problem that would be great, I think that's the only thing stopping my mission from being ready to play now.

Share this post


Link to post
Share on other sites
This might help. Check vs the count of the group instead of 0 itself.

I'm not sure I really understand what that means

(

{_x in veh} count units GroupName == count units GroupName

)

I can see it's checking how many of a group are in a vehicle, is it checking to see if the whole group is in?

On mine I want the trigger to go just if at least 1 group member is there, the whole group doesn't need to be.

What is "=="? Does it just mean equals and is it a multiplayer specific thing? I seem to remember being told I should use that in some way by somebody.

Nice site btw, looks helpful.

Share this post


Link to post
Share on other sites

== means "is equal to" since a single = is assignment.

So var = 5 would set var equal to 5. Then you can test if var is 5 by using var == 5 (which would be true).

Basically what the code you quoted is saying is:

"Does the count of units in the group named groupName which are in the vehicle called veh equal the count of units in groupName?"

So that would be a test of "Is everyone in the group in the vehicle or trigger list". If you set it < ... > == 0 then you'd be asking:

"Does the count of units in the group named groupName which are in the vehicle called veh equal to 0?" or "Is everyone out?"

Share this post


Link to post
Share on other sites

{_x in thisList} count units alpha > 0 or {_x in thisList} count units bravo > 0;

Because one cannot be sure whether both alpha or bravo are always filled the simple way would be to create two separate triggers and split it up, with both triggers using the same on activation consequences.

{_x in thisList} count units alpha > 0;

{_x in thisList} count units bravo > 0;

Regards,

Sander

Share this post


Link to post
Share on other sites
== means "is equal to" since a single = is assignment.

So var = 5 would set var equal to 5. Then you can test if var is 5 by using var == 5 (which would be true).

Basically what the code you quoted is saying is:

"Does the count of units in the group named groupName which are in the vehicle called veh equal the count of units in groupName?"

So that would be a test of "Is everyone in the group in the vehicle or trigger list". If you set it < ... > == 0 then you'd be asking:

"Does the count of units in the group named groupName which are in the vehicle called veh equal to 0?" or "Is everyone out?"

Ok, so how would I adjust my code to use that (if I need to)? Would it be:

{_x in thisList} count units alpha == > 0 or {_x in thisList} count units bravo == > 0;

?

Is the code I'm currently using not already saying that the number of units in alpha or bravo must be equal to more than 0 anyways?

-------------------------------------------------------------------------------------------------------------

{_x in thisList} count units alpha > 0 or {_x in thisList} count units bravo > 0;

Because one cannot be sure whether both alpha or bravo are always filled the simple way would be to create two separate triggers and split it up, with both triggers using the same on activation consequences.

{_x in thisList} count units alpha > 0;

{_x in thisList} count units bravo > 0;

Regards,

Sander

But if I do this, is it not going to trigger the same activation consequences twice when the two groups both walk into the triggers?

Thanks

Edited by clydefrog

Share this post


Link to post
Share on other sites

Depending on what happens after the triggers kick off there may or may not be a need to use an additional check there. There may or may not be any harm done when it is triggered twice. One can also take care of it by naming the two triggers and deleting the redundant trigger on activation of the other, this would be the most simple solution. Perhaps if you specifiy what the result is of the trigger kicking off is more specific advice can be offered.

Regards,

Sander

Share this post


Link to post
Share on other sites
Depending on what happens after the triggers kick off there may or may not be a need to use an additional check there. There may or may not be any harm done when it is triggered twice. One can also take care of it by naming the two triggers and deleting the redundant trigger on activation of the other, this would be the most simple solution. Perhaps if you specifiy what the result is of the trigger kicking off is more specific advice can be offered.

Regards,

Sander

Well at the moment the trigger is just triggering a Task Accomplished message (using mktaskhint script) and also a hint saying "Welcome to etc. etc.". Deleting the other trigger when one of them is activated is a good idea, what's the code for that?

Share this post


Link to post
Share on other sites
deleteVehicle triggerName;

Thought it would be but couldn't find it when I searched, thanks. I asked you a question in that post as well btw, don't know if you saw it or not. Would I do this:

{_x in thisList} count units alpha == > 0 or {_x in thisList} count units bravo == > 0;

and how would that differ from what I'm already using?

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  

×