COUNTER check_bmw = 1
COUNTER check_ferrari = 1
COUNTER check_brawn = 1
COUNTER check_redbull = 1
COUNTER check_mclaren = 1
COUNTER check_renault = 1

COUNTER out_bmw = 1
COUNTER out_ferrari = 1
COUNTER out_brawn = 1
COUNTER out_redbull = 1
COUNTER out_mclaren = 1
COUNTER out_renault = 1

COUNTER ql_bmw = 0
COUNTER ql_ferrari = 0
COUNTER ql_brawn = 0
COUNTER ql_redbull = 0
COUNTER ql_mclaren = 0
COUNTER ql_renault = 0

COUNTER ql_timer = 3629
COUNTER show_times = 0

TIMER_DATA time
TIMER_DATA time_good



loading_ql:
SET loop = 0

WHILE_EXEC (loading = 3)

IF (show_times = 0)
 DISPLAY_MESSAGE ( 2996 ) // "QUALIFICATION 
 DISPLAY_BRIEF ( 3007 ) // "Pitlane off
 DISPLAY_TIMER ( time , 0 ) 
 DISPLAY_TIMER ( time_good , 121 )
 SET show_times = 1
ENDIF

IF ((show_times > 0)
AND ( ql_timer > 0))
 -- ql_timer
ENDIF

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX      LICZNIK PALIWA     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

STORE_CAR_CURRENT_SPEED ( gt1_bmwsauber , speed_bmwsauber )
STORE_CAR_CURRENT_SPEED ( gt1_ferrari , speed_ferrari )
STORE_CAR_CURRENT_SPEED ( gt1_brawn , speed_brawn )
STORE_CAR_CURRENT_SPEED ( gt1_redbull , speed_redbull ) 
STORE_CAR_CURRENT_SPEED ( gt1_mclaren , speed_mclaren )
STORE_CAR_CURRENT_SPEED ( gt1_renault , speed_renault )


 IF (( speed_bmwsauber > 1000 )
 AND ( speed_bmwsauber < 3000 ))
  ++ czas_bmwsauber
 ENDIF
 IF (( speed_bmwsauber > 3000 )
 AND ( speed_bmwsauber < 7000 ))
  SET czas_bmwsauber = ( czas_bmwsauber + 2 )
 ENDIF
 IF ( speed_bmwsauber > 7000 )
  SET czas_bmwsauber = ( czas_bmwsauber + 4 )
 ENDIF


 IF (( speed_ferrari > 1000 )
 AND ( speed_ferrari < 3000 ))
  ++ czas_ferrari
 ENDIF
 IF (( speed_ferrari > 3000 )
 AND ( speed_ferrari < 7000 ))
  SET czas_ferrari = ( czas_ferrari + 2 )
 ENDIF
 IF ( speed_ferrari > 7000 )
  SET czas_ferrari = ( czas_ferrari + 4 )
 ENDIF

 IF (( speed_brawn > 1000 )
 AND ( speed_brawn < 3000 ))
  ++ czas_brawn
 ENDIF
 IF (( speed_brawn > 3000 )
 AND ( speed_brawn < 7000 ))
  SET czas_brawn = ( czas_brawn + 2 )
 ENDIF
 IF ( speed_brawn > 7000 )
  SET czas_brawn = ( czas_brawn + 4 )
 ENDIF

 IF (( speed_redbull > 1000 )
 AND ( speed_redbull < 3000 ))
  ++ czas_redbull
 ENDIF
 IF (( speed_redbull > 3000 )
 AND ( speed_redbull < 7000 ))
  SET czas_redbull = ( czas_redbull + 2 )
 ENDIF
 IF ( speed_redbull > 7000 )
  SET czas_redbull = ( czas_redbull + 4 )
 ENDIF

 IF (( speed_mclaren > 1000 )
 AND ( speed_mclaren < 3000 ))
  ++ czas_mclaren
 ENDIF
 IF (( speed_mclaren > 3000 )
 AND ( speed_mclaren < 7000 ))
  SET czas_mclaren = ( czas_mclaren + 2 )
 ENDIF
 IF ( speed_mclaren > 7000 )
  SET czas_mclaren = ( czas_mclaren + 4 )
 ENDIF

 IF (( speed_renault > 1000 )
 AND ( speed_renault < 3000 ))
  ++ czas_renault
 ENDIF
 IF (( speed_renault > 3000 )
 AND ( speed_renault < 7000 ))
  SET czas_renault = ( czas_renault + 2 )
 ENDIF
 IF ( speed_renault > 7000 )
  SET czas_renault = ( czas_renault + 4 )
 ENDIF

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX   KOORDYNATY DLA PLAYERA   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX            1               XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

// P1 BMW

IF (IS_CHARACTER_IN_CAR (p1 , gt1_bmwsauber))
 IF (( czas_bmwsauber > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta1 , 3 ))))
  SET plus_gta1 = 1
  SET czas_bmwsauber = 0
 ENDIF
ENDIF
 
// P1 FERRARI

IF (IS_CHARACTER_IN_CAR (p1 , gt1_ferrari))
 IF (( czas_ferrari > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta1 , 3 ))))
  SET plus_gta1 = 1
  SET czas_ferrari = 0
 ENDIF
