Jump to content
Sign in to follow this  
Desrat

Function with Return value (Example Requested)

Recommended Posts

can someone post a "for dummies" example (maybe the obligatory "hello world") of an sqf function that could be precompiled (for use with the call command) that will return a value,array or whatever.

Thanks in advance

Share this post


Link to post
Share on other sites

In simple form....

A useless but simple example to return the height (z value) of an object

Create a file called "fn_getZ.sqf" in your mission folder.

fn_getZ.sqf:-

private ["_obj","_z"];

_obj = _this select 0;

_z = getPos _obj select 2;

_z

In your init.sqf (precompile):-

getZ = compile preprocessFileLineNumbers "fn_getZ.sqf";

To call:-

_height = [_plane] call getZ;

_height will contain the height (z value) of the _plane.

This returns a single value. If you can't figure out returning an array I can post another example for you.

Share this post


Link to post
Share on other sites

that should put me on the right track, thx to the pair of you :)

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  

×