Results 1 to 9 of 9

Thread: Problems with understanding jip and locality

  1. #1

    Problems with understanding jip and locality

    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:

    Code:
    _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.
    Last edited by RogueTrooper; Jul 6 2011 at 12:31.

  2. #2
    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.
    Last edited by Muzzleflash; Jul 6 2011 at 12:39.

  3. #3
    First Sergeant Buliwyf's Avatar
    Join Date
    Jan 1 2004
    Location
    Hamburg / Germany
    Posts
    823
    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:

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

  4. #4
    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
    Last edited by Xeno; Jul 6 2011 at 12:47.

  5. #5
    Gunnery Sergeant RogueTrooper's Avatar
    Join Date
    Dec 19 2007
    Location
    Respawn Screen
    Posts
    512
    Author of the Thread
    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
    Code:
    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.
    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.
    Last edited by RogueTrooper; Jul 6 2011 at 13:07.

  6. #6
    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
    Regards
    Carl Gustaffa - left this game due becoming Steam Exclusive

  7. #7
    Gunnery Sergeant RogueTrooper's Avatar
    Join Date
    Dec 19 2007
    Location
    Respawn Screen
    Posts
    512
    Author of the Thread
    In a trigger e.g., you can not use

    Code:
    ["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

  8. #8
    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.

  9. #9
    Warrant Officer Demonized's Avatar
    Join Date
    Nov 16 2010
    Location
    Back from afk 2013
    Posts
    2,614
    Quote Originally Posted by RogueTrooper View Post
    In a trigger e.g., you can not use

    Code:
    ["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
    Code:
    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
    My scripts:
    Spoiler:

    what to do when posting any kind of code dammit!!

    Any new mission editor or scripter in Arma2 should have read Mr Murrays Editing Guide Deluxe at least once, it still applies for A2 even though it was made for Armed Assault.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •