Jump to content

General c++ question


Go to solution Solved by Kori,

Recommended Posts

Hello everyone, 

I make a panel for Metin2 in c++ but the start script don't work for me... 

#include <iostream>
#include <stdlib.h> // system
#include "header.h"
#include "ConfigFile.h"
using namespace std;

int rServer(int answer) {
	ConfigFile cf("config.txt");
	string lang, dIP;
	double dChannel, dCore;
	lang = (const string)cf.Value("Main_Setting", "LANG");
	dChannel = cf.Value("Main_Setting", "CHANNEL");
	dCore = cf.Value("Main_Setting", "CORES");
	dIP = (const string)cf.Value("Main_Setting", "IP");
	if (lang == "DE") {
		system("clear");
		cout << "\033[32mDer Server wird gestaret ...\033[0m\n";
		const auto db = "cd /usr/home/game2/database/ && ./database -I " + dIP + " &";
		const auto auth = "cd /usr/home/game2/auth/ && ./auth -I " + dIP + " &";
		system(db.c_str());
		system("sleep 2");
		system(auth.c_str());
		system("sleep 2");
		for (auto i = 1; i < dChannel + 1; i++) {
			for (auto c = 1; c < dCore + 1; c++) {
				const auto path = "cd /usr/home/game2/channel" + to_string(i) + "/core" + to_string(c);
				const auto path2 = "cd /usr/home/game2/channel99/core" + to_string(c);
				const auto cmd1 = path + "/ && ./channel" + to_string(i) + "_core" + to_string(c) + " -I " + dIP + " &";
				const auto cmd2 = path2 + "/ && ./channel99_core" + to_string(c) + " -I " + dIP + " &";
				system(cmd1.c_str());
				system("sleep 5");
				system(cmd2.c_str());
				system("sleep 5");
			}
		}
		cout << "\033[32mDer Server wurde gestartet.\033[0m\n";
		system("sleep 2");
		system("clear");
		system("./start");
	}
	if (lang == "ENG") {
		system("clear");
		cout << "\033[32mThe serveris starting ...\033[0m\n";
		const auto db = "cd /usr/home/game2/database/ && ./database -I " + dIP + " &";
		const auto auth = "cd /usr/home/game2/auth/ && ./auth -I " + dIP + " &";
		system(db.c_str());
		system("sleep 2");
		system(auth.c_str());
		system("sleep 2");
		for (auto i = 1; i < dChannel + 1; i++) {
			for (auto c = 1; c < dCore + 1; c++) {
				const auto path = "cd /usr/home/game2/channel" + to_string(i) + "/core" + to_string(c);
				const auto path2 = "cd /usr/home/game2/channel99/core" + to_string(c);
				const auto cmd1 = path + "/ && ./channel" + to_string(i) + "_core" + to_string(c) + " -I " + dIP + " &";
				const auto cmd2 = path2 + "/ && ./channel99_core" + to_string(c) + " -I " + dIP + " &";
				system(cmd1.c_str());
				system("sleep 5");
				system(cmd2.c_str());
				system("sleep 5");
			}
		}
		cout << "\033[32mThe Server is Online.\033[0m\n";
		system("sleep 2");
		system("clear");
		system("./start");
	}
	return answer;
}

The script work without errors 

When I make this 

//system(cmd1.c_str());
cout << cmd1.c_str();

Then I see the correct command to start the core 

 

But the server starting ( i see the output) and after start I look with PS and all offline 

 

 

 

  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.