//	             N=180
//W=270---------|---------E=90
//              S=0

PLAYER_PED p1 = (114.2, 170.5, 4.0) 10 90
PLAYER_PED p2 = (114.1, 170.2, 4.0) 7 0
PLAYER_PED p3 = (115.0, 170.2, 4.0) 11 0
PLAYER_PED p4 = (115.0, 170.7, 4.0) 13 180
PLAYER_PED p5 = (116.0, 170.2, 4.0) 12 180
PLAYER_PED p6 = (116.0, 170.7, 4.0) 8 180
//CHAR_DATA  c1 = (114.1, 170.2, 4.0) 10 90 dummy
//CHAR_DATA  c2 = (114.1, 170.2, 4.0)  7 0 dummy
//CHAR_DATA  c3 = (115.0, 171.5, 4.0) 11 0 dummy
//CHAR_DATA  c4 = (115.0, 172.0, 4.0) 13 0 dummy
//CHAR_DATA  c5 = (115.0, 172.5, 4.0) 12 0 dummy
//CHAR_DATA  c6 = (115.0, 173.0, 4.0) 8 0 dummy

COUNTER true = 1
COUNTER p1start  = 1
COUNTER p1check1 = 0
COUNTER p1check2 = 0
COUNTER p1check3 = 0
COUNTER p1check4 = 0
COUNTER p1check5 = 0
COUNTER p2start  = 1
COUNTER p2check1 = 0
COUNTER p2check2 = 0
COUNTER p2check3 = 0
COUNTER p2check4 = 0
COUNTER p2check5 = 0
COUNTER p3start  = 1
COUNTER p3check1 = 0
COUNTER p3check2 = 0
COUNTER p3check3 = 0
COUNTER p3check4 = 0
COUNTER p3check5 = 0
COUNTER p4start  = 1
COUNTER p4check1 = 0
COUNTER p4check2 = 0
COUNTER p4check3 = 0
COUNTER p4check4 = 0
COUNTER p4check5 = 0
COUNTER p5start  = 1
COUNTER p5check1 = 0
COUNTER p5check2 = 0
COUNTER p5check3 = 0
COUNTER p5check4 = 0
COUNTER p5check5 = 0
COUNTER p6start  = 1
COUNTER p6check1 = 0
COUNTER p6check2 = 0
COUNTER p6check3 = 0
COUNTER p6check4 = 0
COUNTER p6check5 = 0
COUNTER player_count = 1
CAR_DATA car1
CAR_DATA car2
CAR_DATA car3
CAR_DATA car4
CAR_DATA car5
CAR_DATA car6

LEVELSTART 

car1  =  CREATE_CAR (  112.5  , 166.0 ) 1 180 T2000GT END
car2  =  CREATE_CAR (  113.5  , 166.0 ) 2 180 T2000GT END
car3  =  CREATE_CAR (  114.5  , 166.0 ) 3 180 T2000GT END
car4  =  CREATE_CAR (  115.5  , 166.0 ) 4 180 T2000GT END
car5  =  CREATE_CAR (  116.5  , 166.0 ) 5 180 T2000GT END
car6  =  CREATE_CAR (  117.5  , 166.0 ) 6 180 T2000GT END

take_remote_control_of_car ( p1 , car1 )

if ( CHECK_CHARACTER_HEALTH ( p2, 1 ))
   ++player_count
   take_remote_control_of_car ( p2, car2 )
   if ( CHECK_CHARACTER_HEALTH ( p3, 1 ))
      ++player_count
      take_remote_control_of_car ( p3, car3)
      if ( CHECK_CHARACTER_HEALTH ( p4, 1 ))
         ++player_count
         take_remote_control_of_car ( p4, car4)
         if ( CHECK_CHARACTER_HEALTH ( p5, 1 ))
            ++player_count
            take_remote_control_of_car ( p5, car5)
            if ( CHECK_CHARACTER_HEALTH ( p6, 1 ))
               ++player_count
               take_remote_control_of_car ( p6, car6)
            endif 
         endif
      endif
   endif
endif
//   CHAR_DATA bot
//   bot = CREATE_CHAR_INSIDE_CAR  ( car2 ) 180 DUMMY END
//   bot = CREATE_CHAR_INSIDE_CAR  ( car3 ) 180 DUMMY END
//   bot = CREATE_CHAR_INSIDE_CAR  ( car4 ) 180 DUMMY END
//   bot = CREATE_CHAR_INSIDE_CAR  ( car5 ) 180 DUMMY END
//   bot = CREATE_CHAR_INSIDE_CAR  ( car6 ) 180 DUMMY END
//   SET_CHAR_OBJECTIVE ( bot, GOTO_AREA_IN_CAR, 112.5, 153.0, 2.0 )

