Announcement

Collapse
No announcement yet.

Scripting Trouble - Error Undefined Variable

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

  • Scripting Trouble - Error Undefined Variable

    I am making my own simple revive script. Long story short, in multiplayer, when AI is disabled, I am getting the Undefined Variable error when my scripts reference the named units which are not being played in the current mission and are not present. If someone is playing the unit, it would work fine. The script below is one of a series of IF statements in the script which find which unit a player is

    if (player == player1) then <------ this is the error, if player1 unit is not used, it will say undefined variable.
    {
    gc_revive_player1needrevive = "true";
    gc_revive_player1active = "false";
    gc_revive_player1oldbody = _oldbody;
    gc_revive_inholding = "true";
    publicvariable "gc_revive_player1needrevive";
    publicvariable "gc_revive_player1oldbody";
    publicvariable "gc_revive_player1active";
    "player1marker" setmarkerpos getpos _oldbody;
    "player1marker" setmarkertext ("" + str name player + " (needs revive)");
    "player1marker" setmarkertype "Dot";
    };

    So, this code works when someone is playing the unit player1. However, if that unit is not used in a multiplayer game, it will return an error "undefined variable". As would be expected, since player1 doesn't exist at the time.

    Can anyone think of a way around this?
    Last edited by GeneralCarver; 12-10-2009, 07:39 PM. Reason: more to say
    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: Scripting Trouble - Error Undefined Variable

    Wrap the whole thing to:
    Code:
    if (not isNil "player1") then
    {
    
    };

    Comment


    • #3
      Re: Scripting Trouble - Error Undefined Variable

      Originally posted by Fincuan View Post
      Wrap the whole thing to:
      Code:
      if (not isNil "player1") then
      {
      
      };

      That worked man! Thanks a lot! Case closed!
      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


      • #4
        Re: Scripting Trouble - Error Undefined Variable

        When is this bad boy being released?
        Last edited by Dredge; 12-11-2009, 02:36 PM.

        [unit][squadl][command2]

        KnyghtMare ~You could always tell the person holding the gun to your head you would like to play on a different server...

        Comment


        • #5
          Re: Scripting Trouble - Error Undefined Variable

          Probably tonight. I've had to redo part of it to make it better.
          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


          • #6
            Re: Scripting Trouble - Error Undefined Variable

            I eagerly await its release......need to put it in the ACE Event Mission...nice little debut me thinks

            [unit][squadl][command2]

            KnyghtMare ~You could always tell the person holding the gun to your head you would like to play on a different server...

            Comment

            Connect

            Collapse

            TeamSpeak 3 Server

            Collapse

            Advertisement

            Collapse

            Twitter Feed

            Collapse

            Working...
            X