Jump to content

Recommended Posts

Hi..

I need help with little problem.. i add new pet system and when i try compile server source it give me this error.. can someone help me???

->

main.cpp:483: error: 'temp_exp_line' was not declared in this scope

here my main.cpp

https://pastebin.com/rdzv7LCP

Link to comment
https://metin2.dev/topic/16454-new-pet-system-server-source-err/
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Before:

std::ifstream exppet_table_open("/usr/home/game/share/exppettable.txt");

Add:

std::string temp_exp_line;
#ifdef NEW_PET_SYSTEM
	std::string temp_exp_line;
	std::ifstream exppet_table_open("/usr/home/game/share/exppettable.txt");
	/*if (!exp_table_open.is_open())
	return 0;*/

	int exppet_table_counter = 0;
	int tmppet_exp = 0;
	while (!exppet_table_open.eof())
	{
		exppet_table_open >> temp_exp_line;
		str_to_number(exppet_table_common[exppet_table_counter], temp_exp_line.c_str());
		if (exppet_table_common[exppet_table_counter] < 2147483647) {
			sys_log(0, "Livelli Pet caricati da exppettable.txt: %d !", exppet_table_common[exppet_table_counter]);
			exppet_table_counter++;
		}
		else {
			fprintf(stderr, "[main] Impossibile caricare la tabella exp valore non valido\n");
			break;
		}
	}
#endif

Learn some basics of C++ - it doesn't hurt.

1 minute ago, vandragoon said:

now i have this:
main.cpp:497: error: redeclaration of 'std::string temp_exp_line'
main.cpp:474: error: 'std::string temp_exp_line' previously declared here
 

Better do it this way:

	// START_OF_Player_EXP_TABLE_LOADING
	string temp_exp_line;
	char szExpTable[256];
	snprintf(szExpTable, sizeof(szExpTable), "%s/exp.txt", LocaleService_GetBasePath().c_str());
	ifstream exp_table_open(szExpTable);
	if (!exp_table_open.is_open()) {
		fprintf(stderr, "Failed to Load ExpTable from %s/exp.txt\n", LocaleService_GetBasePath().c_str());
		sys_err("Failed to Load ExpTable from %s/exp.txt", LocaleService_GetBasePath().c_str());
		return 0;
	}
	int exp_table_counter = 0;
	while (!exp_table_open.eof())
	{
		exp_table_open >> temp_exp_line;
		str_to_number(exp_table_common[exp_table_counter], temp_exp_line.c_str());
		exp_table_counter++;
	}
	fprintf(stderr, "EXP erfolgreich geladen von: %s\n", LocaleService_GetBasePath().c_str());
	//sys_log(0, "EXP Table Loaded succsefully from %s", LocaleService_GetBasePath().c_str());
	// END_OF_Player_EXP_TABLE_LOADING
	
#ifdef NEW_PET_SYSTEM
 	temp_exp_line = ""; //clearing
	std::ifstream exppet_table_open("/usr/home/game/share/exppettable.txt");
	/*if (!exp_table_open.is_open())
	return 0;*/

	int exppet_table_counter = 0;
	int tmppet_exp = 0;
	while (!exppet_table_open.eof())
	{
		exppet_table_open >> temp_exp_line;
		str_to_number(exppet_table_common[exppet_table_counter], temp_exp_line.c_str());
		if (exppet_table_common[exppet_table_counter] < 2147483647) {
			sys_log(0, "Livelli Pet caricati da exppettable.txt: %d !", exppet_table_common[exppet_table_counter]);
			exppet_table_counter++;
		}
		else {
			fprintf(stderr, "[main] Impossibile caricare la tabella exp valore non valido\n");
			break;
		}
	}
#endif

You didn't notice you've added something with the same name of variable before. Next time remember to check.

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.