Jump to content

Count how many object are in a trigger and teleport objects with a task is completed

Recommended Posts

I'm making a mission where there are 6 missions to do but I only want players to do 3 missions maximum

The way I intend to do it is like so:
- Every mission has an object "attached" to them

- Once the players complete a mission, the attached object gets moved in the trigger
- The trigger counts how many objects there are in itself and if the amount is equal to 3.. It gets activate


How do I count how many objects are in the trigger and (optionally) how do I detect that a mission has been completed and activates a separate trigger?


Thanks a lot ❤️

Edit 1:

I found and edited a code, it works but only with units instead of objects but it's better than nothing:

(count (thislist select {alive _x })) isequalto 3


Share this post

Link to post
Share on other sites

I found this on another post, It counts how many vehicles are in a trigger area. I'm making some modifications and testing it rn:


(count (thislist select {alive _x && (_x isKindOf "Tank" || _x isKindOf "Car")})) isequalto 0


Share this post

Link to post
Share on other sites

Once a player complete a mission, you set the mission task as succeeded, and a counter +1 on server. No need to trigger / add object or else.


in initServer.sqf

missionCount = 0;   (or what you want)

publicVariable "missionCount";  // as common reference for each player


When a mission is successful or failed (I don't know your task state but I'm rather sure there is a trigger for each case success/loose), you just have to add:

if the trigger is server server only:

missioncount = missionCount +1;

publicVariable "missionCount";


if the trigger fires for each players+server:

if (isServer) then {

  missionCount = missionCount +1;

  publicVariable "missionCount";


The principle is that server stays the common reference for the count. Generally, this is also the place for generating the tasks/missions. So, if you know what you do, you can keep all that on server (and public variable is useless). That depends on the way you propagate the tasks states.



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