while_exec ( true = 1 )

//
// player1
//
if ( is_car_wrecked ( car1 ))
   if ( p1start = 1 )   
      car1  =  CREATE_CAR (  112.5  , 166.0 ) 1 180 T2000GT END
   endif

   if ( p1check1 = 1 )
      car1  =  CREATE_CAR (  155.0  , 166.2 ) 1 90 T2000GT END
   endif

   if ( p1check2 = 1 )
      car1  =  CREATE_CAR (  186.3, 145.4 ) 1 180 T2000GT END
   endif
   
   if ( p1check3 = 1 )   
      car1  =  CREATE_CAR (  182.5  , 135.4 ) 1 0 T2000GT END
   endif
   
   if ( p1check4 = 1 )   
      car1  =  CREATE_CAR (  136.5  , 45.1 ) 1 0 T2000GT END
   endif

   if ( p1check5 = 1 )   
      car1  =  CREATE_CAR (  101.0  , 236.5 ) 1 90 T2000GT END
   endif

   take_remote_control_of_car ( p1, car1)
endif


if ( player_count > 1 )

//
// player2
//
if ( is_car_wrecked ( car2 ))
   if ( p2start = 1 )   
      car2  =  CREATE_CAR (  113.5  , 166.0 ) 2 180 T2000GT END
   endif

   if ( p2check1 = 1 )
      car2  =  CREATE_CAR (  155.0  , 167.2 ) 2 90 T2000GT END
   endif

   if ( p2check2 = 1 )
      car2  =  CREATE_CAR (  187.3, 145.4 ) 2 180 T2000GT END
   endif
   
   if ( p2check3 = 1 )   
      car2  =  CREATE_CAR (  181.5  , 135.4 ) 2 0 T2000GT END
   endif
   
   if ( p2check4 = 1 )   
      car2  =  CREATE_CAR (  136.5  , 45.1 ) 2 0 T2000GT END
   endif

   if ( p2check5 = 1 )   
      car2  =  CREATE_CAR (  101.0  , 237.5 ) 2 90 T2000GT END
   endif

   take_remote_control_of_car ( p2, car2)
endif

endif

if ( player_count > 2 )

//
// player3
//
if ( is_car_wrecked ( car3 ))
   if ( p3start = 1 )   
      car3  =  CREATE_CAR (  114.5  , 166.0 ) 3 180 T2000GT END
   endif

   if ( p3check1 = 1 )
      car3  =  CREATE_CAR (  155.0  , 167.2 ) 3 90 T2000GT END
   endif

   if ( p3check2 = 1 )
      car3  =  CREATE_CAR (  187.3, 145.4 ) 3 180 T2000GT END
   endif
   
   if ( p3check3 = 1 )   
      car3  =  CREATE_CAR (  181.5  , 135.4 ) 3 0 T2000GT END
   endif
   
   if ( p3check4 = 1 )   
      car3  =  CREATE_CAR (  136.5  , 45.1 ) 3 0 T2000GT END
   endif

   if ( p3check5 = 1 )   
      car3  =  CREATE_CAR (  101.0  , 237.5 ) 3 90 T2000GT END
   endif

   take_remote_control_of_car ( p3, car3)
endif
endif

if ( player_count > 3 )
//
// player4
//
if ( is_car_wrecked ( car4 ))
   if ( p4start = 1 )   
      car4  =  CREATE_CAR (  115.5  , 166.0 ) 4 180 T2000GT END
   endif

   if ( p4check1 = 4 )
      car4  =  CREATE_CAR (  155.0  , 167.2 ) 4 90 T2000GT END
   endif

   if ( p4check2 = 1 )
      car4  =  CREATE_CAR (  187.3, 145.4 ) 4 180 T2000GT END
   endif
   
   if ( p2check4 = 1 )   
      car4  =  CREATE_CAR (  181.5  , 135.4 ) 4 0 T2000GT END
   endif
   
   if ( p4check4 = 1 )   
      car4  =  CREATE_CAR (  136.5  , 45.1 ) 4 0 T2000GT END
   endif

   if ( p4check5 = 1 )   
      car4  =  CREATE_CAR (  101.0  , 237.5 ) 4 90 T2000GT END
   endif

   take_remote_control_of_car ( p4, car4)
endif
endif

