{$CLEO .csa}

thread 'CARSPWN' 
wait 1000
5@ = 400 

:CARSPWN_2
wait 0 
40@ = 0
while 40@ < 1500 
    wait 100
    0DDD: 0@ = get_mutex_var 0
    if and
        0@ == 0
        Player.Defined($PLAYER_CHAR)
        Player.Controllable($PLAYER_CHAR)
        not Actor.Driving($PLAYER_ACTOR)
    jf @CARSPWN_2
    if and    
        80E1: not key_pressed 3 4 
        00E1: key_pressed 3 5
        00E1: key_pressed 3 6 
    jf @CARSPWN_2  
end
0DDC: set_mutex_var 0 to 1 

:CARSPWN_69
wait 0
03E5: text_box 'CSPWN_1' 
player.CanMove($PLAYER_CHAR) = false
0575: set_actor $PLAYER_ACTOR pinned_position 1
camera.SetBehindPlayer()
wait 500
jump @CARSPWN_95

:CARSPWN_83
wait 0 
5@ = 400 // integer values 

:CARSPWN_95
01E5: text_1number_highpriority 'NUMBER' 5@ flag 2000 time 1 
Model.Load(5@)
038B: load_requested_models 

:CARSPWN_120
wait 0 
if 
   Model.Available(5@)
else_jump @CARSPWN_120
07E4: get_model 5@ dimensions_cornerA_to 0@ 1@ 2@ dimensions_cornerB_to 10@ 11@ 12@
if 
    081F:  model 5@ plane
then    
    10@ *= 1.2
else
    10@ *= 2.2
    10@ += 1.0
end
04C4: create_coordinate 0@ 1@ 2@ from_actor $PLAYER_ACTOR offset 0.2 10@ 0.0 
3@ = Actor.Angle($PLAYER_ACTOR) 
if 
  3@ > 180.0 // floating-point values 
else_jump @CARSPWN_215 
3@ -= 180.0 // floating-point values 
jump @CARSPWN_225 

:CARSPWN_215
3@ += 180.0 // floating-point values 

:CARSPWN_225
4@ = Car.Create(5@, 0@, 1@, 2@)
3@ -= 90.0
Car.Angle(4@) = 3@
020A: set_car 4@ door_status_to 2 
Model.Destroy(5@)
wait 50

:CARSPWN_262
wait 0 
if 
    Actor.InCar($PLAYER_ACTOR, 4@)
then
    jump @END_TRUE
end     

if and
    00E1: key_pressed 3 5
    80E1: not key_pressed 3 4
    80E1: not key_pressed 3 6
jf @CARSPWN_315

:END_TRUE 
020A: set_car 4@ door_status_to 0
car.RemoveReferences(4@) 
03D5: remove_text 'NUMBER' 
03E5: text_box 'CSPWN_2'
player.CanMove($PLAYER_CHAR) = true
0575: set_actor $PLAYER_ACTOR pinned_position 0
0DDC: set_mutex_var 0 to 0
jump @CARSPWN_2 

:CARSPWN_315
wait 0
if or
    player.Wasted($PLAYER_CHAR)
    0741: actor $PLAYER_ACTOR busted
then
    jump @END_FALSE
end

if and
    80E1: not key_pressed 3 5 
    00E1: key_pressed 3 4
    00E1: key_pressed 3 6 
jf @CARSPWN_364  

:END_FALSE
car.Destroy(4@)
car.RemoveReferences(4@)
03D5: remove_text 'NUMBER' 
player.CanMove($PLAYER_CHAR) = true
0575: set_actor $PLAYER_ACTOR pinned_position 0
0DDC: set_mutex_var 0 to 0
03E5: text_box 'CSPWN_3'
wait 1000
jump @CARSPWN_2 

:CARSPWN_364
wait 0
if 

//05EE:   key_pressed 57 //VK_...
00E1: key_pressed 3 8
 
else_jump @CARSPWN_474 
Car.Destroy(4@)
03D5: remove_text 'NUMBER' 
if 
   not 5@ == 611 // integer values 
else_jump @CARSPWN_83 
5@ += 1 // integer values 
if or
   5@ == 441
   5@ == 464
   5@ == 465
   5@ == 501
   5@ == 564
   5@ == 577
   5@ == 592
   5@ == 594
then
   jump @CARSPWN_603
end    
if or
   5@ == 449 
   5@ == 537
   5@ == 538
   5@ == 569
   5@ == 570
   5@ == 590 
then
   jump @CARSPWN_603
end       
jump @CARSPWN_95 

:CARSPWN_474
wait 0 
if 

//05EE:   key_pressed 48 //VK_...
00E1: key_pressed 3 2
 
else_jump @CARSPWN_262 
Car.Destroy(4@)
03D5: remove_text 'NUMBER' 
if 
   not 5@ == 400 // integer values 
else_jump @CARSPWN_584 
5@ -= 1 // integer values 
if or
   5@ == 441
   5@ == 464
   5@ == 465
   5@ == 501
   5@ == 564
   5@ == 577
   5@ == 592   
   5@ == 594
then
   jump @CARSPWN_664
end    
if or
   5@ == 449 
   5@ == 537
   5@ == 538
   5@ == 569
   5@ == 570
   5@ == 590 
then
   jump @CARSPWN_664
end       
jump @CARSPWN_95 

:CARSPWN_584
wait 0 
5@ = 611 // integer values 
jump @CARSPWN_95 

:CARSPWN_603
wait 0 
if or
   5@ == 441
   5@ == 464
   5@ == 465
   5@ == 501
   5@ == 564
   5@ == 577
   5@ == 592   
   5@ == 594
then
   5@ += 1
   jump @CARSPWN_603
end    
if or
   5@ == 449 
   5@ == 537
   5@ == 538
   5@ == 569
   5@ == 570
   5@ == 590 
then
   5@ += 1
   jump @CARSPWN_603   
end 
jump @CARSPWN_95


:CARSPWN_664
wait 0 
if or
   5@ == 441
   5@ == 464
   5@ == 465
   5@ == 501
   5@ == 564
   5@ == 577
   5@ == 592   
   5@ == 594
then
   5@ -= 1
   jump @CARSPWN_664
end    
if or
   5@ == 449 
   5@ == 537
   5@ == 538
   5@ == 569
   5@ == 570
   5@ == 590 
then
   5@ -= 1
   jump @CARSPWN_664
end 
jump @CARSPWN_95
