Okay i am going down. I cannot find the problem for this game.
I created save and load functions and checkpoint function who are bugged.
Here is the save:
void load_game(string n)
{
string filen;
filen = n + ".sav";
ifstream fin(filen);
if(!fin)
{
system("cls");
cout << "Error occured. " << endl;
cout << "Saved file could not be opened. " << endl;
system("PAUSE");
return;
}
else
{
fin >> name;
fin >> primary_weapon;
fin >> second_weapon;
fin >> pistol_acc[0];
fin >> pistol_acc[1];
fin >> pistol_acc[2];
fin >> pistol_acc[3];
fin >> pistol_acc[4];
fin >> smg_acc[0];
fin >> smg_acc[1];
fin >> smg_acc[2];
fin >> rifle_acc[0];
fin >> rifle_acc[1];
fin >> rifle_acc[2];
fin >> rifle_acc[3];
fin >> rifle_acc[4];
fin >> accuracy_level;
fin >> cash;
fin >> player_damage;
fin >> player_damage_smg;
fin >> player_health;
fin >> player_granate;
fin >> player_ammo;
fin >> player_ammo_smg;
fin >> player_got_rifle[0];
fin >> player_got_rifle[1];
fin >> player_got_rifle[2];
fin >> player_got_rifle[3];
fin >> player_got_rifle[4];
fin >> player_got_smg[0];
fin >> player_got_smg[1];
fin >> player_got_smg[2];
fin >> player_got_pistol[0];
fin >> player_got_pistol[1];
fin >> player_got_pistol[2];
fin >> player_got_pistol[3];
fin >> player_got_pistol[4];
fin >> player_position[0];
fin >> player_position[1];
fin >> player_position[2];
fin >> player_position[3];
fin >> player_position[4];
fin >> scenes[0];
fin >> scenes[1];
fin >> scenes[2];
fin >> scenes[3];
fin >> scenes[4];
fin >> player_in_position[0];
fin >> player_in_position[1];
fin >> player_in_position[2];
fin >> player_in_position[3];
fin >> player_in_position[4];
for(int i = 0; i < 10; i++)
fin >> mainb_missions[i];
fin.close();
}
}
And here is the checkpoint*holding gun on my face*:
int main(int argc, char *argv[])
{
bool load = false;
string name2;
srand(time(nullptr));
system("cls");
cout << "W ";
Sleep(500);
cout << "e ";
Sleep(500);
cout << "l ";
Sleep(500);
cout << "c ";
Sleep(1000);
cout << "o ";
Sleep(1000);
cout << "m ";
Sleep(1000);
cout << "e. " << endl;
cout << "Main menu: " << endl;
cout << "1> New game " << endl;
cout << "2> Load last saved checkpoint " << endl;
cout << "3> Exit " << endl;
x = make_selection(3);
x = make_selection(3);
while(x < 1 || x > 3)
{
cout << "Re-select : " << endl;
x = make_selection(3);
}
if(x == 3)
return 0;
if(x == 1 || x == 2)
while(true) //Game starts here
{
if(x == 1)
{
cout << "WARNING: IF you enter the same name for the profile " << endl;
cout << "everything will be erased. " << endl;
cout << "Enter your name for the profile: "; cin >> name;
save_game();
}
if(x == 2)
{
cout << "Enter your profile name: " << endl;
cin >> name2;
load = true;
load_game(name2);
}
if(scenes[0]) //Scene 1
{
scenes[0] = false;
scenes[1] = true;
cout << "Year is 2012, 21 of December. " << endl;
cout << "Russian special forces, spetsnaz, have been sent " << endl;
cout << "to a ufo crash location. " << endl;
cout << "Unidentified flying object was open. " << endl;
cout << "It was laying down in snow with no body. " << endl;
cout << "Spetsnaz leader called trucks to ship the ufo. " << endl;
cout << "He however had to leave the site to face the terrorists. " << endl;
cout << "He left 50 people to guard the crash site. " << endl;
cout << "After two days of waiting for trucks, trucks came. " << endl;
cout << "Military trucks with tank following them, all in line. " << endl;
cout << "There were 5 trucks and 10 tanks. " << endl;
cout << "One of the spetsnaz was slowly approaching ufo with his gas mask. " << endl;
cout << "He was wearing Kalashnikov RPG Light Machine Gun. " << endl;
cout << "Light just went off on every of truck. Everyone started panicking. " << endl;
cout << "Spetsnaz that was near ufo had his gun, well how to say, \"upgraded\". " << endl;
cout << "His eyes were however whole light blue. " << endl;
cout << "He pulled out his LMG and that is where this report stops. " << endl;
system("PAUSE");
} //Scene 1 end
if(scenes[1]) //Scene 2 start
{
system("cls");
scenes[1] = false;
scenes[2] = true;
cout << "TIME: One day ago " << endl;
cout << "LOCATION: Russian military helicopter " << endl;
cout << "Spetsnaz #1: Hey boss i heard some shit was down there. " << endl;
cout << "Spetsnaz #2: You are full of information number one! Don't scare me. " << endl;
cout << "Spetsnaz leader: You guys are going to be fine. " << endl;
cout << "Spetsnaz leader: Nothing to worry about...[PILOT STOPPED LEADER FROM TALKING]. " << endl;
cout << "Pilot: Sir we are here. " << endl;
cout << "Scene: " << endl;
cout << "Chopper is slowly landing on big H. " << endl;
system("PAUSE");
}//End of scene 2
while(player_position[0]) //While player is in main base
{
checkpoint(); //<< HERE IS THE CHECKPOINT! DO YOU SEE IT!?!?
//Down there i deleted the unecesary code
Problem is when i run the load function it shows me the scene1 and helicopter is landing scene then i press enter then it asks me again for name input and always like that >.<.
I did it! The problem was the variables. I declared them extern xD. My error
@cire, i did not include the important piece of code. Guys i am so sorry for this.
Thank you for your help.