Give lifes to the player by Score

Crimsondeath

Active member
Hi again, I don't know where to put this topic (Ask and Answer or Scripting), but is there a script to give lifes to the player?

I know there is a "lifescore {int}" in the OpenBOR Manual, but when I give points to the player by script, for example: changeplayerproperty(0, "score", P1Score+5000);

The "lifescore" method didn't give any life to the player even if the required score was reach (only give life when the player kills an enemy or get an score item).

So I'm using this life score script on "score#.c" :

C#:
void lifeScore(int player)
{
    void self      = getplayerproperty(player, "entity");
    int score      = getplayerproperty(player, "score");
    int lifeScore = 200000;
    int add          = 1;
    
    if(getindexedvar("next1up"+player) == NULL()){
        setindexedvar("next1up"+player, lifeScore);
    }
    

    if(self != NULL()){ 
        while(score >= getindexedvar("next1up"+player)){ 
            int lives = getplayerproperty(player, "lives");
            playsample(openborconstant("SAMPLE_1UP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
            changeplayerproperty(player, "lives", lives+add);
            setindexedvar("next1up"+player, getindexedvar("next1up"+player)+lifeScore); 
        }
    }
}

But It gives a life to the player when the score is over 200,000 points (and the player get a life each time he kills an enemy when the stage starts) not each 200,000 points and has the same problem with the "changeplayerproperty(0, "score", P1Score+50000)" function on bonus stages :( .

Thanks in advance
 
But It gives a life to the player when the score is over 200,000 points (and the player get a life each time he kills an enemy when the stage starts) not each 200,000 points and has the same problem with the "changeplayerproperty(0, "score", P1Score+50000)" function on bonus stages :( .
Because your code only checks if the score is bigger than the "lifeScore".
When you have 230.000 as a score, for example, its bigger than the "lifeScore" (200.00) and it will add another life.

Try adding this:
int lifeScore = lifeScore++;
after this line
changeplayerproperty(player, "lives", lives+add);
I haven't tested it, I made it from the top of my head
 
Back
Top Bottom