Welcome to Tactical Gamer

+ Reply to Thread
Results 1 to 6 of 6
Discussion: ArmA - Development / ArmA - Mission Development - Scripting Trouble - Error Undefined Variable - I am making my own simple revive script. Long story short, in multiplayer, when AI
  1. #1

    GeneralCarver's Avatar

    Join Date
    Aug 2007
    Location
    Indiana, USA
    Age
    32
    Posts
    532

    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 at 08:39 PM. Reason: more to say

  2.  
  3. #2

    Fincuan's Avatar

    Join Date
    Jan 2009
    Location
    Helsinki, Finland
    Posts
    772

    Re: Scripting Trouble - Error Undefined Variable

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

  4.  
  5. #3

    GeneralCarver's Avatar

    Join Date
    Aug 2007
    Location
    Indiana, USA
    Age
    32
    Posts
    532

    Re: Scripting Trouble - Error Undefined Variable

    Quote 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!

  6.  

     
  7. #4



    Dredge's Avatar

    Join Date
    Oct 2009
    Location
    Keying ACOG's Car
    Age
    26
    Posts
    6,510
    Blog Entries
    5

    Re: Scripting Trouble - Error Undefined Variable

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


    Bastion: "I always enjoy it when the mentally questionable are given control of flying the aircraft"

  8.  
  9. #5

    GeneralCarver's Avatar

    Join Date
    Aug 2007
    Location
    Indiana, USA
    Age
    32
    Posts
    532

    Re: Scripting Trouble - Error Undefined Variable

    Probably tonight. I've had to redo part of it to make it better.

  10.  
  11. #6



    Dredge's Avatar

    Join Date
    Oct 2009
    Location
    Keying ACOG's Car
    Age
    26
    Posts
    6,510
    Blog Entries
    5

    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


    Bastion: "I always enjoy it when the mentally questionable are given control of flying the aircraft"

  12.  

     

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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


  
 

Back to top