Jump to content
Sign in to follow this  
nuxil

How to pass an argument to a running script?

Recommended Posts

hi forum.. i need some help solve my little problem..

i need to know how i can pass an argument to a running script.. without using publicalvariable's

i tried using something like this..

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

// test.sqf

_me = _this select 0;

_id = _this select 2;

_arg = _this select 3;

while {(_arg == 1)} do {

hint "the test script is running";

sleep 1;

_me removeaction _id;

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

// init.sqf

_me = _this select 0;

_teston = _me addaction["t on", "test.sqf",1,1,false];

_testoff = _me addaction["t off", "test.sqf",0,1,false];

but the problem with this is that its not stoping.. but rather staring a script and passing 0 as the argument when i press t off in my user action menu..

ps. i need to use the user action menu.

Share this post


Link to post
Share on other sites

The addaction will always start a script. However, you could make the script that is run when you use the action simply change variables for your "t" script.

Basically, t_on.sqf and t_off.sqf would modify a global boolean variable called "t_status", setting it to true or false, and then exit when done. Your t.sqf script (always running in the background) would then perform its functions only if t_status was set to on. (You could have t.sqf run a loop that only performs its actions if t_status is true.)

Might be a bit complicated but it's the first thing I thought of.

Good luck.

Share this post


Link to post
Share on other sites

There are at least a couple of ways of doing it. The setVariable version, could look like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// teston.sqf

_me = _this select 0;

_id = _this select 2;

_arg = _this select 3;

_me setVariable ["myaction",_arg];

while {((_me GetVariable "myaction") == 1)} do {

hint "the test script is running";

sleep 1;

};

_me removeaction _id;

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//testoff.sqf

_me = _this select 0;

_id = _this select 2;

_arg = _this select 3;

_me setVariable ["myaction",_arg];

_me removeaction _id;

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// init.sqf

_me = _this select 0;

_teston = _me addaction["t on", "teston.sqf",1,1,false];

_testoff = _me addaction["t off", "testoff.sqf",0,1,false];

Share this post


Link to post
Share on other sites

problem solved wink_o.gif

thanks for your help guys. notworthy.gif

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  

×