OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: sardaukar17 on 25 Aug 2009, 07:11:36

Title: (Timer) how to Check a==20
Post by: sardaukar17 on 25 Aug 2009, 07:11:36
All I want to do is check ONCE if Timer==20 or any other number. I'll show you what I am working on it will explain better than I can.

Code: [Select]
#ReStart
Timer=30

#Timer
~1
timer=timer-1
?(timer==20): goto "Infantry"
?(timer==10): goto "Armor"
?(timer==1): goto "Air"
?(timer<=0): goto "ReStart"
goto "timer"

The actual timer will count down as desired but the check for "Infantry" hits every second. When 10 seconds hits I can get it to go to armor once and same with Air. I predict either I have the syntax wrong or (and this is probly the case) the == command only works to make Parameters equal to Parameters, and apparently numbers are not parameters. I read some interesting stuff that can be done in the Decription and I have read about a few other scripts that are Timers but with all that effort toward creating all these Boolean variables there isn't a simple way to check to see if a number is equal to another number? I even went as far as to try Reverse phsycology on it

Code: [Select]
#ReStart
Timer=30

#Timer
~1
timer=timer-1

?((timer>=21) AND (timer<=23)): goto "Infantry"
?((timer>=11) AND (timer<=13)): goto "Armor"
?((timer>=1) AND (timer<=3)): goto "Air"
?(timer<=0): goto "ReStart"
goto "timer"
This actually produces the same result as before... So I guess the question is.. How do I make parameters equal to numbers?
Title: Re: (Timer) how to Check a==20
Post by: bardosy on 25 Aug 2009, 07:58:12
I'm not sure but try to use the same upper/lower case always... I mean: use timer (with small T) always or use Timer (with big T) always and never mix.
Title: Re: (Timer) how to Check a==20
Post by: Worldeater on 25 Aug 2009, 08:23:53
Hmm, SQS and SQF are not case sensitive. The syntax is fine and the script should work as intended. Did you check the RPT for errors?
Title: Re: (Timer) how to Check a==20
Post by: Zombie on 25 Aug 2009, 10:55:08
haven't tried it, but would _timer fix the problem?  I use a countup script and the variable is prefixed with _
my script
Code: [Select]
_count = 0
#Start
~1
_count = _count + 1
?(_count >= 1800): TimeUp = True
Goto "Start"
Title: Re: (Timer) how to Check a==20
Post by: h- on 25 Aug 2009, 11:14:00
@sardaukar17
Tested the first code sample and it works just fine here.. :dunno:
I used simple hints and goto "Timer" in each label and the timer works just fine..

Code: [Select]
#ReStart
Timer=30

#Timer
~1
timer=timer-1
player globalChat format ["%1",timer];
?(timer==20): goto "Infantry"
?(timer==10): goto "Armor"
?(timer==1): goto "Air"
?(timer<=0): goto "ReStart"
goto "Timer"

#Infantry
hint format ["Infantry label\n timer:%1",timer]
goto "Timer"

#Armor
hint format ["Armor label\n timer:%1",timer]
goto "Timer"

#Air
hint format ["Air label\n timer:%1",timer]
goto "Timer"
Title: Re: (Timer) how to Check a==20
Post by: sardaukar17 on 25 Aug 2009, 17:03:28
lol well whatever it was I was doing wrong I must have fixed when I posted it. :confused: It works now.
I appriciate the help. :clap: Atleast it's there for someone else to find if they need a simple timer. :good:

Lesson #432
Do not try to do any scripting when very tired