ENDIF

// P1 BRAWN

IF (IS_CHARACTER_IN_CAR (p1 , gt1_brawn))
 IF (( czas_brawn > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta1 , 3 ))))
  SET plus_gta1 = 1
  SET czas_brawn = 0
 ENDIF
ENDIF

// P1 REBULL

IF (IS_CHARACTER_IN_CAR (p1 , gt1_redbull))
 IF (( czas_redbull > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta1 , 3 ))))
  SET plus_gta1 = 1
  SET czas_redbull = 0
 ENDIF
ENDIF

// P1 MCLAREN

IF (IS_CHARACTER_IN_CAR (p1 , gt1_mclaren))
 IF (( czas_mclaren > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta1 , 3 ))))
  SET plus_gta1 = 1
  SET czas_mclaren = 0
 ENDIF
ENDIF

// P1 RENAULT

IF (IS_CHARACTER_IN_CAR (p1 , gt1_renault))
 IF (( czas_renault > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta1 , 3 ))))
  SET plus_gta1 = 1
  SET czas_renault = 0
 ENDIF
ENDIF


// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX   KOORDYNATY DLA PLAYERA   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX            2               XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

// P2 BMW

IF (IS_CHARACTER_IN_CAR (p2 , gt1_bmwsauber))
 IF (( czas_bmwsauber > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta2 , 3 ))))
  SET plus_gta2 = 1
  SET czas_bmwsauber = 0
 ENDIF
ENDIF
 
// P2 FERRARI

IF (IS_CHARACTER_IN_CAR (p2 , gt1_ferrari))
 IF (( czas_ferrari > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta2 , 3 ))))
  SET plus_gta2 = 1
  SET czas_ferrari = 0
 ENDIF
ENDIF

// P2 BRAWN

IF (IS_CHARACTER_IN_CAR (p2 , gt1_brawn))
 IF (( czas_brawn > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta2 , 3 ))))
  SET plus_gta2 = 1
  SET czas_brawn = 0
 ENDIF
ENDIF

// P2 REBULL

IF (IS_CHARACTER_IN_CAR (p2 , gt1_redbull))
 IF (( czas_redbull > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta2 , 3 ))))
  SET plus_gta2 = 1
  SET czas_redbull = 0
 ENDIF
ENDIF

// P2 MCLAREN

IF (IS_CHARACTER_IN_CAR (p2 , gt1_mclaren))
 IF (( czas_mclaren > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta2 , 3 ))))
  SET plus_gta2 = 1
  SET czas_mclaren = 0
 ENDIF
ENDIF

// P2 RENAULT

IF (IS_CHARACTER_IN_CAR (p2 , gt1_renault))
 IF (( czas_renault > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta2 , 3 ))))
  SET plus_gta2 = 1
  SET czas_renault = 0
 ENDIF
ENDIF

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX   KOORDYNATY DLA PLAYERA   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX            3               XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

// P3 BMW

IF (IS_CHARACTER_IN_CAR (p3 , gt1_bmwsauber))
 IF (( czas_bmwsauber > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta3 , 3 ))))
  SET plus_gta3 = 1
  SET czas_bmwsauber = 0
 ENDIF
ENDIF
 
// P3 FERRARI

IF (IS_CHARACTER_IN_CAR (p3 , gt1_ferrari))
 IF (( czas_ferrari > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta3 , 3 ))))
  SET plus_gta3 = 1
  SET czas_ferrari = 0
 ENDIF
ENDIF

// P3 BRAWN

IF (IS_CHARACTER_IN_CAR (p3 , gt1_brawn))
 IF (( czas_brawn > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta3 , 3 ))))
  SET plus_gta3 = 1
  SET czas_brawn = 0
 ENDIF
ENDIF

// P3 REBULL

IF (IS_CHARACTER_IN_CAR (p3 , gt1_redbull))
 IF (( czas_redbull > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta3 , 3 ))))
  SET plus_gta3 = 1
  SET czas_redbull = 0
 ENDIF
ENDIF

// P3 MCLAREN

IF (IS_CHARACTER_IN_CAR (p3 , gt1_mclaren))
 IF (( czas_mclaren > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta3 , 3 ))))
  SET plus_gta3 = 1
  SET czas_mclaren = 0
 ENDIF
ENDIF

// P3 RENAULT

IF (IS_CHARACTER_IN_CAR (p3 , gt1_renault))
 IF (( czas_renault > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta3 , 3 ))))
  SET plus_gta3 = 1
  SET czas_renault = 0
 ENDIF
ENDIF

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX   KOORDYNATY DLA PLAYERA   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX            4               XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

// P4 BMW

IF (IS_CHARACTER_IN_CAR (p4 , gt1_bmwsauber))
 IF (( czas_bmwsauber > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta4 , 3 ))))
  SET plus_gta4 = 1
  SET czas_bmwsauber = 0
 ENDIF
ENDIF
 
// P4 FERRARI

IF (IS_CHARACTER_IN_CAR (p4 , gt1_ferrari))
 IF (( czas_ferrari > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta4 , 3 ))))
  SET plus_gta4 = 1
  SET czas_ferrari = 0
 ENDIF
ENDIF

// P4 BRAWN

IF (IS_CHARACTER_IN_CAR (p4 , gt1_brawn))
 IF (( czas_brawn > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta4 , 3 ))))
  SET plus_gta4 = 1
  SET czas_brawn = 0
 ENDIF
ENDIF

// P4 REBULL

IF (IS_CHARACTER_IN_CAR (p4 , gt1_redbull))
 IF (( czas_redbull > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta4 , 3 ))))
  SET plus_gta4 = 1
  SET czas_redbull = 0
 ENDIF
ENDIF

// P4 MCLAREN

IF (IS_CHARACTER_IN_CAR (p4 , gt1_mclaren))
 IF (( czas_mclaren > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta4 , 3 ))))
  SET plus_gta4 = 1
  SET czas_mclaren = 0
 ENDIF
ENDIF

// P4 RENAULT

IF (IS_CHARACTER_IN_CAR (p4 , gt1_renault))
 IF (( czas_renault > 3100)
 AND (NOT(CHECK_RESPECT_GREATER ( p1 , gta4 , 3 ))))
  SET plus_gta4 = 1
  SET czas_renault = 0
 ENDIF
ENDIF

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX     ANTI-CRASH FUEL     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

IF ((CHECK_CHARACTER_HEALTH ( p1 , 0))
AND (CHECK_SCORE_GREATER ( p1 , -1)))
  ++ scorep1
ENDIF 

IF ((CHECK_CHARACTER_HEALTH ( p2 , 0))
AND (CHECK_SCORE_GREATER ( p2 , -1)))
  ++ scorep2
ENDIF

IF ((CHECK_CHARACTER_HEALTH ( p3 , 0))
AND (CHECK_SCORE_GREATER ( p3 , -1)))
  ++ scorep3
ENDIF

IF ((CHECK_CHARACTER_HEALTH ( p4 , 0))
AND (CHECK_SCORE_GREATER ( p4 , -1)))
  ++ scorep4
ENDIF

// p1
IF  (((scorep2 < scorep1)
AND   (scorep3 < scorep1))
AND   (scorep4 < scorep1))
 SET group = 1
ENDIF

// p1 + p2
IF  (((scorep2 = scorep1)
AND   (scorep3 < scorep1))
AND   (scorep4 < scorep1))
 SET group = 2
ENDIF

// p1 + p3
IF  (((scorep2 < scorep1)
AND   (scorep3 = scorep1))
AND   (scorep4 < scorep1))
 SET group = 3
ENDIF

// p1 + p4
IF  (((scorep2 < scorep1)
AND   (scorep3 < scorep1))
AND   (scorep4 = scorep1))
 SET group = 4
ENDIF

// p1 + p2 + p3
IF  (((scorep2 = scorep1)
AND   (scorep3 = scorep1))
AND   (scorep4 < scorep1))
 SET group = 5
ENDIF

// p1 + p2 + p4
IF  (((scorep2 = scorep1)
AND   (scorep3 < scorep1))
AND   (scorep4 = scorep1))
 SET group = 6
ENDIF

// p1 + p3 + p4
IF  (((scorep2 < scorep1)
AND   (scorep3 = scorep1))
AND   (scorep4 = scorep1))
 SET group = 7
ENDIF

// p1 + p2 + p3 + p4
IF  (((scorep2 = scorep1)
AND   (scorep3 = scorep1))
AND   (scorep4 = scorep1))
 SET group = 8
ENDIF

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX           PLUS          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

// DLA P1
IF (plus_gta1 = 1 )

 IF ( group = 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p1 , 1 )
  SET plus_gta1 = 0
 ENDIF

 IF ( group = 2 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p2 , 1 )
  SET plus_gta1 = 0
 ENDIF

 IF ( group = 3 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p3 , 1 )
  SET plus_gta1 = 0
 ENDIF

 IF ( group = 4 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p4 , 1 )
  SET plus_gta1 = 0
 ENDIF

 IF ( group = 5 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p2 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p3 , 1 )
  SET plus_gta1 = 0
 ENDIF
 
 IF ( group = 6 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p2 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p4 , 1 )
  SET plus_gta1 = 0
 ENDIF
 
 IF ( group = 7 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p3 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p4 , 1 )
  SET plus_gta1 = 0
 ENDIF
 
 IF ( group = 8 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p2 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p3 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta1  , p4 , 1 )
  SET plus_gta1 = 0
 ENDIF
 
ENDIF

// DLA P2

IF (plus_gta2 = 1 )

 IF ( group = 2 )
  CHANGE_GANG_CHAR_RESPECT ( gta2  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta2  , p2 , 1 )
  SET plus_gta2 = 0
 ENDIF

 IF ( group = 5 )
  CHANGE_GANG_CHAR_RESPECT ( gta2  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta2  , p2 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta2  , p3 , 1 )
  SET plus_gta2 = 0
 ENDIF
 
 IF ( group = 6 )
  CHANGE_GANG_CHAR_RESPECT ( gta2  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta2  , p2 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta2  , p4 , 1 )
  SET plus_gta2 = 0
 ENDIF
 
 IF ( group = 8 )
  CHANGE_GANG_CHAR_RESPECT ( gta2  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta2  , p2 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta2  , p3 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta2  , p4 , 1 )
  SET plus_gta2 = 0
 ENDIF
 
