Jump to content
Sign in to follow this  
Provac

Scripting noob needs help

Recommended Posts

Basically its a script that goes through 10 rounds of shooting targets and at the end calculates a total score for each round. I get some errors in the first while {} do {} commands saying its expecting a script or code or something. If someone pro can look over it and tell me what is wrong with the setup id be very happy and maybe learn a thing or two biggrin_o.gif

Quote[/b] ]

// Range

_target = [pr1,pr2];

_roundtime = 5;

_rounds = 0;

_score = 0;

// Kill Targets

{_x setdammage 1} forEach _target;

// Round start countdown timer

while {_roundtime > 0} do

{

_roundtime = _roundtime-1;

hint format ["Round will start in: %1s",_roundtime];

sleep 1;

};

// Rounds

while {_rounds < 10} do

{

// Resets round time and pop up targets

_roundtime = 4;

{_x setdammage 0} forEach _target;

while {_roundtime > 0} do

{

_roundtime = _roundtime-1;

hint format ["%1s",_roundtime];

sleep 1;

};

// Calculates Score for the round

_rounds = _rounds+1;

hint format ["Round %1 Complete",_rounds];

if (not alive _x) then {_score = _score+5} forEach _target;

{_x setdammage 1} forEach _target;

sleep 5;

};

// After all rounds are complete the total score and pass fail is announced

hint "Minimum 70 points to pass the range"

sleep 3;

hint format ["Final Score is %1 out of 100",_score];

sleep 3;

if (_score < 70) then {Hint format ["You did not pass the Pistol Range"]} else {Hint format ["You passed the Pistol Range"]};

thanks for any help that is given.

Share this post


Link to post
Share on other sites

Well, your mixing SQF and SQS scripting for starters. Replace all instances of ~ with "sleep".

i.e.:

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

while {_roundtime > 0} do

{

_roundtime = _roundtime-1;

hint format ["Round will start in: %1s",_roundtime];

~1

};

would become

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

while {_roundtime > 0} do

{

_roundtime = _roundtime-1;

hint format ["Round will start in: %1s",_roundtime];

sleep 1;

};

Share this post


Link to post
Share on other sites

Thanks Namikaze!

Now the script works 99%

Only thing left is that at the end of each round loop it doesnt count the score correctly.

if (not alive _x) then {_score = _score+5} forEach _target;

actually, it doesn't count at all. At the end of the script it always ends up with a _score of 0.

Any tips there? Maybe an alternative to check what targets have been killed and update the score before it re loops into a new round.

Share this post


Link to post
Share on other sites

Try this:

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

{if (not alive _x) then { _score = _score+5; }; } forEach _target;

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  

×