Jump to content
Sign in to follow this  
chaoticgood

BIS_fnc_GC working in arma 3?

Recommended Posts

Is this function working in Arma 3? I'm not exactly sure how to use it properly. I've read the wiki page http://community.bistudio.com/wiki/BIS_fnc_GC but I still can't figure out how it works.

I've tried:

while{true}do
{
sleep 5;
_garbage = allDead;
gCount = count _garbage;
publicVariable "gCount";
if(_gCount >= 1)then{
	[_garbage] spawn BIS_fnc_GC;
	};
};

This is done on a dedicated server and it sends the dead back to my client to see how many there are.

I then spawn in some AI, kill them, the dead body count goes up, then I fly away in a helicopter to about 2km from the dead bodies, then I fly back and they are still there.

Share this post


Link to post
Share on other sites

The operation is simple.

1 - When you call BIS_fnc_GC (btw, prefer using "call" because it return true if success) ([objectList] call BIS_fnc_GC), you mark the object list for deletion (added to the queue (bis_functions_mainscope, var qeue)) with a "time to die".

2 - Once the object is queued, the Garbage collector comes in action. It checks every 10 seconds if the queue is empty, if not, it proceeds to deletion if all player are farther than 1000 meters.

Note: If the item queued is a group, it'll test if all units of this group are dead.

Here you are :)

Share this post


Link to post
Share on other sites

Thanks for the info, would this work then?:

while{true}do
   {
   sleep 5;
   _garbage = allDead;
   gCount = count _garbage;
   publicVariable "gCount";

   }; 
[_garbage] call BIS_fnc_GC;

Share this post


Link to post
Share on other sites

Well, it should... But some questions:

What's the goal of "gCount"?

The garbage script is simple, you add, it proceeds. But, the of BIS_fnc_GC is that everything you put is queued in a simple array. So, it means that every 5 second, you add "allDead". For example, if we have s1,s2,s3,s4 dead, you are going to get this:

loop 1:

[s1,s2,s3,s4] + [existing queue] => [s1,s2,s3,4]

[s1,s2,s3,s4] + [existing queue] => [s1,s2,s3,4,s1,s2,s3,s4]

Then [s1,s2,s3,4,s1,s2,s3,s4,s1,s2,s3,s4]

and over and over until all players are 1000 meters farther of the object to delete, at this moment, the queue will start to drain.

You need to check if unit is already in queue before adding.

This doesn't really affect the module itself (in fact, it could impact performances w/ a very long mission) but you need one entry per dead man. Ideally, something to garbage should be queued only one time.

About your code, you fixed it... I recommend you this page. It should work.

Share this post


Link to post
Share on other sites

The goal of "gCount" is to see what the total number of things in _garbage is, as this is done on a dedicated server. So if I hint it, I won't be able to see it. So I then send the variable to all clients for debugging purposes and will be removed once I get the code working.

I assume I should call the function on the server and not the client?

As for checking if something is already is in the queue, I have no idea how to do that because I don't think you can actually check what's in the queue, correct me if I'm wrong.

Edited by chaoticgood

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  

×