; this is an example of working with arrays, using loops
; also it shows how loop commands Continue and Break work

DEFINE OBJECTS 0
DEFINE MISSIONS 0
DEFINE EXTERNAL_SCRIPTS -1 ; Use -1 to not write AAA script
DEFINE UNKNOWN_EMPTY_SEGMENT 0
DEFINE UNKNOWN_THREADS_MEMORY 0

; --------------------
; THE STRIPPED MAIN THREAD
; contains initial info
; --------------------
thread 'MAIN'
 var
  $PLAYER_CHAR : Player
 end
01F0: set_max_wanted_level_to 6 
set_wb_check_to 0 
00C0: set_current_time 8 0 
04E4: unknown_refresh_game_renderer_at 2488.5601 -1666.84 
Camera.SetAtPos(2488.5601, -1666.84, 13.38)
$PLAYER_CHAR = Player.Create(#NULL, 2488.5601, -1666.84, 13.38)
$PLAYER_ACTOR = Actor.EmulateFromPlayer($PLAYER_CHAR)
Camera.SetBehindPlayer
set_weather 0          
wait 0                                   
$PLAYER_CHAR.SetClothes("PLAYER_FACE", "HEAD", Head)
$PLAYER_CHAR.SetClothes("JEANSDENIM", "JEANS", Legs)
$PLAYER_CHAR.SetClothes("SNEAKERBINCBLK", "SNEAKER", Shoes)
$PLAYER_CHAR.SetClothes("VEST", "VEST", Torso)
$PLAYER_CHAR.Build
$PLAYER_CHAR.CanMove = True
fade 1 0                     
select_interior 0
016C: restart_if_wasted at 2027.77 -1420.52 15.99 angle 137.0 unknown 0 
016D: restart_if_busted at 1550.68 -1675.49 14.51 angle 90.0 unknown 0 
create_thread @example01 
end_thread 

;=====================================================================
; example #1
;=====================================================================
:example01
thread "example01" 

 var 
  $num:Integer = 10 ; actors number
  $actor: array 10 of Actor
  $marker: array 10 of marker  
 end                      

; load needed model
#WMOPJ.Load
:load                 
wait 0                                           
if                   
  #WMOPJ.Available                                                     
jf @load                  

; start point, position of the first actor 
Actor.StorePos($PLAYER_ACTOR, $x, $y, $z)
$y+=2.0
$x-=3.0

FOR $CurrenIndex = 0 TO $num delay 250
 $x+=1.0 ; offset
 $actor[$CurrenIndex].Create(CivMale, #WMOPJ, $x, $y, $z)     ; create actor
 $marker[$CurrenIndex].CreateAboveActor($actor[$CurrenIndex]) ; with marker above
end 

#WMOPJ.Destroy ; we don't need it anymore
wait 1000

FOR $CurrenIndex = 0 TO $num   ; destroy all actors and markers
  $marker[$CurrenIndex].Disable
  wait 250
  if
    $CurrenIndex <> 4
  jf continue ; skip the fifth actor, let him live ;)
  $actor[$CurrenIndex].DestroyWithFade
  
  if
   $CurrenIndex == 8
  jf Continue
  Break    ; if it is the ninth actor then break the loop 
  
end

end_thread