Jump to content
Sign in to follow this  
roguetrooper

Problems with understanding jip and locality

Recommended Posts

I am confused by the results of a very simple MP test map.

* two playable soldiers placed in the editor: named player1 and player2

* in the init line of player1: [1] exec "start.sqf";

* in the init line of player2: [2] exec "start.sqf";

start.sqf looks like this:

_value = _this select 0;
~_value
hint format ["%1",_value];
exit;

The delay is there to be able to get two different hints, since a hint does not expand a previous hint, but edges it out.

I'm testing it on one computer with two instances of Arma, which allows to join a LAN-server with the same ID.

Mkay, here it goes. It may be a bit confusing at the first glance, but it is very simple at all:

When I start the server (not dedicated, look above) and enter the world with as one of the soldiers and the A.I. is ENabled in the lobby, then of course I have this result:

one second after start I see the text "1"

two seconds after start I see the text "2"

So far, so fine. Everything is clear to me.

Then I start another instance of Arma and join my first instance. In this second instance I select player2 in the MP lobby (player1 is occupied, of course).

Question 1: While I am player2, that joined the server that is already running, I only get the hint "1" on my screen. I rather would have expected to see hint "2" ONLY. Why does player2 see the hint of the player1-init-line, which is not local for player2, but does not see his own init-line-hint?

When I 'jip' the server as player2 (player1 is the host) and the A.I. had been DISabled in the MP lobby, then I see hint "1" and one second later "2".

Question 2: Why does a client, that joins later by JIP, execute the init-line of a unit, that is not local to the JIP'er?

All this is so confusing :(

PS. This setup has no real purpose and is just there for testing and understanding.

Edited by RogueTrooper

Share this post


Link to post
Share on other sites

Init lines have nothing to do with locality, they are all run when a player joins. Only commands, not files or lines, have the concept of locality.

As for only one line showing up, the other might have been shown during loading then the other one. Remember execVM runs alongside the game and other scripts and you cannot expect a script started before another to also end before, especially not during loading I think.

Edited by Muzzleflash

Share this post


Link to post
Share on other sites

Because each client executes the init line in the mission.sqm. It doesn`t make any different if he is player1 or player2... each client read the mission.sqm file and executes it.

To be sure that only the local player1 executes the script file you have to add a condition like this:

if(not local player1)exitWith{player sideChat "You are player2!"};

:rolleyes:

Share this post


Link to post
Share on other sites

And please try to stop confusing yourself even more and change the extension of sqs files to sqs and not sqf like you do. :)

Btw, I personally try to avoid walls of code in init lines which should only run for a local object (like the player) exactly because inits run everytime again a player connects (as the others have mentioned already).

Just as a tip.

Xeno

Edited by Xeno

Share this post


Link to post
Share on other sites

I have used "hint", whose pling you can hear during the black "receiving..." screen.

When the client of player2, who joins later by JIP, executes the init-line of all units in mission.sqm, why then does it execute the init-line of player1 and not his own init-line (i.e. being player2 I hear and see pling/text "1", but not "2").

I am aware of

if !(local unit) then { exit };

I am using it in my files. As I said, this setup was just made to get an deeper insight.

Further, I do not confuse myself with sqs and sqf. :D

I am using [] exec "file.sqf" (f like fox) all the time (with certain exceptions) and everything works fine.

I am also aware, that a jip'ping client executes the init-line of the unit he is jip'ping into. I am exploiting it in my MP-maps where a jip'ping player shall get a fresh inventory although the unit might have been controlled by AI before he joined and fired ammo etc.

Edited by RogueTrooper

Share this post


Link to post
Share on other sites

exec:

Execute a script using (the deprecated) .sqs syntax. The argument is passed to the script in the "_this" variable.

It is not recommended to use this command. Instead, the execVM command should be used!

...

IMPORTANT: not reccomended for use with .sqf scripts! line breaks will cause problems if you do - use execVM for those

So, I don't know... If not confused, then at least stubborn old man :p

Share this post


Link to post
Share on other sites

In a trigger e.g., you can not use

["parameter1","parameter2"] execVM "test.sqf/s";

Error message: type script; expected nothing.

During my first Arma-scripting-steps in ArmA-One I learned, that execVM gave me error messages where it could, whereas [parameter] exec "file.sqF" works all the time, without any visible or hidden rpt error messages. So I kept [] exec sqF over the years...

/shrug

Share this post


Link to post
Share on other sites

All it needs is a handle, even a dummy like 0 which doesn't do anything (can't reassign a number):

0 = ["parameter1","parameter2"] execVM "test.sqf";

If you wanted to control it, say using scriptDone or terminate, you'd have to use a proper handle.

Share this post


Link to post
Share on other sites
In a trigger e.g., you can not use

["parameter1","parameter2"] execVM "test.sqf/s";

Error message: type script; expected nothing.

During my first Arma-scripting-steps in ArmA-One I learned, that execVM gave me error messages where it could, whereas [parameter] exec "file.sqF" works all the time, without any visible or hidden rpt error messages. So I kept [] exec sqF over the years...

/shrug

thats because in any editor object in the editor you need a handle, using

whatever = ["parameter1","parameter2"] execVM "test.sqf";

is the proper way to do it.

in scripts you dont need the whatever = handle, but in the editor directly you do need it.

edit: ninjaed :D

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  

×