Hello all,
My code isnt working. It is supposed to be a RPG World of Warcraft game lol.

1) When I have

if (inventory.size() == MAX_ITEMS)
    {
    inventory.push_back("Rusty Armor");
    }
    else
    {
        deleteItem();
    }

2) My deleteItem() function dosnt work, is their another way to do this?

Here is the code:

#include<iostream>
#include<fstream>
#include<string>
#include<vector>
using namespace std;

char var;
char string1[100];
vector<string> inventory;
int MAX_ITEMS = 0;
string name;
int armor;
int newGame();
int loadGame();
int deleteItem();

int main()
{    
    cout << "WELCOME TO KYLES RPG GAME!!!" << endl << endl;
    cout << "1.New Game" << endl;
    cout << "2.Load Game" << endl << endl << endl;
    cin >> var;
    if (var == '1')
    {
        newGame();    
    }
    else
    {
        loadGame();
    }
}

int newGame()
{
    inventory.push_back("Rusty Armor1");
    inventory.push_back("Rusty Armor2");
    inventory.push_back("Rusty Armor3");
    inventory.push_back("Rusty Armor4");
    inventory.push_back("Rusty Armor5");
    inventory.push_back("Rusty Armor6");
    system("CLS");
    cout << "Your father has been fighting for the Horde ever sence you were born.";
    cout << "On one day when you were twelve, a battle at a Horde's city, Terrin Mill ";
    cout << "was occuring. Your  father, Thrall is captured by Alliance and kept in who knows where. ";
    cout << "It is your time know. Your time to train and fight against the Alliance." << endl << endl << endl << endl << endl;
    system("PAUSE");
    system("CLS");
    cout << "You have arrived at Valley of Trails where you will train for a while." << endl << endl << endl << endl << endl;
    system("PAUSE");
    system("CLS");
    cout << "What is your name, Orc?" << endl;
    cin >> name;
    system("CLS");
    cout << name << ", eh? come with me I will suit you up." << endl << endl << endl << endl << endl;
    system("PAUSE");
    system("CLS");
    cout << "My name is Kyle, I have been working with the Horde for quite a while now. ";
    cout << "The first thing you will need is a bag...AH HA heres one, it has 6 slots, hope ";
    cout << "you   dont mind." << endl;
    MAX_ITEMS = 6;
    system("CLS");
    cout << "Now...to get you some armor. Heres some, pretty rusty but it'll do." << endl;
    if (inventory.size() == MAX_ITEMS)
    {
    inventory.push_back("Rusty Armor");
    }
    else
    {
        deleteItem();
    }    
    system("PAUSE");
}

int loadGame()
{
    system("PAUSE");
}

