Jump to content

General c++ question


Go to solution Solved by Kori,

Recommended Posts

  • Active+ Member

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
https://metin2.dev/topic/19607-general-c-question/
Share on other sites

  • Active+ Member
  • Solution

#fixxed by myself 

I have removed this line :

system("./start")

 

I have closed my panel via ctrl+c and then go the server down too ( why ever lel) 

 

Thanks 

  • Love 1
Link to comment
https://metin2.dev/topic/19607-general-c-question/#findComment-106675
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.