Hello! I'm new here, so correct me if this is the wrong location... but I'm trying to make a program for the Minecraft server I'm on, and it requires that if someone wants to make a map that is used on the server, that there's a .xml file that shows all the information, like items the person spawns with, etc. I wrote the majority of the program recently, so I can remember almost all of what happens when :P
Here's my program:
#include <iostream>
#include <string>
#include <stdlib.h>
#include <fstream>
using namespace std;
int screen()
{
cout << ".-------------------------------." << endl;
cout << "| |" << endl;
cout << "| Welcome to the XML Builder! |" << endl;
cout << "| Made by tratiikxt1t4n |" << endl;
cout << "| |" << endl;
cout << "*-------------------------------*\n" << endl;
}
int output()
{
int authornumber, filters, filter, shots;
int helmet, chestplate, leggings, boots, sword, bow, arrows, enchantnum;
string name, objective, authname1, authname2;
string authname3, authname4, contrib1, contrib2, contrib3;
string contrib4, team1, team2, color1, color2, playernum;
string name1, name2, enchant1, enchant2;
float version, velocity;
cout << "Generating .xml file now..." << endl;
fstream file;
file.open("Your_XML_File.xml",ios::trunc|ios::out);
file << "<?xml version=\"1.0\"?>" << endl;
file << "<map proto=\"1.0.0\">" << endl;
file << "<name>" << name << "</name>" << endl;
file << "<version>" << version << "</version>" << endl;
file.close();
}
int main()
{
int authornumber, filters, filter, shots, output();
int helmet, chestplate, leggings, boots, sword, bow, arrows, enchantnum;
string name, objective, authname1, authname2;
string authname3, authname4, contrib1, contrib2, contrib3;
string contrib4, team1, team2, color1, color2, playernum;
string name1, name2, enchant1, enchant2;
float version, velocity;
screen();
cout << "Please Type the name of the map: ";
cin >> name;
cout << "Version of the map: ";
cin >> version;
system("clear");
screen();
cout << "Objective of the map: ";
cin >> objective;
system("clear");
screen();
cout << "Number of Authors: ";
cin >> authornumber;
if ( authornumber == 1 )
{
cout << "\nAuthor name: ";
cin >> authname1;
cout << "Author contribution: ";
cin >> contrib1;
}
else if ( authornumber == 2 )
{
cout << "\nAuthor name: ";
cin >> authname1;
cout << "Author contribution: ";
cin >> contrib1;
cout << "\nAuthor name: ";
cin >> authname2;
cout << "Author contribution: ";
cin >> contrib2;
}
else if ( authornumber == 3 )
{
cout << "\nAuthor name: ";
cin >> authname1;
cout << "Author contribution: ";
cin >> contrib1;
cout << "\nAuthor name: ";
cin >> authname2;
cout << "Author contribution: ";
cin >> contrib2;
cout << "\nAuthor name: ";
cin >> authname3;
cout << "Author contribution: ";
cin >> contrib3;
}
else if ( authornumber >= 4 )
{
cout << "\nAuthor name: ";
cin >> authname1;
cout << "Author contribution: ";
cin >> contrib1;
cout << "\nAuthor name: ";
cin >> authname2;
cout << "Author contribution: ";
cin >> contrib3;
cout << "\nAuthor name: ";
cin >> authname3;
cout << "Author contribution: ";
cin >> contrib3;
cout << "\nAuthor name: ";
cin >> authname4;
cout << "Author contribution: ";
cin >> contrib4;
}
system("clear");
screen();
cout << "Team colors: ";
cin >> color1;
cout << "\n ";
cin >> color2;
system("clear");
screen();
cout << "Team names: ";
cin >> name1;
cout << "\n ";
cin >> name2;
system("clear");
screen();
cout << "Max number of players on each team: ";
cin >> playernum;
system("clear");
screen();
blocks:
cout << "1. Blocks can be placed/broken" << endl;
cout << "2. Blocks cannot be placed/broken" << endl;
cin >> filters;
if ( filters == 1 )
{
filter = 1;
}
else if ( filters == 2 )
{
filter = 0;
}
else
{
cout << "Incorrect option!" << endl;
goto blocks;
}
system("clear");
screen();
cout << "1. Shoot arrows" << endl;
cout << "2. Shoot enderpearls" << endl;
cin >> shots;
cout << "Velocity: ";
cin >> velocity;
system("clear");
screen();
cout << "What items do you want the player to use?\nEnter '0' to skip that item.\nPlease use their IDs." << endl;
cout << "Helmet: ";
cin >> helmet;
cout << "Chestplate: ";
cin >> chestplate;
cout << "Leggings: ";
cin >> leggings;
cout << "Boots: ";
cin >> boots;
cout << "Sword: ";
cin >> sword;
cout << "Number of Enchantments: ";
cin >> enchantnum;
if ( enchantnum == 1 )
{
cout << "Enchantment: ";
cin >> enchant1;
}
if ( enchantnum == 2 )
{
cout << "Enchantment: ";
cin >> enchant1;
cout << " ";
cin >> enchant2;
}
cout << "Bow [1. Yes; 2. No]: ";
cin >> bow;
if ( bow == 1 )
{
cout << "Arrows: ";
cin >> arrows;
}
output();
}
the only problem is that the output .xml file is incorrect. It's supposed to say <name>NAMEHERE</name>, but it only says <name></name>. Any help? Thanks!