Jump to content
Sign in to follow this  
acidcrash

Pop-up target script problem

Recommended Posts

Right, I've been working on a little script for pop-up targets and keepting track of hits and misses. All works fine untill you miss a target, at this point the whole thing goes apeshit at me and makes it impossible for the person shooting to hit the target.

I cant see whats wrong especially as it worked before i added the random time section (see below) and the "miss" section wasnt altered, the only thing altered is the loop section which is where i added the random-"gotos"

anyway, the script in question

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

;Acidcrash

;Pop-Up targets, random timing

;-------------------------------

?!(local Server) : exit

pistol = 0; publicvariable "pistol"

missed = 0; Publicvariable "missed"

_seconds = 0

#loop

_rand = random 5

_num = _rand - (_rand mod 1)

?(pistol >= 16): goto "end"

_pistol = _pistol + 1

_seconds = 0

target setdammage 0

?_num == 1 : goto "one"

?_num == 2 : goto "two"

?_num == 3 : goto "three"

?_num == 4 : goto "four"

#one

_seconds = _seconds + 0.1

;debug

;hint "one"

?(getdammage target > 0.5): goto "hit"

?(_seconds >= 5): goto "missed"

~0.1

goto "one"

#two

_seconds = _seconds + 0.1

;debug

;hint "two"

?(getdammage target > 0.5): goto "hit"

?(_seconds >= 6): goto "missed"

~0.1

goto "two"

#three

_seconds = _seconds + 0.1

;debug

;hint "three"

?(getdammage target > 0.5): goto "hit"

?(_seconds >= 4): goto "missed"

~0.1

goto "three"

#four

_seconds = _seconds + 0.1

;debug

;hint "four"

?(getdammage target > 0.5): goto "hit"

?(_seconds >= 7): goto "missed"

~0.1

goto "four"

#loop1

_seconds = _seconds + 0.1

?(getdammage target > 0.1): goto "hit"

?(_seconds >= 5): goto "missed"

~0.1

goto "loop1"

#hit

target setdammage 1

pistol = pistol + 1;; publicvariable = "pistol"

hint format ["Hits : %1 \n Missed : %2", pistol, missed]

~0.5

shooter addscore 1

ref addscore 1

~5

goto "loop"

#missed

target setdammage 1

missed = missed + 1;; publicvariable = "missed"

hint format ["Hits : %1 \n Missed : %2", pistol, missed]

~0.5

goto "loop"

#end

ref1 globalchat format ["The final results are: Hits : %1  Missed : %2", pistol, missed]

exit

would appreciate it if anyone could have a look and see where i screwed up

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  

×