//
// player1
//
IF ( IS_CAR_IN_BLOCK ( car1, 159.8, 168.5, 3.0, 5.0 , 5.0 ))
   set P1start  = 0
   set P1check1 = 1
   set P1check2 = 0
   set P1check3 = 0
   set P1check4 = 0
   set P1check5 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car1, 188.7, 145.4, 5.0, 5.0 , 5.0 ))
   set P1check1 = 0
   set P1check2 = 1
   set P1check3 = 0
   set P1check4 = 0
   set P1check5 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car1, 182.5, 135.4, 6.0, 5.0 , 5.0 ))
   set P1check1 = 0
   set P1check2 = 0
   set P1check3 = 1
   set P1check4 = 0
   set P1check5 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car1, 136.5, 45.1, 4.0, 5.0 , 5.0 ))
   set P1check1 = 0
   set P1check2 = 0
   set P1check3 = 0
   set P1check4 = 1
   set P1check5 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car1, 101.0, 236.5, 2.0, 5.0 , 5.0 ))
   set P1check1 = 0
   set P1check2 = 0
   set P1check3 = 0
   set P1check4 = 0
   set P1check5 = 1
   //display_brief ( 8800 )
endif

//
// player2
//
IF ( IS_CAR_IN_BLOCK ( car2, 159.8, 168.5, 3.0, 5.0 , 5.0 ))
   set P2start  = 0
   set P2check1 = 1
   set P2check2 = 0
   set P2check3 = 0
   set P2check4 = 0
   set P2check5 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car2, 188.7, 145.4, 5.0, 5.0 , 5.0 ))
   set P2check1 = 0
   set P2check2 = 1
   set P2check3 = 0
   set P2check4 = 0
   set P2check5 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car2, 182.5, 135.4, 6.0, 5.0 , 5.0 ))
   set P2check1 = 0
   set P2check2 = 0
   set P2check3 = 1
   set P2check4 = 0
   set P2check5 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car2, 136.5, 45.1, 4.0, 5.0 , 5.0 ))
   set P2check1 = 0
   set P2check2 = 0
   set P2check3 = 0
   set P2check4 = 1
   set P2check5 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car2, 101.0, 236.5, 2.0, 5.0 , 5.0 ))
   set P2check1 = 0
   set P2check2 = 0
   set P2check3 = 0
   set P2check4 = 0
   set P2check5 = 1
   //display_brief ( 8800 )
endif

//
// player3
//
IF ( IS_CAR_IN_BLOCK ( car3, 159.8, 168.5, 3.0, 5.0 , 5.0 ))
   set P3start  = 0
   set P3check1 = 1
   set P3check2 = 0
   set P3check3 = 0
   set P3check4 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car3, 188.7, 145.4, 5.0, 5.0 , 5.0 ))
   set P3check1 = 0
   set P3check2 = 1
   set P3check3 = 0
   set P3check4 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car3, 182.5, 135.4, 6.0, 5.0 , 5.0 ))
   set P3check1 = 0
   set P3check2 = 0
   set P3check3 = 1
   set P3check4 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car3, 136.5, 45.1, 4.0, 5.0 , 5.0 ))
   set P3check1 = 0
   set P3check2 = 0
   set P3check3 = 0
   set P3check4 = 1
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car3, 101.0, 236.5, 2.0, 5.0 , 5.0 ))
   set P3check1 = 0
   set P3check2 = 0
   set P3check3 = 0
   set P3check4 = 0
   set P3check5 = 1
   //display_brief ( 8800 )
endif

//
// player4
//
IF ( IS_CAR_IN_BLOCK ( car4, 159.8, 168.5, 3.0, 5.0 , 5.0 ))
   set P4start  = 0
   set P4check1 = 1
   set P4check2 = 0
   set P4check3 = 0
   set P4check4 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car4, 188.7, 145.4, 5.0, 5.0 , 5.0 ))
   set P4check1 = 0
   set P4check2 = 1
   set P4check3 = 0
   set P4check4 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car4, 182.5, 135.4, 6.0, 5.0 , 5.0 ))
   set P4check1 = 0
   set P4check2 = 0
   set P4check3 = 1
   set P4check4 = 0
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car4, 136.5, 45.1, 4.0, 5.0 , 5.0 ))
   set P4check1 = 0
   set P4check2 = 0
   set P4check3 = 0
   set P4check4 = 1
   //display_brief ( 8800 )
endif

IF ( IS_CAR_IN_BLOCK ( car4, 101.0, 236.5, 2.0, 5.0 , 5.0 ))
   set P4check1 = 0
   set P4check2 = 0
   set P4check3 = 0
   set P4check4 = 0
   set P4check5 = 1
   //display_brief ( 8800 )
endif

endwhile

LEVELEND
