Jump to content
Sign in to follow this  
Schilly

Looking for assistance...

Recommended Posts

I am trying to make a script so that a series of popup targets popup at random. Now the problem I am having, well 2 problems really... 1: "sleep" doesnt seem to want to work.. and 2: Getting the target to pop up, then down again after a short period of time then move onto a new target does not seem to want to work either.

Here is the script I have so far... Any help would be greatly apprieciated.

nopop = true;

_targets = [l1t1, l1t2, l1t3, l1t4, l1t5, l1t6, l1t7, l1t8, l1t9, l1t10, l1t11, l1t12, l1t13, l1t14, l1t15, l1t16, l1t17, l1t18, l1t19, l1t20, l1t21, l1t22, l1t23, l1t24, l1t25, l1t26, l1t27, l1t28, l1t29, l1t30];

{_x  animate["terc",1]} forEach _targets;
sleep 10;

foo = 0;

while "foo<30" do {
rnumber = random 30;
rtarget = _targets select rnumber;
rtarget animate["terc", 0];
sleep 3;
rtarget animate["terc", 1];
foo = foo + 1;
sleep 5;
};

Share this post


Link to post
Share on other sites

Not bad your very close.

name all your targets 1-30 I changed the names and only did 3 for testing

call the script and place in the trigger On act box

targets = [t1,t2,t3]; nul=[targets] execVM"popup.sqf";

Set the trigger to anyone not present and set all time boxes to min,mid,max to 2 which will give a short delay.

And script is

// targets = [t1,t2,t3]; nul=[targets] execVM"popup.sqf";
_targets = _this select 0;
//nopop = true;

//_targets = [l1t1, l1t2, l1t3, l1t4, l1t5, l1t6, l1t7, l1t8, l1t9, l1t10, l1t11, l1t12, l1t13, l1t14, l1t15, l1t16, l1t17, l1t18, l1t19, l1t20, l1t21, l1t22, l1t23, l1t24, l1t25, l1t26, l1t27, l1t28, l1t29, l1t30];

{_x  animate["terc",1]} forEach _targets;

hint "targets down";

sleep 2;

_foo = 0;

while {_foo<30} do {
hint "while";
_rnumber = random 2;
_rtarget = _targets select _rnumber;
_rtarget animate["terc", 0];
sleep 3;
_rtarget animate["terc", 1];
_foo = _foo + 1;
sleep 5;
};
hint "exit";
_targets = _this select 0;
//nopop = true;

//_targets = [l1t1, l1t2, l1t3, l1t4, l1t5, l1t6, l1t7, l1t8, l1t9, l1t10, l1t11, l1t12, l1t13, l1t14, l1t15, l1t16, l1t17, l1t18, l1t19, l1t20, l1t21, l1t22, l1t23, l1t24, l1t25, l1t26, l1t27, l1t28, l1t29, l1t30];

{_x  animate["terc",1]} forEach _targets;

hint "targets down";

sleep 2;

_foo = 0;

while {_foo<30} do {
hint "while";
_rnumber = random 2;
_rtarget = _targets select _rnumber;
_rtarget animate["terc", 0];
sleep 3;
_rtarget animate["terc", 1];
_foo = _foo + 1;
sleep 5;
};
hint "exit";

the // are lines not being used in the script.

Hints can be removed but are there to help debugging by letting me know where in the script is working.

.OH sleep is working fine.

.Place the script in note pad and save to your game mission with under the name "popup.sqf"

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Hello,

By trigger condition you mean what exactly? I know what the trigger condition is, but what would I set the trigger up to be? As it is right now, I have a "addAction" on a notice board to start the range... (this addaction ["Start", "start.sqs"]; for example)... Can this be done this way with the one you wrote?

Share this post


Link to post
Share on other sites

I've edited it a touch, see if that help. You may be able to call it your way but you will need to change start.sqs to nul=[tareget] execVM"popup.sqf"

