Jump to content
kvntvan

Checking for publicvariable in Condition

Recommended Posts

Hello, I'm trying to add a custom ace interaction to build a camp when certain conditions are met by the player.

However I do not want them to be able to build a second camp after the first is already built, I thought the easiest way to accomplish this was by setting a publicvariable to true and to only have the action available when the variable was false.

 

this is what the add ace interaction code looks like

if !(hasInterface) exitWith {};

_condition = {
    ('murshun_cigs_lighter' in (VestItems player + Uniformitems player + backpackItems player)) && campspawn == false;
};
_statement = {
        execVM "Camp_Script\spawn.sqf";
};
_build = ["buildcamp","Build Camp","\a3\ui_f\data\IGUI\Cfg\Actions\Obsolete\ui_action_fire_in_flame_ca",_statement,_condition] call ace_interact_menu_fnc_createAction;
[(typeOf player), 1, ["ACE_SelfActions"], _build] call ace_interact_menu_fnc_addActionToClass;


 

the part I'm having problems with is the second part of the condition, the entire code worked perfectly until I added this line

&& campspawn == false;

 

additional things I added, I added this

campspawn = false; publicVariable "campspawn";

into my init.sqf

 

placed

campspawn = true;

into the end of my camp building script

and

campspawn = false;

into my camp packing script.

But I get this error when loading into the game

e132e03a13.png

 

It says the error is a missing ";" but I don't think thats the actual issue because I've tried it with and without semicolons and have tried semicolons in a few different places to no avail, so would anyone happen to know what I'm doing wrong?

Share this post


Link to post
Share on other sites

A "missing ;" error is generally not literal - it means something is wrong with the code in such a way that the engine expects the expression to end somewhere it doesn't. 

 

In this case, the error message shows one "=" where there should be two, so it thinks the condition should actually end with "campspawn" (I.E. checking if campspawn is true).

  • Like 1

Share this post


Link to post
Share on other sites

more exactly:

... && ! campspawn

instead of

... && campspawn = false

 

  • Like 2

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

×