ENDIF

// DLA P3

IF (plus_gta3 = 1 )

 IF ( group = 3 )
  CHANGE_GANG_CHAR_RESPECT ( gta3  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta3  , p3 , 1 )
  SET plus_gta3 = 0
 ENDIF
 
 IF ( group = 5 )
  CHANGE_GANG_CHAR_RESPECT ( gta3  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta3  , p2 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta3  , p3 , 1 )
  SET plus_gta3 = 0
 ENDIF 
 
 IF ( group = 7 )
  CHANGE_GANG_CHAR_RESPECT ( gta3  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta3  , p3 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta3  , p4 , 1 )
  SET plus_gta3 = 0
 ENDIF  
 
 IF ( group = 8 )
  CHANGE_GANG_CHAR_RESPECT ( gta3  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta3  , p2 , 1 )  
  CHANGE_GANG_CHAR_RESPECT ( gta3  , p3 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta3  , p4 , 1 )
  SET plus_gta3 = 0
 ENDIF  
  
ENDIF

// DLA P4

IF (plus_gta4 = 1 )

 IF ( group = 4 )
  CHANGE_GANG_CHAR_RESPECT ( gta4  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta4  , p4 , 1 )
  SET plus_gta4 = 0
 ENDIF
 
 IF ( group = 6 )
  CHANGE_GANG_CHAR_RESPECT ( gta4  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta4  , p2 , 1 )    
  CHANGE_GANG_CHAR_RESPECT ( gta4  , p4 , 1 )
  SET plus_gta4 = 0
 ENDIF
 
 IF ( group = 7 )
  CHANGE_GANG_CHAR_RESPECT ( gta4  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta4  , p3 , 1 )  
  CHANGE_GANG_CHAR_RESPECT ( gta4  , p4 , 1 )
  SET plus_gta4 = 0
 ENDIF
 
 IF ( group = 8 )
  CHANGE_GANG_CHAR_RESPECT ( gta4  , p1 , 1 )
  CHANGE_GANG_CHAR_RESPECT ( gta4  , p2 , 1 )   
  CHANGE_GANG_CHAR_RESPECT ( gta4  , p3 , 1 )  
  CHANGE_GANG_CHAR_RESPECT ( gta4  , p4 , 1 )
  SET plus_gta4 = 0
 ENDIF
 
ENDIF

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX   QL TIME & WAYPOINTS   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX            BMW          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

IF (IS_CAR_IN_BLOCK ( gt1_bmwsauber , 100.3 , 187.5 , 4.0 , 1.0 , 7.0 ))
 IF (check_bmw = 1)
  SET check_bmw = 2
 ENDIF
 IF ((check_bmw = 3)
 AND (ql_timer > 0))
  ++ pseudo_count
  SET check_bmw = 0
  SET out_bmw = 0
 ENDIF
ENDIF
 
IF (IS_CAR_IN_BLOCK ( gt1_bmwsauber , 127.5 , 118.5 , 4.0 , 1.0 , 7.0 ))
 IF (check_bmw = 2)
  SET check_bmw = 3
 ENDIF
ENDIF

IF ( check_bmw > 1 )
 ++ ql_bmw
ENDIF
 
IF (( ql_timer = 0)
AND ( check_bmw > 0))
 IF (zapadnia_bmwsauber = 2)
  SET out_bmw = 2
  Explode ( gt1_bmwsauber)
 ENDIF
 SET position_start_bmw = ( position_start_bmw + 4 )
 SET check_bmw = 0
 SET ql_bmw = 0
ENDIF
 
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX         FERRARI         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

IF (IS_CAR_IN_BLOCK ( gt1_ferrari , 100.3 , 187.5 , 4.0 , 1.0 , 7.0 ))
 IF (check_ferrari = 1)
  SET check_ferrari = 2
 ENDIF
 IF ((check_ferrari = 3)
 AND (ql_timer > 0))
  ++ pseudo_count
  SET check_ferrari = 0
  SET out_ferrari = 0
 ENDIF
ENDIF
 
IF (IS_CAR_IN_BLOCK ( gt1_ferrari , 127.5 , 118.5 , 4.0 , 1.0 , 7.0 ))
 IF (check_ferrari = 2)
  SET check_ferrari = 3
 ENDIF
ENDIF

IF ( check_ferrari > 1 )
 ++ ql_ferrari
ENDIF
 
IF (( ql_timer = 0)
AND ( check_ferrari > 0))
 IF (zapadnia_ferrari = 2)
  SET out_ferrari = 2
  Explode ( gt1_ferrari)
 ENDIF
 SET position_start_ferrari = ( position_start_ferrari + 4 )
 SET check_ferrari = 0
 SET ql_ferrari = 0