you would also have to preload your variables into target by placing in a gamelogic.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Also suggest, just to make the code more clean, to change your while-loops to for-loops, since you use them exactly like a for-loop. Just easier to read :)

Share this post


Link to post
Share on other sites
Also suggest, just to make the code more clean, to change your while-loops to for-loops, since you use them exactly like a for-loop. Just easier to read :)

Is that more efficient, I was always told back in the days of BBC Basic that While was more efficient as it doesn't execute any code after it if it's not true.

Share this post


Link to post
Share on other sites

Hmm for some reason the targets are not doing anything... They all just stay put heh. I wonder what I am doing wrong. I loaded the vars into the game logic, and setup the "start.sqs" and "popup.sqf" like you suggested... Nothin.

Share this post


Link to post
Share on other sites

Depends on how you use them. You expect your setup to run 30 times, so whether it runs the code once before checking if it should run it again or if it checks first if to run it at all doesn't really matter.

You do have a point though, so under other circumstances while-loops can be more efficient.

Share this post


Link to post
Share on other sites

Never mind previous post... Fixed the problem.

Having the:

 _targets = _this select 0;

causes it to goof up and not have any targets for some reason.

When I removed that, and just used the static variable like I had before, it worked perfectly.

Share this post


Link to post
Share on other sites
Never mind previous post... Fixed the problem.

Having the:

 _targets = _this select 0;

causes it to goof up and not have any targets for some reason.

When I removed that, and just used the static variable like I had before, it worked perfectly.

strange it works in mine, I did miss the _ off in the first post and then updated it, you may have been too quick for me.

Share this post


Link to post
Share on other sites

I tried it both ways :| I got it to work this way though... Working quite well.

Going to be adding a counter into the mix as well... I'll post it up once I get it done.

Thanks for the help though :)

Btw: Here is the final script I used to get it to work:

popup.sqf


nopop = true;

_targets = [l1t1, l1t2, l1t3, l1t4, l1t5, l1t6, l1t7, l1t8, l1t9, l1t10, l1t11, l1t12, l1t13, l1t14, l1t15, l1t16, 

l1t17, l1t18, l1t19, l1t20, l1t21, l1t22, l1t23, l1t24, l1t25, l1t26, l1t27, l1t28, l1t29, l1t30];


{_x  animate["terc",1]} forEach _targets;

hint "Range Starting in 5...";
sleep 1;
hint "Range Starting in 4...";
sleep 1;
hint "Range Starting in 3...";
sleep 1;
hint "Range Starting in 2...";
sleep 1;
hint "Range Starting in 1...";
sleep 1;

_foo = 1;

while {_foo<31} do {
hint format["Firing Range Active\n--------------------------------------\nCurrent target: %1/30.", _foo];
_rnumber = random 30;
_rtarget = _targets select _rnumber;
_rtarget animate["terc", 0];
sleep 2;
_rtarget animate["terc", 1];
_foo = _foo + 1;

sleep random 5;
};
hint format["Safeties On, Range Inactive!\n--------------------------------------\nFinal Score: %1/30.", _foo];

-- The last hint in this one is where the final score will be shown, presently it just shows the target count.

r_start.sqs

nul=[target] execVM"popup.sqf";

---------- Post added at 04:14 PM ---------- Previous post was at 03:56 PM ----------

K another quesiton... What is the easiest way to tell if the target has been knocked over... In MULTIPLAYER. I was going to use the "addEventHandler" but that seems to be SP only.

Share this post


Link to post
Share on other sites

I carn't test right now, maybe if you can check for damage or !alive. I'm just guessing really.

Share this post


Link to post
Share on other sites

I tried using an if statement with an "animationPhase" but that didnt seem to work :|

---------- Post added at 06:30 PM ---------- Previous post was at 04:40 PM ----------

Another problem it seems I am having... "hint" does not seem to be global when in mutiplayer. For example, if I start the script, noone else can see the hints. Anyway to fix this?

---------- Post added at 07:22 PM ---------- Previous post was at 06:30 PM ----------

Anyone have any ideas?

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  

×