Jump to content
xjoker_

[network perf] publicVariable vs setVariable + count

Recommended Posts

Hello.

 

Let's say in my mission, at any time, clients need to get the number of players that have a specific variable assigned.

What method is the best (mostly for network traffic) between 

  • when players connect, the server assign a random var (A, B, or C) to them using 
    _unit setVariable ["var","A",true]; // A, B or C

    And clients can get the number of players like that

    _nbA = {_x getVariable ["var",""] isEqualTo "A"} count playableUnits;

     

  • or when players connect, the server increments a variable (and do the opposite when players disconnect) like 
    nbA = nbA + 1;
    publicVariable "nbA";
    
    nbA = nbA - 1;
    publicVariable "nbA";

    And clients can access the var like that 

    hint str nbA;
    hint str nbB;
    hint str nbC;

     

 

Share this post


Link to post
Share on other sites

I think the publicVariable implementation is fastest because when you use setvariable with public variable true the setvariable is set on all clients including JIP clients.

 

Share this post


Link to post
Share on other sites
21 hours ago, gc8 said:

because when you use setvariable with public variable true the setvariable is set on all clients including JIP clients.

That's exactly what publicVariable does too.

 

22 hours ago, xjoker_ said:

Let's say in my mission, at any time, clients need to get the number of players that have a specific variable assigned.

I think one could probably make a better solution if we knew what you are actually trying to do.

 

The second variant is better because you have just one variable that will have to be redistributed to all clients, instead of one per client.

  • Like 2

Share this post


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

That's exactly what publicVariable does too.

 

yeah I meant 3 publicvariables are better than transmitting all the player variables for each client

  • Thanks 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

×