Jump to content
Sign in to follow this  
smacker909

global variable question

Recommended Posts

Does a global variable get deleted when the script that defines it finishes running? I was trying to use a global variable from a second script AFTER the first one (which defined it) had finished.. and was getting errors. I thought that global variables would remain, but now I think maybe not?

Share this post


Link to post
Share on other sites

They do. (I mean, they stay in memory)... Probably bad timing. Add a fail safe to the second script:

waitUntil {!(isNil "yourGlobalVariable")};

Share this post


Link to post
Share on other sites

Okay, thanks! I'll try that :) On a side note, my script deals with generating a supply truck during my mission.. at random location, and then giving him a random destination, when reached, sets up insurgent camp there.. fun thing is I hopping in the blackhawk to locate and track the progress / result of the convoy ! I have gotten much better and flying haha.

Edited by smacker909
spelling

Share this post


Link to post
Share on other sites

Ha, yea, debug can be quite good training! :D

I got too lazy for that old fashion debug however.

You may consider using markers and stuff for debug. Then use the fast forward function.

For example, a marker attached to the truck, turning red if the truck and/or crew is dead/destroyed:

_debug = true; // Enable/Disable debug




if (_debug) then {

_yourTruck spawn {

	_marker = createMarker[str(random 999999), (getPosATL _this)];
	_marker setMarkerShape "ICON";
	_marker setMarkerType "mil_dot";
	_marker setMarkerColor "ColorGreen";
	_marker setMarkerSize [0.8, 0.8];

	while {({alive _x} count (crew _this) > 0) && (alive _this)} do { // Update marker while alive
		_marker setMarkerPos (getPosATL _this);
		sleep 1;
	};

	_marker setMarkerColor "ColorRed"; // Red marker = NO crew left or truck destroyed

};

};

Share this post


Link to post
Share on other sites

Thanks mate! That's good stuff. I'm still at the foot hills of the arma scripting mountain! lol. I shall be including _debug code in future scripts :D

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×