PLAYER_PED p1 = (  100.0 , 100.0 , 3.0 ) 10  0
PLAYER_PED p2 = (  100.0 , 103.0 , 3.0 ) 7 180
//CHAR_DATA p2 = ( 100.0, 103.0 ) 7 180 DUMMY
CAR_DATA p1car
CAR_DATA p2car
p1car  =  CREATE_CAR ( 100.0, 101.0, 3.0 ) 2 90 STINGRAY END
p2car  =  CREATE_CAR ( 100.0, 102.0, 3.0 ) 2 90 STINGRAY END
//CAR_DATA p1car
//CAR_DATA p2car
COUNTER numberOfLaps = 5
COUNTER finalLap = 4 // should be one less than number of laps
COUNTER endlessloop = 1
COUNTER P1check1 = 0
COUNTER P1check2 = 0
COUNTER P2check1 = 0
COUNTER P2check2 = 0
COUNTER lapsP1 = 1
COUNTER lapsP2 = 1
COUNTER random01 = 0
COUNTER random02 = 0
ONSCREEN_COUNTER P1Lapcount
ONSCREEN_COUNTER P2Lapcount
//GENERATOR vehiclegun1  =  ( 125.0 , 87.0 , 3.0  ) 90 COLLECT_18 300 300 10
//GENERATOR rocket1  =  ( 103.0 , 99.0 , 3.0  ) 90 ROCKET 100 100
GENERATOR rocket2  =  ( 118.0 , 90.1 , 3.0  ) 0 ROCKET 30 30 
GENERATOR rocket3  =  ( 116.0 , 79.2 , 3.0  ) 0 ROCKET 30 30
GENERATOR rocket4  =  ( 102.0 , 82.5 , 3.0  ) 180 ROCKET 30 30

LEVELSTART

SET_CAR_ROCKETPROOF  ( p1car, ON )
SET_CAR_ROCKETPROOF  ( p2car, ON )
ADD_ONSCREEN_COUNTER  ( P1LapCount , lapsP1 )
ADD_ONSCREEN_COUNTER  ( P2LapCount , lapsP2 )
DISPLAY_MESSAGE ( 5504 ) // RACE ON
//SWITCH_GENERATOR   ( vehiclegun1 , ON ) 
//SWITCH_GENERATOR   ( rocket1 , ON ) 
SWITCH_GENERATOR   ( rocket2 , ON ) 
SWITCH_GENERATOR   ( rocket3 , ON ) 
SWITCH_GENERATOR   ( rocket4 , ON ) 

WHILE_EXEC ( endlessloop = 1 )

IF ( IS_CAR_WRECKED (p1car))
   p1car  =  CREATE_CAR ( 100.0, 101.0, 3.0 ) 2 90 STINGRAY END
ENDIF
   
IF ( IS_CAR_WRECKED (p2car))
   p2car  =  CREATE_CAR ( 100.0, 102.0, 3.0 ) 2 90 STINGRAY END
ENDIF
   

IF ( IS_CHARACTER_IN_ANY_CAR  (p1))
STORE_CAR_CHARACTER_IS_IN ( p1, p1car )
ENDIF

STORE_CAR_CHARACTER_IS_IN ( p2, p2car )

IF ( lapsP1 < lapsP2 )
   SET_CAR_ROCKETPROOF  ( p1car   ,  ON  )
   SET_CAR_ROCKETPROOF  ( p2car   ,  OFF )
ENDIF

IF ( lapsP2 < lapsP1 )
   SET_CAR_ROCKETPROOF  ( p1car   ,  OFF  )
   SET_CAR_ROCKETPROOF  ( p2car   ,  ON )
ENDIF
   
IF ( LOCATE_CHARACTER_ANY_MEANS ( p1, 102.0, 102.0, 3.0, 1.0 , 5.0 ))
   set P1check1 = 1
   IF ( P1check2 =1 )
      IF ( lapsP1 = 1 )
         DISPLAY_MESSAGE ( 5502 ) // SECOND LAP!
      ENDIF
      
      IF ( lapsP1 = finalLap )
         DISPLAY_MESSAGE ( 5503 ) // FINAL LAP!
      ENDIF
      
      IF ( lapsP1 = numberOfLaps )
         DISPLAY_MESSAGE ( 5501 ) // RACE OVER!
         ADD_SCORE ( p1 , 10000000 )
      ENDIF
      
      ++ lapsP1
      set P1check2 = 0
   endif
ENDIF

IF ( LOCATE_CHARACTER_ANY_MEANS ( p1, 83.0, 95.0, 3.0, 10.0 , 1.0 ))
   IF ( P1check1 = 1 )
      set P1check2 = 1
   endif
ENDIF

IF ( LOCATE_CHARACTER_ANY_MEANS ( p2, 102.0, 102.0, 3.0, 1.0 , 5.0 ))
   set P2check1 = 1
   IF ( P2check2 =1 )
      IF ( lapsP2 = 1 )
         DISPLAY_MESSAGE ( 5502 ) // SECOND LAP!
      ENDIF
      
      IF ( lapsP2 = finalLap )
         DISPLAY_MESSAGE ( 5503 ) // FINAL LAP!
      ENDIF
      
      IF ( lapsP2 = numberOfLaps )
         DISPLAY_MESSAGE ( 5501 ) // RACE OVER!
         ADD_SCORE ( p2 , 10000000 )
      ENDIF
      
      ++ lapsP2
      set P2check2 = 0
   endif
ENDIF

IF ( LOCATE_CHARACTER_ANY_MEANS ( p2, 83.0, 95.0, 3.0, 10.0 , 1.0 ))
   IF ( P2check1 = 1 )
      set P2check2 = 1
   endif
ENDIF

ENDWHILE

LEVELEND
