Home   Help Search Login Register  

Author Topic: Having problems with timer script  (Read 1634 times)

0 Members and 2 Guests are viewing this topic.

Offline Proxemo

  • Members
  • *
Having problems with timer script
« on: 18 Sep 2007, 01:34:51 »
I have a script here that I cannot get working. Here is the idea behind it:

I have 6 targets in a room.

When blufor activates trigger, a timer begins. The format is seconds/milliseconds.

When all six targets are down, timer ends and a hint format box pops up and displays time taken in seconds.
 
I had already set an object down to reset the targets using action menu. I would like to tie this in with resetting the timer as well.

Here is what I have so far but I am receiving errors.
*****************************************************

;start timer and display start message
hint format["The timer has been reset to 0 seconds"]
~1
_count = 0
#loop
_count = _count+1
?(alive t1) and (alive t2) and (alive t3) and (alive t4) and (alive t5) and (alive t6): goto "loop"

;display end message and time taken
hint format "All targets cleared" /n "Time Taken: " _count " seconds"
~5
********************************************************************

What happens when I load this up, I get the hint format prompt, "timer has been reset..." and it doesn't go away. If I continue to shoot targets and knock them down, nothing happens after that.

I have no idea about how to code the timer to reset using an action menu.

Just curious if any of you scripting guru's can help me out. I'm somewhat new at this so be gentle.




Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Having problems with timer script
« Reply #1 on: 18 Sep 2007, 02:02:34 »
comments on ur code

Code: [Select]
hint format["The timer has been reset to 0 seconds"] <---- u dont need format in here just : Hint "The time has been reset to 0 seconds"
~1
_count = 0
#loop <---- u need som time delay in dis loop so add a : ~1 just after dis line
_count = _count+1
?(alive t1) and (alive t2) and (alive t3) and (alive t4) and (alive t5) and (alive t6): goto "loop"  <---- dis will stop da loop when da 1st target is dead u need 2 change da ands to ors

;display end message and time taken
hint format "All targets cleared" /n "Time Taken: " _count " seconds" < ------ dis is not a vlid use of da format comand it shud b : hint format ["All targets cleared/nTime Taken %1 seconds",_count]
~5 < ---------u dont need a delay if deres nothing after it

also nicer way 2 do dis (using functinos as dey r beter dan scripts is like dat

LCD_Timer.sqf

Code: [Select]
private ["_LCD_Count"];

hint "The timer has been reset to 0 seconds";
sleep 1;

_LCD_Count = 0;
while {{alive _x} count [t1,t2,t3,t4,t5,t6] > 0} do
{
        sleep 0.5;
        _LCD_Count = _LCD_Count + 0.5;
};

hint format ["All targets cleared./nTime Taken %1 Seconds",_LCD_Count];

if (true) exitwith{}:

hope dat helps u

btw

WELCOME 2 OFPEC M8

:D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Proxemo

  • Members
  • *
Re: Having problems with timer script
« Reply #2 on: 18 Sep 2007, 08:18:55 »
Thanks a lot man. I just ended up doing the fix you have commented on because I have no idea about that sqf stuff. Remember, I am easily intimidated. :D

Now that I got it working I do have a tweak to it that I should make.


Instead of activating the count by walking into the trigger, is it possible to activate the counter as soon as the first target is shot?
I have set the targets to go down in 3 shots. So after a single bullet is fired and hits any of the targets, the counter should begin. I would probably have to overhaul this script which would suck.




« Last Edit: 18 Sep 2007, 08:32:13 by Proxemo »

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Having problems with timer script
« Reply #3 on: 18 Sep 2007, 08:27:50 »
4 randomness u need da random comand :P :D

but im not sure if this setdamage 0 wud work 2 acyualy reanimate things  :dunno: u may need 2 replace em usin createvehicle comand... but i didnt try tho :P so tel me if it works :D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Proxemo

  • Members
  • *
Re: Having problems with timer script
« Reply #4 on: 18 Sep 2007, 08:30:47 »
lol damn. you got me in the middle of editing my post about the randomness. I was going to create a new thread. Sorry bud.

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Having problems with timer script
« Reply #5 on: 18 Sep 2007, 08:39:21 »
lol :D glad 2 b some holp ;)  :cool2:

Quote
Instead of activating the count by walking into the trigger, is it possible to activate the counter as soon as the first target is shot?

u cud add an eventhandler of da type "hit" nd use dat 2 detect if a target have been hit :P... what u do is set da timer script 2 start from da event handler... but u wud need 2 remove da 1st second delay (da ~1 after da hint) 2 make it count properly nd not mis da 1st second :D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta