Jump to content
Sign in to follow this  
Nutty_101

Execute SQF scripts without a file?

Recommended Posts

I am curious if we can execute SQF scripts without a physical file on the hard drive? At the moment i am having to write the files and i would really like to have the ability to just compile a string and run it.

Share this post


Link to post
Share on other sites
I am curious if we can execute SQF scripts without a physical file on the hard drive? At the moment i am having to write the files and i would really like to have the ability to just compile a string and run it.

e.g:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">call compile "string string string";

e.g:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_string="blablalbal";

call compile _string;

e.g:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_string=format["tst_isServer=%1",isServer];

call compile _string;

e.g:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_code={code to execute blablalbal};

call _code;

or:

[] spawn _code;

You can even write multi line:

e.g:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_code=

{

code to execute blablalbal;

code to execute blablalbal;

code to execute blablalbal;

code to execute blablalbal;

code to execute blablalbal;

};

call _code;

You can even write multi line:

e.g:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_string=

"

code to execute %1;

code to execute %2;

code to execute %3;

code to execute %4;

code to execute %5;

";

call compile format[_string, isServer, isPlayer Player, time, daytime, getPos Player];

if you want to run the code in a spawned instance

Share this post


Link to post
Share on other sites

I will try again, i get a ton of formatting errors when i try to call or compile sqf formatted code. Seems to be only using SQS format so if i have it does not work. I guess i could just use a single line, that might be my issue. humm

Quote[/b] ]

if (blah) then {

kljasdjf=1;

} else {

aslkdjf;alskdj=2;

};

Share this post


Link to post
Share on other sites

Ahh, its my comments. I guess i cannot have them in there from what i see so far.

Works:

Quote[/b] ]_Test = "player sidechat ""eeooooo"";

if (!True) then {

hint ""HI!"";

sleep(10);

player setpos [0,0,0];

};

";

_go = compile _Test;

call _go;

Does not

Quote[/b] ]

_Test = "player sidechat ""eeooooo"";

if (!True) then {

hint ""HI!"";

/* Testing comment errors

*/

sleep(10);

player setpos [0,0,0];

};

";

_go = compile _Test;

call _go;

Nor does //

Man, wish i would have tried harder. laugh.. Thanks man.

Share this post


Link to post
Share on other sites

Thanks again SickBoy. That let me use a single script now to pull down running scripts from the database. Much cleaner and easier now.

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  

×