Hello, I am working on a basic text based RPG. Today I was working on the Level generation (PlayerArea) text, but when I compiled to test, I got two errors.
|121|error: expected unqualified-id before 'return'|
|122|error: expected declaration before '}' token|
If it helps, I am using the Code::Blocks IDE with the GNU GCC compiler
#include <iostream>
#include <string>
#include <stdio.h>
#include <cstdlib>
usingnamespace std;
bool GameWindowState = 1;
bool GameStarted = 0;
void GameTitleFnc();
void NewGameFnc();
// int InGameStatMenu(PlayerStats, PlayerMoney, PlayerGender);
short UserInput;
int PlayerArea = 0;
int PlayerStats[3] = {20, 5, 5};
int PlayerMoney = 0;
string NameString;
string PlayerGender;
int main()
{
GameTitleFnc();
while (GameWindowState)
{
if (PlayerArea == 1)
{
int AreaOneOb1 = 15;
if (GameStarted == 0)
{
system("CLS");
cout << "You awaken to the sound of bubbling water flowing through a quiet creek to your right.\n""'Where am I???' you think to yourself. You stand up and take in your surroundings.\n""You are standing in a small clearing, next to a stream, there is a beaten path leading to the north\n""and another to the east. You notice a small bag sitting next to a nearby rotted log\n\n";
cout << "1. Go North\n2. Go East\n3. Inspect Bag\n";
cin >> UserInput;
GameStarted = 1;
if (UserInput == 0)
{
}
elseif (UserInput == 1)
{
PlayerArea = 2;
}
elseif (UserInput == 2)
{
PlayerArea = 4;
}
elseif (UserInput == 3)
{
if (AreaOneOb1 > 0);
{
cout << "You walk over and cautiously open the bag, you find 15 gold coins inside\n\n";
cout << "1. Take Coins\n2. Leave Bag Alone\n";
cin >> UserInput;
if (UserInput == 1)
{
AreaOneOb1 = AreaOneOb1 - 15;
}
}
}
elseif (AreaOneOb1 == 0)
{
cout << "The Bag is empty\n\n1. Return\n";
cin >> UserInput;
}
}
}
else
{
cout << "You are standing in a small clearing, next to a stream, there is a beaten path leading to the north\n""and another to the east. You notice a small bag sitting next to a nearby rotted log\n\n";
}
}
if (PlayerArea == 2)
{
}
elseif (PlayerArea == 3)
{
}
elseif (PlayerArea == 4)
{
}
elseif (PlayerArea == 5)
{
}
elseif (PlayerArea == 6)
{
}
elseif (PlayerArea == 7)
{
}
elseif (PlayerArea == 8)
{
}
elseif (PlayerArea == 9)
{
}
elseif (PlayerArea == 10)
{
}
elseif (PlayerArea == 11)
{
}
elseif (PlayerArea == 12)
{
}
}
return 0;
}
You have exactly one extra left-opening brace. Line 61. Also, this is the perfect program for using switches, so you don't run into the same issue again.