void main()
{//Script for giving extra lives for players based on score
    void P1 = getplayerproperty(0, "entity"); //Get player 1
    void P2 = getplayerproperty(1, "entity"); //Get player 2
    int P1Lives = getplayerproperty(0,"lives"); // Get player 1's lives
    int P2Lives = getplayerproperty(1,"lives"); // Get player 2's lives
    int P1Score = getplayerproperty(0,"score"); // Get player 1's score
    int P2Score = getplayerproperty(1,"score"); // Get player 2's score
    int P1S = getentityvar(P1, 8); //Get player 1's score status
    int P2S = getentityvar(P2, 8); //Get player 2's score status
    int SFX = loadsample("data/sounds/1up.wav");

    if (P1S == NULL()){
      P1S = 0;
    }

    if (P2S == NULL()){
      P2S = 0;
    }

//SFX Player
    if (P1Score >= 5000*(P1S+1)){
      playsample(SFX, 0, 120, 120, 100, 0);
    } else if (P2Score >= 5000*(P2S+1)){
      playsample(SFX, 0, 120, 120, 100, 0);
    }

//Player 1
    while (P1Score >= 5000*(P1S+1)){
      changeplayerproperty(0, "lives", P1Lives+1); // Give life
      P1Lives = P1Lives + 1;
      P1S = P1S + 1;
    }

    setentityvar(P1, 8, P1S);

//Player 2
    while (P2Score >= 5000*(P2S+1)){
      changeplayerproperty(1, "lives", P2Lives+1); // Give life
      P2Lives = P2Lives + 1;
      P2S = P2S + 1;
    }

    setentityvar(P2, 8, P2S);
}