-
12-10-2009 07:34 PM #1
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 07:39 PM. Reason: more to say
-
12-10-2009 08:51 PM #2
Re: Scripting Trouble - Error Undefined Variable
Wrap the whole thing to:
Code:if (not isNil "player1") then { };
-
12-10-2009 11:39 PM #3
-
12-11-2009 07:59 AM #4
Re: Scripting Trouble - Error Undefined Variable
When is this bad boy being released?
Last edited by Dredge; 12-11-2009 at 02:36 PM.
ArmA Admin
|TG-18th| Commander









-
12-11-2009 02:58 PM #5
Re: Scripting Trouble - Error Undefined Variable
Probably tonight. I've had to redo part of it to make it better.
-
12-11-2009 03:15 PM #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
ArmA Admin
|TG-18th| Commander









Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)


Reply With Quote





Bookmarks