Jump to content
SpaydCBR

Question about locality

Recommended Posts

I was in a test mission messing around with the debug console trying to understand the difference between local exec, global exec and server exec. This is what I've learned and please correct me if I'm wrong:

 

Code I used to test was

hint "Hello"

1- Local means only the machine that called the code will execute it. I tested this with a friend and only I was able to see the hint.

2- Global means all clients will execute the code. This time both of us saw the hint.

3- Server means only the server will execute the code. This time only I saw the hint. I assume it's because my client was also the server since I was hosting the mission.

 

Then I tried to do the same test in a dedicated server

(btw, is it possible to make my "local" dedicated server joinable by my friends?)

 

4- When I ran locally, I saw the hint

5- When I ran globally, I saw the hint

6- When I ran on server, I did NOT. I assume it's because this time, my client was not the server, so I couldn't see server executed code.

 

Then I tried a new bit of code

"B_MRAP_01_F" createVehicle getMarkerPos "respawn_west"

7- When I ran locally, I saw the vehicle spawn

8- When I ran globally, I saw TWO vehicles spawn. I assume it ran once for my client and once on the server itself?

9- When I ran on server, I saw the vehicle spawn.

 

At this point I'm confused as to why I saw the "result" of the createVehicle command when run on the server in a dedicated environment but not the hint.

Share this post


Link to post
Share on other sites

1-9 are all correct.

createVehicle is an "effects global" command, which means that it doesn't matter where it is executed it will be synced across all clients (including the server), that is why when using createVehicle/Unit or similar commands it is recommended to run them either solely on the server or on a headless client if avialble, avoiding duplications based on number of clients currently connected.

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

You can see the "EG" at the top left of the page of the command, E = effect, G = global. Similarly with other commands you will see A, which is "arguments", and L, meaning local.

The hint command is EL, effects local, meaning just as you stated above, only the executing machine will see it, or run the "effect":

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

Share this post


Link to post
Share on other sites

jshock perfectly explained everything and I just wanted to add:

 

Try https://community.bistudio.com/wiki/createVehicleLocaland you will see the result you expected from your experience with the hint-command. createVehicleLocal is marked with EL. It is jus the createVehicle-command but with synchronisation switched off. The created vehicle is local only. Useful when you want to create visual helper objects and such stuff.

Share this post


Link to post
Share on other sites

I thought of another question regarding this topic. Is it better to execute as much of the code as possible on the server, or on all the clients?

 

I presume clients, as to not clog up the server to keep the experience smooth for other players.

Share this post


Link to post
Share on other sites

No, it's always recommended to put as much weight on the server as possible because with the diversity of computers for all the players, you need to make the assumption that not everyone has a beastly computer. Hopefully, you know the specs for the server, or can easily find out, but the more on the server (or headless client, which is highly recommended) the better, if you bottleneck a server with your code it's safe to assume it would do the same on each client, if your code is done properly with enough care there should be no issues adding weight on the server.

There was a similar thread and discussion as far as using createVehicle vs createVehicleLocal (executed across all clients), but I'm on my phone and cannot properly link it.

Share this post


Link to post
Share on other sites

I see. Thanks. I'd like to read that thread if you don't mind finding the link. I tried searching for "createVehicle vs createVehicleLocal" but that didn't find anything.

 

I also got to read up on headless clients now. I have no idea what that is haha.

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

×