int deleteItem()
{
    cout << "Sorry, inventory full. Would u like to delete an item for this item? (y or n)" << endl;
        cin >> var;
        switch(var)
        {
                   case 'y':
                        for(int i = 0; i < inventory.size(); i++)
                        cout << inventory[i] << endl << endl;
                        cout << "Type an item that you want to delete." << endl;
                        cin >> string1;
                        if(string1 == inventory[0])
                        {
                                   inventory[1] = inventory [0];
                                   inventory[2] = inventory [1];
                                   inventory[3] = inventory [2];
                                   inventory[4] = inventory [3];
                                   inventory[5] = inventory [4];
                                   inventory[6] = inventory [5];
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8];
                        }
                        if(string1 == inventory[1])
                        {
                                   inventory[2] = inventory [1];
                                   inventory[3] = inventory [2];
                                   inventory[4] = inventory [3];
                                   inventory[5] = inventory [4];
                                   inventory[6] = inventory [5];
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8]; 
                        }
                        if(string1 == inventory[2])
                        {
                                   inventory[3] = inventory [2];
                                   inventory[4] = inventory [3];
                                   inventory[5] = inventory [4];
                                   inventory[6] = inventory [5];
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8]; 
                        }
                        if(string1 == inventory[3])
                        {
                                   inventory[4] = inventory [3];
                                   inventory[5] = inventory [4];
                                   inventory[6] = inventory [5];
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8]; 
                        }
                        if(string1 == inventory[4])
                        {
                                   inventory[5] = inventory [4];
                                   inventory[6] = inventory [5];
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8];
                        }
                        if(string1 == inventory[5])
                        {
                                   inventory[6] = inventory [5];
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8]; 
                        }
                        if(string1 == inventory[6])
                        {
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8]; 
                        }
                        if(string1 == inventory[7])
                        {
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8]; 
                        }
                        if(string1 == inventory[8])
                        {
                                   inventory[9] = inventory [8];
                        } 
                 case 'Y':
                        for(int i = 0; i < inventory.size(); i++)
                        cout << inventory[i] << endl << endl;
                        cout << "Type an item that you want to delete." << endl;
                        cin >> string1;
                        if(string1 == inventory[0])
                        {
                                   inventory[1] = inventory [0];
                                   inventory[2] = inventory [1];
                                   inventory[3] = inventory [2];
                                   inventory[4] = inventory [3];
                                   inventory[5] = inventory [4];
                                   inventory[6] = inventory [5];
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8];
                        }
                        if(string1 == inventory[1])
                        {
                                   inventory[2] = inventory [1];
                                   inventory[3] = inventory [2];
                                   inventory[4] = inventory [3];
                                   inventory[5] = inventory [4];
                                   inventory[6] = inventory [5];
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8]; 
                        }
                        if(string1 == inventory[2])
                        {
                                   inventory[3] = inventory [2];
                                   inventory[4] = inventory [3];
                                   inventory[5] = inventory [4];
                                   inventory[6] = inventory [5];
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8]; 
                        }
                        if(string1 == inventory[3])
                        {
                                   inventory[4] = inventory [3];
                                   inventory[5] = inventory [4];
                                   inventory[6] = inventory [5];
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8]; 
                        }
                        if(string1 == inventory[4])
                        {
                                   inventory[5] = inventory [4];
                                   inventory[6] = inventory [5];
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8];
                        }
                        if(string1 == inventory[5])
                        {
                                   inventory[6] = inventory [5];
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8]; 
                        }
                        if(string1 == inventory[6])
                        {
                                   inventory[7] = inventory [6];
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8]; 
                        }
                        if(string1 == inventory[7])
                        {
                                   inventory[8] = inventory [7];
                                   inventory[9] = inventory [8]; 
                        }
                        if(string1 == inventory[8])
                        {
                                   inventory[9] = inventory [8];
                        }     
                   case 'n':
                        system("PAUSE");   
                   case 'N':
                        system("PAUSE");                 
        }
}

1) When I have

if (inventory.size() == MAX_ITEMS)
    {
    inventory.push_back("Rusty Armor");
    }
    else
    {
        deleteItem();
    }

uhmmm... If you have a full inventory of items, you get a free Rusty Armor, but if you don't you lose an item?
I think you meant to use inventory.size() != MAX_ITEMS What are all those if() and array swaps in deleteItem()? It's unreadable, learn how to use loops.

Thank you for responding to my thread. What i was trying to do with the arrays was for example: I want to move everything down one to delete the item that they want to delete. Can you show me how to do this please? Thank you again.

OMG! Why don't you simply use vector's erase() method to delete an inventory item instead of all those assignment statements :scared:

Well first:
OMG!!! I dont know what you were trying to mean by OMG and :scared: but I did not KNOW about vector erase()!!!!!

2nd Their were 6 armors:

inventory.push_back("Rusty Armor1");
inventory.push_back("Rusty Armor2");
inventory.push_back("Rusty Armor3");
inventory.push_back("Rusty Armor4");
inventory.push_back("Rusty Armor5");
inventory.push_back("Rusty Armor6");

Well first:
OMG!!! I dont know what you were trying to mean by OMG and :scared:

If you are not native English then maybe you will not know what OMG means. Here is a link

I was exclaiming great surprise at the inefficiency of the code you posted.

I KNOW WHAT OMG MEANS. The last part is what i really want to hear not the first part. And thank you MosaicFuneral for the link.

Again thank you for the link but, I dont get what its saying. How would I vector.erase() a variable? Like:

cout << "What would u like to delete?" << endl;
cin >> anyvar;
// would I put:
vector.erase(anyvar);

Is that right?

This article has been dead for over six months. Start a new discussion instead.