spawn ghosttime
@script
void main()
{
setlocalvar("maxRush1", getglobalvar("maxRush1"));
setlocalvar("maxRush2", getglobalvar("maxRush2"));
setlocalvar("maxRush3", getglobalvar("maxRush3"));
setlocalvar("next1up0", getglobalvar("next1up0"));
setlocalvar("next1up1", getglobalvar("next1up1"));
setlocalvar("next1up2", getglobalvar("next1up2"));
clearglobalvar();
setglobalvar("maxRush1", getlocalvar("maxRush1"));
setglobalvar("maxRush2", getlocalvar("maxRush2"));
setglobalvar("maxRush3", getlocalvar("maxRush3"));
setglobalvar("next1up0", getlocalvar("next1up0"));
setglobalvar("next1up1", getlocalvar("next1up1"));
setglobalvar("next1up2", getlocalvar("next1up2"));
}
@end_script
health 5
coords 30 240
at 0
setglobalvar("next1up0",12250000);
void main()
{
lifeScore(0);
}
void lifeScore(int player)
{//Custom LifeScore script for add lives, used to avoid native engine LifeScore issue
void self = getplayerproperty(player, "entity");
int score = getplayerproperty(player, "score");
int lifeScore = 250000; //DEFINED LIFESCORE TARGET TO ADD EACH LIVE
int add = 1; //HOW MUCH LIVES WILL BE ADDED WHEN SCORE REACHED THE TARGET
//USED TO CHECK IF THE PLAYER IS IN A NEW GAME
if(getglobalvar("next1up"+player) == NULL()){
setglobalvar("next1up"+player, lifeScore);
}
//USED TO ADD LIVES TO PLAYER
if(self != NULL()){ //CURRENT PLAYER REMAINS IN GAME??
while(score >= getglobalvar("next1up"+player)){ //CURRENT SCORE REACHED THE LAST DEFINED TARGET??
int lives = getplayerproperty(player, "lives"); //CHECK CURRENT LIVES EVERYTIME THIS TASK RUNS
playsample(openborconstant("SAMPLE_1UP"), 0, 120, 120, 100, 0); //PLAY SAMPLE
changeplayerproperty(player, "lives", lives+add); //ADD +1 LIVE
setglobalvar("next1up"+player, getglobalvar("next1up"+player)+lifeScore); //DEFINE AND SAVE THE NEXT TARGET
}
}
}
//USED TO CHECK IF THE PLAYER IS IN A NEW GAME
if(getglobalvar("next1up"+player) == NULL() || self == NULL()){
setglobalvar("next1up"+player, lifeScore);
}
Toranks said:If one of the players exits the game and then re-enters the game, starting again with a score of 0, the variable is not reset. So I suggest adding this to all scripts on scorex.c files
//USED TO CHECK IF THE PLAYER IS IN A NEW GAME
if(getglobalvar("next1up"+player) == NULL() || self == NULL()){
setglobalvar("next1up"+player, lifeScore);
}
Is possible that if in a game where the score is reset to 0 after losing one credit, the code may not work well. However, my game does not reset the score, so I will not make any further modifications. But I warn other people who can use the code, they should add another extra condition to detect this.