rcar $car = get local car

rcarmodel $asr = get generic model 19 of $car	//ASR light
set $asr scriptcontrolled 1

int $asrnow=1
int $asrlast=1
int $asrdown=0

func void CheckASR()
{
  if is key 90 pressed			// [Z] key
  {
    if $asrdown == 0			// First press
    {
      $asrdown = 1			// Mark as held down
      $asrnow = 1 - $asrnow		// Toggle ASR
    }
  }
  else
  {
    $asrdown = 0			// Key released
  }

  if $asrlast != $asrnow
  {
    $asrlast = $asrnow
    set $car tc $asrnow
  }
  
  int $asractive = get $car tc active
  int $test = (1 - $asrnow) + $asractive

  if $test > 0
  {
    set $asr position float[3]{0.0,0.0,0.0}
  }
  else
  {
    set $asr position float[3]{0.0,0.0,0.1}
  }
}

func void StopEngine()
{
  if is key 88 pressed			// [X] key
  {
    send "stop engine" to console
  }
}

while 1
{
  CheckASR()
  StopEngine()

  interrupt
}