Jump to content
Sign in to follow this  
icebreakr

Obstacle course timer

Recommended Posts

I'm making a mission for my SBP Camp Noobia obstacle course. I would need a script that would work with two triggers:

1. when blufor (anyone) passes the line the timer starts (via hint?)

2. when blufor passes the finish line the full time appears :)

anyone ? ;)

Share this post


Link to post
Share on other sites
I'm making a mission for my SBP Camp Noobia obstacle course. I would need a script that would work with two triggers:

1. when blufor (anyone) passes the line the timer starts (via hint?)

2. when blufor passes the finish line the full time appears :)

anyone ? ;)

Did the training obstacle course in the original BI mission have a timer? You could take a look at that. Beyond that I don't know. I figured it might help you a little until someone else replies.

Share this post


Link to post
Share on other sites

Untested, but as far as I can think, this should work. It's crude and needs refinements, but it gives the basic principle ;)

Run this as a script from the first trigger (activated by BLUFOR, repeatedly), passing thisList to the script:

if(!player in thisList) exitWith {};

player setVariable ["SBP_courseStart", time];
hint "Course started!";

And this as a script at the end trigger (again, BLUFOR repeatedly):

if(!player in thisList) exitWith {};

_start = player getVariable "SBP_courseStart";
_end = time;

hint format["You completed the course in %1 seconds", (_end-_start)];

Edited by JamesF1

Share this post


Link to post
Share on other sites

Should be simple.

Activation Code in first trigger:

_nul = "start" execVM "timer.sqf"

Activation Code in second trigger:

_nul = "end" execVM "timer.sqf"

timer.sqf:

if(_this == "start") then{stopwatchtimer = time; hint "time is running..."};
if(_this == "end" && not (isNil "stopwatchtimer")) then{
  hint format["Total time: %1", time - stopwatchtimer];
  stopwatchtimer = nil;
};

EDIT: Damn, someone else was faster ^^. However, too similar approaches, might help you.

Edited by Bon

Share this post


Link to post
Share on other sites

Just a minor point, but yours will trigger a hint on any connected players for any BLUFOR unit who trips the trigger (hence why I included a check for the player in the trigger). It's not really a problem, but it would then be better to change the hint so that it says who started/completed the course (or implement a player check) ;)

Share this post


Link to post
Share on other sites

Great guys, how do you implement the "nick" of the currently competing player?

Share this post


Link to post
Share on other sites
Just a minor point, but yours will trigger a hint on any connected players for any BLUFOR unit who trips the trigger (hence why I included a check for the player in the trigger). It's not really a problem, but it would then be better to change the hint so that it says who started/completed the course (or implement a player check) ;)

I assumed its for SP purposes only. To avoid the trigger to be executed on every machine when a certain player enters it, you can simply replace the condition of the triggers from "this" to "player in thislist". Then the trigger is only executed on the machine of the player who actually entered it.

To get the name/nick of a player the command is (what a surprise) name.

Hf.

Share this post


Link to post
Share on other sites

Just whipped up something that works purely in triggers, and should work in multiplayer (but I've not tested). Don't expect something optimal, though, as I'm far too tired for that ;) It also allows more than one player to run at any one time, and announces the course start/timing to all other BLUFOR players (it doesn't even register the runners if you're OPFOR).

Rather than explain the set-up, I've bundled a test mission :) The trigger next to the player (left side) is just for debug - so don't bother copying that over. You could simply merge this in to whatever you need - just extract to your missions folder :)

http://jamesburgess.co.uk/misc/TimerTest.utes.zip

Share this post


Link to post
Share on other sites

Great dude, will test it out :)

EDIT: excellent, works perfectly! Thank you

Edited by IceBreakr

Share this post


Link to post
Share on other sites

Hey guys, this is just what I've been looking for and I have it set up to use Bon's coding with the two triggers and it works great.

I'm trying to adapt it to use in a mission with a nuclear bomb. Short story, the nuke is randomly placed in 1 of about 6 locations and the group is searching for it. My trigger so START the timer is attached to the nuke itself so that no matter where it goes the trigger to START a timer goes with it.

There is the second trigger that sits right on top of it so that when they reach it and deactivate it, the timer gives them the time and stops.

can anyone give me the coding for a couple of things:

1) coding to use on a trigger that if Bon's timer EXCEEDS a certain time limit, the nuke will explode (I can make it explode, I just need the coding for it to do so after a time limit)

2) This one isn't as critical, but I'd like for the timer to SHOW UP onscreen for my players. Using Bon's code, above, what is the syntax to get the timer to show up on screen as it counts.

Basically I have it set up so that when players find the right town with the nuke, using a script, I have a bunch of OPFOR show up to defend the nuke and players have to fight their way through them all to disarm it in time.

Thanks in advance for the help guys....:D

Share this post


Link to post
Share on other sites

Is there a way to store this info? So it can be easily reviewed and tallied after multiple sections of a course?

Share this post


Link to post
Share on other sites

you can store it via Variables for every unit that ran the course.

it should be something like this:

if(!player in thisList) exitWith {};

_start = player getVariable "SBP_courseStart";
_end = time;

hint format["You completed the course in %1 seconds", (_end-_start)];

_score = (_end-_start);
player seVariable ["score", _score, false]; //This is what I added.

then to call the scores again, you just get the "score" variable from each person that have gone through the course;

Share this post


Link to post
Share on other sites

Thank you Silderoy! I read the wiki http://community.bistudio.com/wiki/setVariable for setVariable, but I am sorry to say this is all beyond me. How would I get the "score" after it's been recorded form the initial section of the course?

Also if a group were to run the course would "group getVariable" work in place of "player getVariable" to give a time for the team?

Let me explain what I'm trying to do: I'm making a tank course that alternates between obstacle courses and firing ranges. If possible I'd like for all the timed sections (3) to be combined for a total sum at the end. Is this possible?

Thank you again!

Share this post


Link to post
Share on other sites
Thank you Silderoy! I read the wiki http://community.bistudio.com/wiki/setVariable for setVariable, but I am sorry to say this is all beyond me. How would I get the "score" after it's been recorded form the initial section of the course?

Also if a group were to run the course would "group getVariable" work in place of "player getVariable" to give a time for the team?

Let me explain what I'm trying to do: I'm making a tank course that alternates between obstacle courses and firing ranges. If possible I'd like for all the timed sections (3) to be combined for a total sum at the end. Is this possible?

Thank you again!

after you stored the scores, you will use "getVariable" to get them.

for example "_soldier1Score = Soldier1 getVariable "score";

Yes, you can set a variable to a whole group. but you will need to modefy the script, so it doesnt count every player for himself but the from the moment the first group member get into the course, to the moment the last group member leaves the course. then you use the name of the group for the setVariable. if you dont know it, use:

(group _soldier) setVariable ["score", _score, false];

_soldier is the name of one of the soldiers in the group.

Edited by Silderoy

Share this post


Link to post
Share on other sites

I'm using this:

if(side player==west) then { if(isNil "runners") then { runners = []; }; runners = runners + [[(thisList select 0),time]]; hint format["%1 started the course!", name (thisList select 0)]; };

How would I make this work for a a list of vehicles instead of players?

Thanks!

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  

×