Jump to content
Sign in to follow this  
j_murphy

Pop-up Target script Error "Invalid number in expression"

Recommended Posts

Hi, I am making a rifle range script for arma 3 and I am getting 2 problems:

 

1) When I run this the debugger returns ""Invalid number in expression on line 13", here is the function.

targetPool = [tar1,tar2];
_numTargets = count targetPool;
monitorTargets = false;
hitNumber = 0;

if (_numTargets > 0) then {
	monitorTargets = true;
};
//Loop while we are being asked to
while {monitorTargets} do {
		
	{
		if (animationState == "terc" && animationPhase == 1)  {
			hitNumber = hitNumber + 1;
			hintSilent format["Hit number: %1", hitNumber];
		} else if (animationState = "terc" && animationPhase == 0) {
			_this animate["terc",1];
		} else {
			hintSilent "Miss!";
		};
		
	}forEach targetPool;
};

2) This not a fatal issue but it's not ideal. I can't call the function even though I have defined the class in a c++ header file. my description.ext:

#include "Functions.h"

and my Functions.h:

class CfgFunctions {

	class crane {
		file = "functions\";
		tags = "crane";

		class PreTasks {
			//For funtions to be initialised before init obj's
			preInit = 1;

			class setWarInventory{};
			class setRidgebackInventory{};
			class startRange{};
		};

		class PostTasks {
			//for functions to be initialised after init obj's
			postInit = 1;
			
			class stopRange{};
		};

	};

};
//I forgot to end the CfgFunctions class with };

Thank you for any help. 

Share this post


Link to post
Share on other sites
targetPool = [tar1,tar2];
_numTargets = count targetPool;
monitorTargets = false;
hitNumber = 0;

if (_numTargets > 0) then {
    monitorTargets = true;
};
//Loop while we are being asked to
while {monitorTargets} do {
        
    {
        if (animationState == "terc" && animationPhase == 1) then
        {
            hitNumber = hitNumber + 1;
            hintSilent format["Hit number: %1", hitNumber];
        }
        else
        {
            if (animationState = "terc" && animationPhase == 0)
            {
                _this animate["terc",1];
            }
            else
            {
                hintSilent "Miss!";
            };
        };
    }forEach targetPool;
};

This should work if I didn't miss something. You forgot a "then" and some brackets

 

 

Edit: ninja'd

 

 

@OP, report your other post to a mod via the report button so it can be deleted.

 

 

Edit: Also, add a sleep to your while loop, otherwise it will run on each frame.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you for your help. EDIT: It still doesn't work, it says that the error is in line 13 in the condition. 

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  

×