ENDIF

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX          BRAWN          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

IF (IS_CAR_IN_BLOCK ( gt1_brawn , 100.3 , 187.5 , 4.0 , 1.0 , 7.0 ))
 IF (check_brawn = 1)
  SET check_brawn = 2
 ENDIF
 IF ((check_brawn = 3)
 AND (ql_timer > 0))
  ++ pseudo_count
  SET check_brawn = 0
  SET out_brawn = 0
 ENDIF
ENDIF
 
IF (IS_CAR_IN_BLOCK ( gt1_brawn , 127.5 , 118.5 , 4.0 , 1.0 , 7.0 ))
 IF (check_brawn = 2)
  SET check_brawn = 3
 ENDIF
ENDIF

IF ( check_brawn > 1 )
 ++ ql_brawn
ENDIF
 
IF (( ql_timer = 0)
AND ( check_brawn > 0))
 IF (zapadnia_brawn = 2)
  SET out_brawn = 2
  Explode ( gt1_brawn)
 ENDIF
 SET position_start_brawn = ( position_start_brawn + 4 )
 SET check_brawn = 0
 SET ql_brawn = 0
ENDIF

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX         REDBULL         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

IF (IS_CAR_IN_BLOCK ( gt1_redbull , 100.3 , 187.5 , 4.0 , 1.0 , 7.0 ))
 IF (check_redbull = 1)
  SET check_redbull = 2
 ENDIF
 IF ((check_redbull = 3)
 AND (ql_timer > 0))
  ++ pseudo_count
  SET check_redbull = 0
  SET out_redbull = 0
 ENDIF
ENDIF
 
IF (IS_CAR_IN_BLOCK ( gt1_redbull , 127.5 , 118.5 , 4.0 , 1.0 , 7.0 ))
 IF (check_redbull = 2)
  SET check_redbull = 3
 ENDIF
ENDIF

IF ( check_redbull > 1 )
 ++ ql_redbull
ENDIF
 
IF (( ql_timer = 0)
AND ( check_redbull > 0))
 IF (zapadnia_redbull = 2)
  SET out_redbull = 2
  Explode ( gt1_redbull)
 ENDIF
 SET position_start_redbull = ( position_start_redbull + 4 )
 SET check_redbull = 0
 SET ql_redbull = 0
ENDIF

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX         MCLAREN         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

IF (IS_CAR_IN_BLOCK ( gt1_mclaren , 100.3 , 187.5 , 4.0 , 1.0 , 7.0 ))
 IF (check_mclaren = 1)
  SET check_mclaren = 2
 ENDIF
 IF ((check_mclaren = 3)
 AND (ql_timer > 0))
  ++ pseudo_count
  SET check_mclaren = 0
  SET out_mclaren = 0
 ENDIF
ENDIF
 
IF (IS_CAR_IN_BLOCK ( gt1_mclaren , 127.5 , 118.5 , 4.0 , 1.0 , 7.0 ))
 IF (check_mclaren = 2)
  SET check_mclaren = 3
 ENDIF
ENDIF

IF ( check_mclaren > 1 )
 ++ ql_mclaren
ENDIF
 
IF (( ql_timer = 0)
AND ( check_mclaren > 0))
 IF (zapadnia_mclaren = 2)
  SET out_mclaren = 2
  Explode ( gt1_mclaren)
 ENDIF
 SET position_start_mclaren = ( position_start_mclaren + 4 )
 SET check_mclaren = 0
 SET ql_mclaren = 0
ENDIF

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX         RENAULT         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

IF (IS_CAR_IN_BLOCK ( gt1_renault , 100.3 , 187.5 , 4.0 , 1.0 , 7.0 ))
 IF (check_renault = 1)
  SET check_renault = 2
 ENDIF
 IF ((check_renault = 3)
 AND (ql_timer > 0))
  ++ pseudo_count
  SET check_renault = 0
  SET out_renault = 0
 ENDIF
ENDIF
 
IF (IS_CAR_IN_BLOCK ( gt1_renault , 127.5 , 118.5 , 4.0 , 1.0 , 7.0 ))
 IF (check_renault = 2)
  SET check_renault = 3
 ENDIF
ENDIF

IF ( check_renault > 1 )
 ++ ql_renault
ENDIF
 
IF (( ql_timer = 0)
AND ( check_renault > 0))
 IF (zapadnia_renault = 2)
  SET out_renault = 2
  Explode ( gt1_renault)
 ENDIF
 SET position_start_renault = ( position_start_renault + 4 )
 SET check_renault = 0
 SET ql_renault = 0
ENDIF

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX   QUALIFICATION TIMES   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

IF ( ql_timer = 0 )
// BMW

 IF ( out_bmw = 2 )
  DISPLAY_BRIEF ( 3031 ) // "#BMW Sauber# not qualificated.
  SET out_bmw = 3
 ENDIF

//Ferrari

 IF ( out_ferrari = 2 )
  DISPLAY_BRIEF ( 3032 ) // "#Ferrari# not qualificated.
  SET out_ferrari = 3
 ENDIF
 
