Jump to content
Sign in to follow this  
SGT Fuller

Error with my script

Recommended Posts

Hey guys having these errors populate the RPT and would really appreciate some help fixing this thanks in advance

_A10C selectWeap>

20:28:42 Error Undefined variable in expression: _a10c_switch

20:28:42 File USAF_A10\scr\loadouts\A10C_dynamic_loadouts.sqf, line 123

20:28:42 Error in expression <g_done_switch";

sleep 0.01;

WaitUntil { _A10C_switch == 1};

_A10C selectWeap>

20:28:42 Error position: <_A10C_switch == 1};

here is that entire selection that im sure its refering to ending with line 123

//REARMING SWITCH, CAN BE SUBSTITUDED BY VARIABLE, USED TO PREVENT

//MULTIPLE INSTANCES OF SAME FUNCTION AT ONCE

_A10C_switch = _A10C getVariable "Rearming_done_switch";

sleep 0.01;

WaitUntil { _A10C_switch == 1};

Share this post


Link to post
Share on other sites

I would make sure your getVariable has some sort of default value (look at the wiki for syntax) and I would also just move the getVariable line into the waitUntil condition.

Share this post


Link to post
Share on other sites

getVariable has a syntax that returns a default value, this way, you don't get an error if variable has not been set yet.

_result = _thing getVariable ["myValue", "defaultValueIfMyValueDoesNotExist"];

waitUntil {
   (_A10C getVariable ["Rearming_done_switch", 0]) == 1
};

Edited by Zigomarvin

Share this post


Link to post
Share on other sites
getVariable has a syntax that returns a default value, this way, you don't get an error if variable has not been set yet.

_result = _thing getVariable ["myValue", "defaultValueIfMyValueDoesNotExist"];

waitUntil {
   (_A10C getVariable ["Rearming_done_switch", 0]) == 1
};

Hey brother it didn't seem to work

Share this post


Link to post
Share on other sites

its been awhile since i have done anything in sqf(been elbow deep in c++ for the last 3 months) but maybe its not liking that "phrasing" of the condition while being compared?

maybe


waitUntil {
 _randomVar = _A10C getVariable "Rearming_done_switch"; // pretty sure this would just be a readability thing but again, im rusty on my sqf and could be completely unnecessary.
 (_randomVar == 1) 
};  

would work?

the way this reads to me (from my c++ corrupted mind) is it sets the variable, stores "Rearming_done_switch" then waits for it to equal 1 (or what ever value you need it to be)

if you havent tried this approach, try it, your original idea looks correct but doesnt look savy with sqf syntax.

the code i have written takes into consideration that the default value has already been defined, the way zigo did it was correct syntactically also. (i think)

Edited by Sw4l

Share this post


Link to post
Share on other sites

Hey, for some reason i can only reply to threads and not make my own(retarded:p)

I didnt find any posts more similar to what im wondering.

What is the correct code to count all BLUFOR/OPFOR/INDEPENDENT players and make that number come up on a statusbar as a player joins/leaves team/server.

for example: count playableUnits_WEST. Only that one right there wont work. im getting "BLUFOR: scalar" on my statusbar with that code in the sqf file.

Is anyone capable of helping me with this?

Thank you very much, and again....Im very sorry if i did something very wrong by replying to this thread about this. I just didnt see any other way.

Share this post


Link to post
Share on other sites

Hi,

Not sure it's the best way but this may work :

_count = 0;
{
if((side _x) == west) then {_count = _count + 1};
} foreach playableUnits;

And for original thread :

//REARMING SWITCH, CAN BE SUBSTITUDED BY VARIABLE, USED TO PREVENT
//MULTIPLE INSTANCES OF SAME FUNCTION AT ONCE
WaitUntil {sleep 0.01;((_A10C getVariable ["Rearming_done_switch",0]) == 1)};

Edited by Mash6

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  

×