Jump to content
Sign in to follow this  
Rydygier

Problem with "getvariable" - alternative syntax causing RPT error

Recommended Posts

This part of sqf file executed with EH "handledamage":

_gcheck = _target getvariable [_gname,0];

(_target is an object, _gname is a string and 0 is 0).

causing an RPT error:

Error position: <getvariable [_gname,0]

Error getvariable: array type, string needed

It seems, that it doesn't recognize alternative getvariable syntax. Why?

Share this post


Link to post
Share on other sites

Thanks, but I need default value for an undefined variable, so standard syntax here is not an option and so am trying to use this: object getVariable [name, defaultValue] with the described effect.

Share this post


Link to post
Share on other sites

are you sure _gname is a string as I got the same thing the other day when I hadn't done it right.

Just doing a little test and not using EVH this works

gname = "myVariable";what = myTruck getVariable [gname,4];hint format ["%1",what]

Share this post


Link to post
Share on other sites

Yes, _gname is a string for sure. Tried with other strings too. I tried code similar to your in sqf activated by trigger:

gname = "myVariable";
what = sold1 getVariable [gname,4];
sleep 5;
diag_log format ["%1",what];

and same error occurs. Maybe alternative syntax was introduced after Arma 2 1.10, which I use?

Share this post


Link to post
Share on other sites

The alternate syntax was added to the Biki in Novembrr 2010 which predated 1.10 so that would imply it was viable before then. I have never seen the alternate syntax, have you had luck with it before?

Share this post


Link to post
Share on other sites

It works fine for me in OA, I just tried the same code in Arma2 and it won't accept it.

Share this post


Link to post
Share on other sites

A2 is older then OA. No need to update the BIKI.

Share this post


Link to post
Share on other sites

Well. If so, I have to find another way. If there is any. Thanks for help.

Share this post


Link to post
Share on other sites
gname = "myVariable";
what = sold1 getVariable gname;
if (isNil "what") then {what = 4;};//new
sleep 5;
diag_log format ["%1",what];

Share this post


Link to post
Share on other sites

So simple... thanks a lot. :)

Share this post


Link to post
Share on other sites

I was trying the same thing but could only get any returned I never new what had to be in quotes in the isNil. Thanks also.

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  

×