//Brawn

 IF ( out_brawn = 2 )
  DISPLAY_BRIEF ( 3033 ) // "#Ferrari# not qualificated.
  SET out_brawn = 3
 ENDIF
 
// Redbull
 
 IF ( out_redbull = 2 )
  DISPLAY_BRIEF ( 3034 ) // "#Red Bull# not qualificated.
  SET out_redbull = 3
 ENDIF
 
// Mclaren

 IF ( out_mclaren = 2 )
  DISPLAY_BRIEF ( 3035 ) // "#McLaren# not qualificated.
  SET out_mclaren = 3
 ENDIF 
 
// Renault
 
 IF ( out_renault = 2 )
  DISPLAY_BRIEF ( 3036 ) // "#Renault# not qualificated.
  SET out_renault = 3
 ENDIF
 

// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX      START POSITION     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

// Bmw

IF ( pyramid = 0) 
 IF (( ql_ferrari = 0)
 OR ( ql_bmw = 0))
  SET pyramid = 1
 ENDIF  
 IF ((ql_bmw > ql_ferrari)
 AND ( ql_ferrari > 0))
  ++ position_start_bmw
  SET pyramid = 1
 ENDIF  
 IF ((ql_bmw <= ql_ferrari)
 AND ( ql_bmw > 0))
  ++ position_start_ferrari
  SET pyramid = 1
 ENDIF  
ENDIF 

IF ( pyramid = 1) 
 IF (( ql_brawn = 0)
 OR ( ql_bmw = 0))
  SET pyramid = 2
 ENDIF  
 IF ((ql_bmw > ql_brawn)
 AND ( ql_brawn > 0))
  ++ position_start_bmw
  SET pyramid = 2
 ENDIF  
 IF ((ql_bmw <= ql_brawn)
 AND ( ql_bmw > 0))
  ++ position_start_brawn
  SET pyramid = 2
 ENDIF  
ENDIF   
  
IF ( pyramid = 2) 
 IF (( ql_redbull = 0)
 OR ( ql_bmw = 0))
  SET pyramid = 3
 ENDIF  
 IF ((ql_bmw > ql_redbull)
 AND ( ql_redbull > 0))
  ++ position_start_bmw
  SET pyramid = 3
 ENDIF  
 IF ((ql_bmw <= ql_redbull)
 AND ( ql_bmw > 0))
  ++ position_start_redbull
  SET pyramid = 3
 ENDIF  
ENDIF    
  
IF ( pyramid = 3) 
 IF (( ql_mclaren = 0)
 OR ( ql_bmw = 0))
  SET pyramid = 4
 ENDIF  
 IF ((ql_bmw > ql_mclaren)
 AND ( ql_mclaren > 0))
  ++ position_start_bmw
  SET pyramid = 4
 ENDIF  
 IF ((ql_bmw <= ql_mclaren)
 AND ( ql_bmw > 0))
  ++ position_start_mclaren
  SET pyramid = 4
 ENDIF  
ENDIF    
  
IF ( pyramid = 4) 
 IF (( ql_renault = 0)
 OR ( ql_bmw = 0))
  SET pyramid = 5
 ENDIF  
 IF ((ql_bmw > ql_renault)
 AND ( ql_renault > 0))
  ++ position_start_bmw
  SET pyramid = 5
 ENDIF  
 IF ((ql_bmw <= ql_renault)
 AND ( ql_bmw > 0))
  ++ position_start_renault
  SET pyramid = 5
 ENDIF  
ENDIF    

// ferrari
  
IF ( pyramid = 5) 
 IF (( ql_brawn = 0)
 OR ( ql_ferrari = 0))
  SET pyramid = 6
 ENDIF  
 IF ((ql_ferrari > ql_brawn)
 AND ( ql_brawn > 0))
  ++ position_start_ferrari
  SET pyramid = 6
 ENDIF  
 IF ((ql_ferrari <= ql_brawn)
 AND ( ql_ferrari > 0))
  ++ position_start_brawn
  SET pyramid = 6
 ENDIF  
ENDIF   
  
IF ( pyramid = 6) 
 IF (( ql_redbull = 0)
 OR ( ql_ferrari = 0))
  SET pyramid = 7
 ENDIF  
 IF ((ql_ferrari > ql_redbull)
 AND ( ql_redbull > 0))
  ++ position_start_ferrari
  SET pyramid = 7
 ENDIF  
 IF ((ql_ferrari <= ql_redbull)
 AND ( ql_ferrari > 0))
  ++ position_start_redbull
  SET pyramid = 7
 ENDIF  
ENDIF    
  
IF ( pyramid = 7) 
 IF (( ql_mclaren = 0)
 OR ( ql_ferrari = 0))
  SET pyramid = 8
 ENDIF  
 IF ((ql_ferrari > ql_mclaren)
 AND ( ql_mclaren > 0))
  ++ position_start_ferrari
  SET pyramid = 8
 ENDIF  
 IF ((ql_ferrari <= ql_mclaren)
 AND ( ql_ferrari > 0))
  ++ position_start_mclaren
  SET pyramid = 8
 ENDIF  
ENDIF    
  
