Jump to content
Sign in to follow this  
m0nkey

Learn Arma 3 scripting - question about logics - locality and best use

Recommended Posts

As for the thread title, was just trying to think of a standardized title so I can find these again or reference them. Get tired of losing a post in the mix on forums.

Question is maybe simple. This is all just learning, not actually making anything special. Here is the original source that I have been modifying to see how it works etc

http://forums.bistudio.com/showthread.php?143334-Insurgency-style-respawn/page4

I am trying to understand locality and mp related issues when dealing with dedicated servers. Or just mp good habits in general.

In this example, I have added another piece of code that moves a second game logic to a vehicle location. Nothing fancy, just

logic_name setPos getPosATL object_name;

The script has no check for isServer/isDedicated, so one assumes it runs on client? But I read logics are owned (local only to) the server? So what happens when a client runs this JIPSpawn.sqf script? Is the logic moving on the server, just not being synced (or is that broadcast) to other clients? So when each client runs the script, each client moves the server-owned logic to a new location (even if its in the same location?).

Or is there something else going one? If the client is not specifically stating to update everyone of the change (which is clearly not in the code?) then if the server actually owns the logic, how does everything stay synced?

Or, is the logic actually local to each client, so each client has its own logic (so to speak) and it does not matter.

How might this be impacted when, for instance, more than one client, at the same time, moves the logic?

If the logic is server owned, and a client is driving the vehicle, and at the same time another client tries to move the logic to the vehicle, how can the client not driving get information about the vehicle that is owned by the 1st client because he is driving it?

I apologize, I over-analyze things and after a lot of mp scripting reading I got to wondering what was happening.

Share this post


Link to post
Share on other sites

The answer, truthfully, is that every scripting command will handle this differently.

Firstly I do not believe that logics are ALWAYS local to the server; however, i believe all editor placed logics will be initially local to the server unless this locality is changed via scripting.

Secondly, The BIKI will always tell you the following about locality and each scripting command:

1) Whether or not the object (in this case your logic) must be local to the machine the scripting command is run on in order to work.

2) Whether or not the scripting command will affect the object on all machines, or just the one the command is running on.

To sum it up, The more you work with MP the more you will understand how it works. You just need to make sure that you are not running commands on every machine, that need only run on one as this will multiply the effects of your intent. This is why some things are run client side, some things are run server side, and some things are run both. Again, it is unique to each scripting command and you will need to read teh BIKI to find out each specific use.

for your example given, you can see on the BIKI that the objects used (your logic) do not need to be local to the machine running them; therefore, you can run them on any client or server you like, however the effects will happen on every machine, so you need only run it on one.

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

Share this post


Link to post
Share on other sites
So what happens when a client runs this JIPSpawn.sqf script? Is the logic moving on the server, just not being synced (or is that broadcast) to other clients? So when each client runs the script, each client moves the server-owned logic to a new location (even if its in the same location?).

I don't think the logics even exist on the clients.

Share this post


Link to post
Share on other sites
I don't think the logics even exist on the clients.

That is not true, logics do exist on clients.

Share this post


Link to post
Share on other sites

I have been thinking about starting a thread like this as well.

So for those who know more about MP missions and having them work correctly, in general, is there a good site/s, thread, link, whatever that would help people like me that can make missions but when comes to MP and servers don't know jack.

Thanks in advance.

Share this post


Link to post
Share on other sites

I've been using the logic base class in a editor module adding mod I am working on. From my testing, the logic exists and initiates on both the server and the client. I could be wrong, though - I often am.

One way to prove this is to place a game logic in the editor with a createVehicle (any vehicle) in its initalization box and you will see it spawn for every client (plus server) that connects. It took some failed missions for me to figure that one out.

Edited by Fight9

Share this post


Link to post
Share on other sites
That is not true, logics do exist on clients.

Ones that are spawned at runtime certainly do, but I'm not so sure about logics placed in the editor.

Anyway, I seldom use them and they're probably not necessary for whatever m0nkey is trying to achieve.

Share this post


Link to post
Share on other sites

Well, the logic was being used in the hopes that it was a server logic only. At first anyway. It seemed that a logic created on the server side would be "controlled" by the server. Then when I started to understand how and why client side scripts are used, and further began to experiment with MP functions and variables, it began to occur to me that I don't understand things like the topic posted.

Its a strange thing to be sure. A server creates it and owns it, and there is only one, yet any script that runs on a client can change its pos, but is there more than one instance or not?

But honestly I've been so busy as of late I have not gotten around to that JIP respawn script yet. As usual I set my goals way too lofty and a simple "spawn wave" type mission has turned into a dynamic mission type thingee that is taking way too much time - but does take one into unfamiliar ground where a lot is learned. Ha! or maybe I just need to stop working 7 days a week... I will revisit this when I rewrite that respawn script (again) to do things radically different (yet again). lol.

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  

×