Results 1 to 6 of 6

Thread: Global variables

  1. #1

    Global variables

    I want to have a global variable that will be initiated to false in the init.sqf and then using an addAction it will run a script that will make the variable true.
    and then the condition for a unit to go to its waypoint is the global variable becoming true
    How would I do this?
    i tried doing this:
    init.sqf:
    startmission = false;
    flag pole object:
    _nul = this addAction["Start mission","start.sqf"];
    start.sqf:
    startmission = true;
    helicopter waypoint condition:
    startmission = true;

  2. #2
    See better method in post #6.

    init.sqf:
    Code:
    startmission = false;
    flag pole object:
    Code:
    _nul = this addAction["Start mission","start.sqf"];
    start.sqf:
    Code:
    _me = _this select 0;
    _act = _this select 2;
    _me removeAction _act;
    startmission = true;
    publicVariable "startmission";
    hint "Mission started!";
    helicopter waypoint condition:
    Code:
    startmission
    You were on the right track. Only real changes were publiczing the variable so the server knows it too and in the condition where we changed it from assignment to a check. Also removed the action since you didn't need it anymore and added some feedback.
    Last edited by kylania; Aug 22 2012 at 16:54. Reason: fixed

  3. #3
    Private First Class
    Join Date
    Apr 9 2012
    Posts
    14
    Author of the Thread
    Doesn't work. I did like you wrote but when I choose start mission using the scroll wheel nothing happens and the start mission action stays there

  4. #4
    That's odd, got lazy and it didn't work! I edited the code above and tested and it works.

    One thing to keep in mind is that a unit will travel TO a waypoint with a condition first but won't consider it "complete" till the condition is true. So to have someone stay where they are at the beginning put the condition waypoint at their vehicle nose or make that a HOLD waypoint and switch it with a trigger instead to kick the mission off. (Trigger with condition of start mission synched to the HOLD waypoint for example)

  5. #5
    Private First Class
    Join Date
    Apr 9 2012
    Posts
    14
    Author of the Thread
    Thank you so much! You really helped me!

  6. #6
    Quote Originally Posted by kylania View Post
    init.sqf:
    Code:
    startmission = false;
    Setting a variable value in the init.sqf will override the change made via the action, for the late joiners (Join In Progress players).
    The best option is to check if the variable has been assigned instead of its value, in this situation.

    Quote Originally Posted by kylania View Post
    Code:
    _me = _this select 0;
    _act = _this select 2;
    _me removeAction _act;
    startmission = true;
    publicVariable "startmission";
    hint "Mission started!";
    And within the waypoint condition just check if variable exists:
    PHP Code:
    !isNil startmission 
    Proud community admin/member of The Tour of Teamrespawn

Similar Threads

  1. Global variables in champaign
    By riise in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 2
    Last Post: Sep 7 2011, 06:12
  2. Global Variables that aren't really global...
    By Impavido in forum ARMA - MISSION EDITING & SCRIPTING
    Replies: 17
    Last Post: May 17 2007, 00:14
  3. Global variables
    By Sgt_Wilson in forum OFP : MISSION EDITING & SCRIPTING
    Replies: 3
    Last Post: May 27 2003, 21:43
  4. global and local variables
    By nalesnik in forum OFP : MISSION EDITING & SCRIPTING
    Replies: 3
    Last Post: Dec 16 2001, 13:07
  5. global and local variables
    By nalesnik in forum OFP : MISSION EDITING & SCRIPTING
    Replies: 0
    Last Post: Dec 15 2001, 17:27

Posting Permissions

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