IF ( pyramid = 8) 
 IF (( ql_renault = 0)
 OR ( ql_ferrari = 0))
  SET pyramid = 9
 ENDIF  
 IF ((ql_ferrari > ql_renault)
 AND ( ql_renault > 0))
  ++ position_start_ferrari
  SET pyramid = 9
 ENDIF  
 IF ((ql_ferrari <= ql_renault)
 AND ( ql_ferrari > 0))
  ++ position_start_renault
  SET pyramid = 9
 ENDIF  
ENDIF  

// brawn
   
IF ( pyramid = 9) 
 IF (( ql_redbull = 0)
 OR ( ql_brawn = 0))
  SET pyramid = 10
 ENDIF  
 IF ((ql_brawn > ql_redbull)
 AND ( ql_redbull > 0))
  ++ position_start_brawn
  SET pyramid = 10
 ENDIF  
 IF ((ql_brawn <= ql_redbull)
 AND ( ql_brawn > 0))
  ++ position_start_redbull
  SET pyramid = 10
 ENDIF  
ENDIF    
  
IF ( pyramid = 10) 
 IF (( ql_mclaren = 0)
 OR ( ql_brawn = 0))
  SET pyramid = 11
 ENDIF  
 IF ((ql_brawn > ql_mclaren)
 AND ( ql_mclaren > 0))
  ++ position_start_brawn
  SET pyramid = 11
 ENDIF  
 IF ((ql_brawn <= ql_mclaren)
 AND ( ql_brawn > 0))
  ++ position_start_mclaren
  SET pyramid = 11
 ENDIF  
ENDIF    
  
IF ( pyramid = 11) 
 IF (( ql_renault = 0)
 OR ( ql_brawn = 0))
  SET pyramid = 12
 ENDIF  
 IF ((ql_brawn > ql_renault)
 AND ( ql_renault > 0))
  ++ position_start_brawn
  SET pyramid = 12
 ENDIF  
 IF ((ql_brawn <= ql_renault)
 AND ( ql_brawn > 0))
  ++ position_start_renault
  SET pyramid = 12
 ENDIF  
ENDIF 

// Redbull
  
IF ( pyramid = 12) 
 IF (( ql_mclaren = 0)
 OR ( ql_redbull = 0))
  SET pyramid = 13
 ENDIF  
 IF ((ql_redbull > ql_mclaren)
 AND ( ql_mclaren > 0))
  ++ position_start_redbull
  SET pyramid = 13
 ENDIF  
 IF ((ql_redbull <= ql_mclaren)
 AND ( ql_redbull > 0))
  ++ position_start_mclaren
  SET pyramid = 13
 ENDIF  
ENDIF    
  
IF ( pyramid = 13) 
 IF (( ql_renault = 0)
 OR ( ql_redbull = 0))
  SET pyramid = 14
 ENDIF  
 IF ((ql_redbull > ql_renault)
 AND ( ql_renault > 0))
  ++ position_start_redbull
  SET pyramid = 14
 ENDIF  
 IF ((ql_redbull <= ql_renault)
 AND ( ql_redbull > 0))
  ++ position_start_renault
  SET pyramid = 14
 ENDIF  
ENDIF  

// Mclaren
  
IF ( pyramid = 14) 
 IF (( ql_renault = 0)
 OR ( ql_mclaren = 0))
  SET pyramid = 15
 ENDIF  
 IF ((ql_mclaren > ql_renault)
 AND ( ql_renault > 0))
  ++ position_start_mclaren
  SET pyramid = 15
 ENDIF  
 IF ((ql_mclaren <= ql_renault)
 AND ( ql_mclaren > 0))
  ++ position_start_renault
  SET pyramid = 15
 ENDIF  
ENDIF
//ql timer = 0 end
ENDIF  

IF ( group = 1 )
 IF (( pseudo_count = 1 )
 OR ( wreck = 1 ))
  SET ql_timer = 0
  CLEAR_TIMER ( time_good )  
 ENDIF
ENDIF

IF (group < 5)
 IF (( pseudo_count = 2 )
 OR ( wreck = 2 ))
  SET ql_timer = 0
  CLEAR_TIMER ( time_good )  
 ENDIF
ENDIF

IF (group < 8)
 IF (( pseudo_count = 3 )
 OR ( wreck = 3 )) 
  SET ql_timer = 0
  CLEAR_TIMER ( time_good )  
 ENDIF 
ENDIF

IF (group = 8)
 IF (( pseudo_count = 4 )
 OR ( wreck = 4 )) 
  SET ql_timer = 0
  CLEAR_TIMER ( time_good )  
 ENDIF 
ENDIF

IF (pyramid = 15)
 SET loading = 4
ENDIF
 
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX       WRECKED CARS      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

IF ((IS_CAR_WRECKED (gt1_bmwsauber))
AND (wreck_bmwsauber = 0))
 SET wreck_bmwsauber = 1
 ++ wreck
ENDIF

IF ((IS_CAR_WRECKED (gt1_ferrari))
AND (wreck_ferrari = 0))
 ++ wreck
 SET wreck_ferrari = 1
ENDIF

