Announcement

Collapse
No announcement yet.

Help-Object Null Variable Troubles

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help-Object Null Variable Troubles

    I am attempting to make my own Engineer Script for ArmA and ArmA 2 which allows an engineer to do several tasks not by default in the game. One, obviously, is to repair vehicles.

    I would like to add an action to a vehicle for the engineer to activate and repair it, if its damaged. This requires using the nearestobjects command to search and find the vehicle types the script supports.

    This concept works when it finds vehicles. However, the trouble comes when the command returns nothing (when there is nothing around). It will assign an null-object value to a variable.

    I am unable to develop a script which can tell if the variable is a null object or not. I have tried the ObjNull, isNil,...all those commands, and still no luck.

    So, does anyone know if it is possible to determine if a variable has no value assigned to it?
    Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity. - General George S. Patton.

  • #2
    Re: Help-Object Null Variable Troubles

    If a variable has not been initialized in any way this will be true:
    Code:
    isNil "variablename";
    If it has a null-object/control/etc assigned to it this will be true:
    Code:
    isNull variablename;
    Also I'm pretty sure nearObjects returns an empty array if it doesn't find anything, meaning you could possibly check if it has found anything with:
    Code:
    _ar = player nearObjects 50;
    if (count _ar > 0) then
    {
    what should be done if it found objects
    };

    Comment


    • #3
      Re: Help-Object Null Variable Troubles

      Yeah, if you use nearestObjects, it returns an array of objects that fit the conditions, the array is sorted by distance, closest objects are first in the array.

      So, count the array, if it is greater than 0, there are objects near the player.

      Comment


      • #4
        Re: Help-Object Null Variable Troubles

        sweet thanks beita. I'm blowing you a digital kiss right now.
        Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity. - General George S. Patton.

        Comment


        • #5
          Re: Help-Object Null Variable Troubles

          eww omg omg!

          TGU Instructor TG Pathfinder

          Former TGU Dean Former ARMA Admin Former Irregulars Officer

          "Do not seek death. Death will find you. But seek the road which makes death a fulfillment." - Dag Hammarskjold

          Comment


          • #6
            Re: Help-Object Null Variable Troubles

            If you hate using quotes, you can do the following:

            Code:
            isnil {variablename}
            Its also faster, as it saves compilation of the string :P.

            Comment


            • #7
              Re: Help-Object Null Variable Troubles

              Originally posted by Rommel View Post
              If you hate using quotes, you can do the following:

              Code:
              isnil {variablename}
              Its also faster, as it saves compilation of the string :P.
              Should put that on the optimization-page :)



              Comment

              Connect

              Collapse

              TeamSpeak 3 Server

              Collapse

              Advertisement

              Collapse

              Twitter Feed

              Collapse

              Working...
              X