Toranks said:
Points are assigned on the score screen based on the maximum combo, so I want to save the maximum value during each series of stages. After the score screen, it would be reset to zero. Thanks!
Hi
Toranks
Maybe this example can help. You will need to use 3 scripts:
1) Script to save max rush counter - used in the file named endlevel.c inside the "scripts" folder
2) Script to load max rush counter - used in the file named level.c inside the "scripts" folder
3) Script to reset max rush counter - used in the file named updated.c inside the "scripts" folder
First you will need to create these files if you don't have it, but if you already have the files with more scripts inside, you will need to call them as a individual functions and change the "void main" to any other name, like "void saveMaxRush" and "void loadMaxRush", and call them in a main function named "void main", like this:
Code:
void main()
{
saveMaxRush();
script2();
script3();
etc...
}
void saveMaxRush()
{//Save max rush counter when the level ends
void player1 = getplayerproperty(0, "entity"); //IDENTIFY PLAYER 1
void player2 = getplayerproperty(1, "entity"); //IDENTIFY PLAYER 2
void player3 = getplayerproperty(2, "entity"); //IDENTIFY PLAYER 3
void player4 = getplayerproperty(3, "entity"); //IDENTIFY PLAYER 4
if(player1 != NULL()){ //IS PLAYER 1 PLAYING THE GAME??
setglobalvar("maxRush1", getentityproperty(player1, "rush_tally")); //SAVE CURRENT PLAYER 1 MAX RUSH COUNT
}
if(player2 != NULL()){ //IS PLAYER 2 PLAYING THE GAME??
setglobalvar("maxRush2", getentityproperty(player2, "rush_tally")); //SAVE CURRENT PLAYER 2 MAX RUSH COUNT
}
if(player3 != NULL()){ //IS PLAYER 3 PLAYING THE GAME??
setglobalvar("maxRush3", getentityproperty(player3, "rush_tally")); //SAVE CURRENT PLAYER 3 MAX RUSH COUNT
}
if(player4 != NULL()){ //IS PLAYER 4 PLAYING THE GAME??
setglobalvar("maxRush4", getentityproperty(player4, "rush_tally")); //SAVE CURRENT PLAYER 4 MAX RUSH COUNT
}
}
If don't have scripts in these files, you can paste all the codes below with no changes.
Check if you have the file script.txt in the data folder, and the command "alwaysupdate 1" inside, otherwise the RESET script will not work.
SAVE MAX RUSH COUNTER, INSIDE THE ENDLEVEL.C FILE
Code:
void main()
{//Save max rush counter when the level ends
void player1 = getplayerproperty(0, "entity"); //IDENTIFY PLAYER 1
void player2 = getplayerproperty(1, "entity"); //IDENTIFY PLAYER 2
void player3 = getplayerproperty(2, "entity"); //IDENTIFY PLAYER 3
void player4 = getplayerproperty(3, "entity"); //IDENTIFY PLAYER 4
if(player1 != NULL()){ //IS PLAYER 1 PLAYING THE GAME??
setglobalvar("maxRush1", getentityproperty(player1, "rush_tally")); //SAVE CURRENT PLAYER 1 MAX RUSH COUNT
}
if(player2 != NULL()){ //IS PLAYER 2 PLAYING THE GAME??
setglobalvar("maxRush2", getentityproperty(player2, "rush_tally")); //SAVE CURRENT PLAYER 2 MAX RUSH COUNT
}
if(player3 != NULL()){ //IS PLAYER 3 PLAYING THE GAME??
setglobalvar("maxRush3", getentityproperty(player3, "rush_tally")); //SAVE CURRENT PLAYER 3 MAX RUSH COUNT
}
if(player4 != NULL()){ //IS PLAYER 4 PLAYING THE GAME??
setglobalvar("maxRush4", getentityproperty(player4, "rush_tally")); //SAVE CURRENT PLAYER 4 MAX RUSH COUNT
}
}
LOAD MAX RUSH COUNTER, INSIDE THE LEVEL.C FILE
Code:
void main()
{//Load saved max rush counter and apply when the level starts
void player1 = getplayerproperty(0, "entity"); //IDENTIFY PLAYER 1
void player2 = getplayerproperty(1, "entity"); //IDENTIFY PLAYER 2
void player3 = getplayerproperty(2, "entity"); //IDENTIFY PLAYER 3
void player4 = getplayerproperty(3, "entity"); //IDENTIFY PLAYER 4
if(player1 != NULL()){ //IS PLAYER 1 PLAYING THE GAME??
changeentityproperty(player1, "rush_tally", getglobalvar("maxRush1")); //CHANGE PLAYER 1 MAX RUSH COUNT WITH LOADED VALUE
}
if(player2 != NULL()){ //IS PLAYER 2 PLAYING THE GAME??
changeentityproperty(player2, "rush_tally", getglobalvar("maxRush2")); //CHANGE PLAYER 2 MAX RUSH COUNT WITH LOADED VALUE
}
if(player3 != NULL()){ //IS PLAYER 3 PLAYING THE GAME??
changeentityproperty(player3, "rush_tally", getglobalvar("maxRush3")); //CHANGE PLAYER 3 MAX RUSH COUNT WITH LOADED VALUE
}
if(player4 != NULL()){ //IS PLAYER 4 PLAYING THE GAME??
changeentityproperty(player4, "rush_tally", getglobalvar("maxRush4")); //CHANGE PLAYER 4 MAX RUSH COUNT WITH LOADED VALUE
}
}
RESET MAX RUSH COUNTER, INSIDE THE UPDATED.C FILE
Code:
void main()
{//Reset max rush counter in "Stage Complete" screen
if(openborvariant("in_showcomplete")){
void player1 = getplayerproperty(0, "entity"); //IDENTIFY PLAYER 1
void player2 = getplayerproperty(1, "entity"); //IDENTIFY PLAYER 2
void player3 = getplayerproperty(2, "entity"); //IDENTIFY PLAYER 3
void player4 = getplayerproperty(3, "entity"); //IDENTIFY PLAYER 4
if(player1 != NULL()){ //IS PLAYER 1 PLAYING THE GAME??
setglobalvar("maxRush1", 0); //RESET PLAYER 1 MAX RUSH COUNT SAVED VALUE TO ZERO
}
if(player2 != NULL()){ //IS PLAYER 2 PLAYING THE GAME??
setglobalvar("maxRush2", 0); //RESET PLAYER 2 MAX RUSH COUNT SAVED VALUE TO ZERO
}
if(player3 != NULL()){ //IS PLAYER 3 PLAYING THE GAME??
setglobalvar("maxRush3", 0); //RESET PLAYER 3 MAX RUSH COUNT SAVED VALUE TO ZERO
}
if(player4 != NULL()){ //IS PLAYER 4 PLAYING THE GAME??
setglobalvar("maxRush4", 0); //RESET PLAYER 4 MAX RUSH COUNT SAVED VALUE TO ZERO
}
}
}
I hope it helps. You can erase the lines that refers to players 3 or 4 if you are not using them, but make sure that all lines in all scripts are erased, otherwise the game will crash