IF ((IS_CAR_WRECKED (gt1_brawn))
AND (wreck_brawn = 0))
 SET wreck_brawn = 1
 ++ wreck 
ENDIF

IF ((IS_CAR_WRECKED (gt1_redbull))
AND (wreck_redbull = 0))
 SET wreck_redbull = 1
 ++ wreck
ENDIF

IF ((IS_CAR_WRECKED (gt1_mclaren))
AND (wreck_mclaren = 0))
 SET wreck_mclaren = 1
 ++ wreck
ENDIF

IF ((IS_CAR_WRECKED (gt1_renault))
AND (wreck_renault = 0))
 SET wreck_renault = 1
 ++ wreck
ENDIF
 
 
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX       LOCKED CARS       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXX                         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

//bmw
IF (((NOT(HAS_CAR_GOT_DRIVER (gt1_bmwsauber)))
AND (NOT(bmw_char_alive = 2)))
AND (NOT(wreck_bmwsauber > 0)))
 CHANGE_CAR_LOCK ( gt1_bmwsauber , UNLOCKED )
ENDIF
IF (HAS_CAR_GOT_DRIVER (gt1_bmwsauber))
 CHANGE_CAR_LOCK ( gt1_bmwsauber , LOCKED )
ENDIF

//ferrari
IF (((NOT(HAS_CAR_GOT_DRIVER (gt1_ferrari)))
AND (NOT(ferrari_char_alive = 2)))
AND (NOT(wreck_ferrari > 0)))
 CHANGE_CAR_LOCK ( gt1_ferrari , UNLOCKED )
ENDIF
IF (HAS_CAR_GOT_DRIVER (gt1_ferrari))
 CHANGE_CAR_LOCK ( gt1_ferrari , LOCKED )
ENDIF

//brawn
IF (((NOT(HAS_CAR_GOT_DRIVER (gt1_brawn)))
AND (NOT(brawn_char_alive = 2)))
AND (NOT(wreck_brawn > 0)))
 CHANGE_CAR_LOCK ( gt1_brawn , UNLOCKED )
ENDIF
IF (HAS_CAR_GOT_DRIVER (gt1_brawn))
 CHANGE_CAR_LOCK ( gt1_brawn , LOCKED )
ENDIF

//redbull
IF (((NOT(HAS_CAR_GOT_DRIVER (gt1_redbull)))
AND (NOT(redbull_char_alive = 2)))
AND (NOT(wreck_redbull > 0)))
 CHANGE_CAR_LOCK ( gt1_redbull , UNLOCKED )
ENDIF
IF (HAS_CAR_GOT_DRIVER (gt1_redbull))
 CHANGE_CAR_LOCK ( gt1_redbull , LOCKED )
ENDIF

//mclaren
IF (((NOT(HAS_CAR_GOT_DRIVER (gt1_mclaren)))
AND (NOT(mclaren_char_alive = 2)))
AND (NOT(wreck_mclaren > 0)))
 CHANGE_CAR_LOCK ( gt1_mclaren , UNLOCKED )
ENDIF
IF (HAS_CAR_GOT_DRIVER (gt1_mclaren))
 CHANGE_CAR_LOCK ( gt1_mclaren , LOCKED )
ENDIF

//renault
IF (((NOT(HAS_CAR_GOT_DRIVER (gt1_renault)))
AND (NOT(renault_char_alive = 2)))
AND (NOT(wreck_renault > 0)))
 CHANGE_CAR_LOCK ( gt1_renault , UNLOCKED )
ENDIF
IF (HAS_CAR_GOT_DRIVER (gt1_renault))
 CHANGE_CAR_LOCK ( gt1_renault , LOCKED )
ENDIF
 
IF ((LOCATE_CHARACTER_BY_CAR( p1 , 103.0 , 198.5 , 4.0 , 5.0 , 5.0 ))
AND (NOT ( CHECK_SCORE_GREATER ( p1 , 4999 ))))
 ADD_SCORE_NO_MULT ( p1 , 5000 )
ENDIF
IF ((LOCATE_CHARACTER_BY_CAR( p2 , 103.0 , 198.5 , 4.0 , 5.0 , 5.0 ))
AND (NOT ( CHECK_SCORE_GREATER ( p2 , 4999 ))))
 ADD_SCORE_NO_MULT ( p2 , 5000 )
ENDIF
IF ((LOCATE_CHARACTER_BY_CAR( p3 , 103.0 , 198.5 , 4.0 , 5.0 , 5.0 ))
AND (NOT ( CHECK_SCORE_GREATER ( p3 , 4999 ))))
 ADD_SCORE_NO_MULT ( p3 , 5000 )
ENDIF
IF ((LOCATE_CHARACTER_BY_CAR( p4 , 103.0 , 198.5 , 4.0 , 5.0 , 5.0 ))
AND (NOT ( CHECK_SCORE_GREATER ( p4 , 4999 ))))
 ADD_SCORE_NO_MULT ( p4 , 5000 )
ENDIF

 
ENDWHILE


SET loop = 1
MISSION_HAS_FINISHED ( )
RETURN
 
 
MISSIONSTART

GOSUB loading_ql:

MISSIONEND 
