2015-06-08 127 views
-2

我正在嘗試爲此Minecraft聊天客戶端創建一個工具,您可以使用批處理文件登錄到服務器而不是啓動實際的Minecraft客戶端。我試圖製作一個工具,您可以將您的帳戶詳細信息輸入到批處理文件中所需的其他文本以及所需的服務器IP。如果我在標題中要求的不是我應該做的,我也很抱歉。我只是需要一些東西來給那裏的人一個粗略的想法,然後再看看我需要幫助的線索。創建變量C++的多個實例

這是我在塗料中製作的圖片,顯示了基本佈局。我不要求與GUI的幫助,我只是做它來幫助人們視覺和萬一我正在做絕對沒有任何意義:

enter image description here

的Minecraft聊天客戶端

http://www.minecraftforum.net/topic/1314800-winmaclinux-minecraft-console-client-175/

所有我需要幫助的是如何輸入可以說25個我的世界賬戶進入那個「Input Alts」框並讓程序識別有多少個交易所,然後以我在圖片中的格式輸出它們。我知道如何使用基本的cin或cout來做所有其他的事情。我想知道創建一個數組是否會是一個很好的解決方案,但我不知道如何讓程序將每個帳戶識別爲自己的獨立身份。如果只需要一個單獨的輸入,並且手動輸入您試圖輸出的alt的數量會更容易,那麼我不介意這樣做。

任何幫助將不勝感激。

我想出瞭如何一次完成一個帳戶,但它需要很長時間。

#include <iostream> 
#include <string> 

using namespace std; 
//Minecraft Account Details 
string account = " "; 
//Minecraft Server IP 
string serverIPAddress = ""; 

int main() 
{ 
cout << "Please Enter your email and password in the following format\n"; 

cout << "[email protected] password1\n"; 

// Lets say we input "[email protected] password1". 
getline(cin, account); 

// Lets just use "minecraftserver.com". 
cout << "Please Enter The server IP"; 
getline(cin, serverIPAddress); 

cout << "Minecraft.exe " << account << " " << serverIPAddress << endl; 
//Output: Minecraft.exe [email protected] password1 minecraftserver.com 

return 0; 
} 
+0

爲什麼這會被投票? – Jagannath

+0

@Jagannath這很不清楚。例如,故事板屏幕有一個GUI,而示例代碼是一個控制檯程序,並且從GUI中抓取線的行爲 - 這是問題的核心 - 與閱讀控制檯完全不同 –

+0

@Westfall是否應該成爲單獨的服務器IP /每個用戶/通行證,還是一個服務器IP? –

回答

0

我想你想讀取用戶/密碼的詳細信息,然後將它們存儲在容器中。 main()中的代碼可能如下所示:

// input stuff 
std::vector<std::string> accounts; 
std::cout << "Please Enter The username and passwords\n"; 

for (std::string temp; std::getline(std::cin, temp);) 
    accounts.push_back(temp); 

std::string server_ip; 
std::cout << "Please Enter The server IP\n"; 
std::getline(server_ip); 

// output stuff 
for (auto&& acc : accounts) 
    std::cout << acc << ' ' << server_ip << '\n';