Jump to content

[C++] Announcement refine success


VegaS

Recommended Posts

Maybe i am noob, or my english not help me again.

Already this function made check if vnum >= 7, so means he will show u announce like when u upgrade something, only if new item is >=+7.

  • <Refine> Player [Jorila] upgraded item [Soul-Sword+7] with succes!
  • <Refine> Player [Jorila] upgraded item [Soul-Sword+8] with succes!
  • <Refine> Player [Jorila] upgraded item [Soul-Sword+9] with succes!

m4pDc.png

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1
Link to comment
Share on other sites

 

	static int arg[2] = {147, 149};
				
	if (arg[0] <= pkNewItem->GetVnum() && pkNewItem->GetVnum() <= arg[1])
	{
		if (pkNewItem->GetRefineLevel() >= 7)
		{			
			char szUpgradeAnnouncement[QUERY_MAX_LEN];
			snprintf(szUpgradeAnnouncement, sizeof(szUpgradeAnnouncement), "<Refine> Player %s upgraded item [%s] with succes!", GetName(), pkNewItem->GetName()); 
			BroadcastNotice(szUpgradeAnnouncement);
		}
	}
  •  
  • <Refine> Player [Jorila] upgraded item [Battle-Sword+7] with succes!
  • <Refine> Player [Jorila] upgraded item [Battle-Sword+8] with succes!
  • <Refine> Player [Jorila] upgraded item [Battle-Sword+9] with succes!

 

	static int arg[2] = {141, 149};
				
	if (arg[0] <= pkNewItem->GetVnum() && pkNewItem->GetVnum() <= arg[1])
	{		
		char szUpgradeAnnouncement[QUERY_MAX_LEN];
		snprintf(szUpgradeAnnouncement, sizeof(szUpgradeAnnouncement), "<Refine> Player %s upgraded item [%s] with succes!", GetName(), pkNewItem->GetName()); 
		BroadcastNotice(szUpgradeAnnouncement);
	}

 

  • <Refine> Player [Jorila] upgraded item [Battle-Sword+1] with succes!
  • <Refine> Player [Jorila] upgraded item [Battle-Sword+2] with succes!
  • <Refine> Player [Jorila] upgraded item [Battle-Sword+3] with succes!
  • <Refine> Player [Jorila] upgraded item [Battle-Sword+4] with succes!
  • <Refine> Player [Jorila] upgraded item [Battle-Sword+5] with succes!
  • <Refine> Player [Jorila] upgraded item [Battle-Sword+6] with succes!
  • <Refine> Player [Jorila] upgraded item [Battle-Sword+7] with succes!
  • <Refine> Player [Jorila] upgraded item [Battle-Sword+8] with succes!
  • <Refine> Player [Jorila] upgraded item [Battle-Sword+9] with succes!
  • Love 1
Link to comment
Share on other sites

4 minutes ago, VegaS said:

 


	static int arg[2] = {140, 149}; // MIN - MAX
				
	if (arg[0] <= item->GetVnum() && item->GetVnum() <= arg[1])
	{
		// Do something
	}

 

thanks :D i have 2 very little  question. oh my gosh, i ask to much, but i am a c++ noob s:

 

where i must add the 

static int arg[2] = {140, 149}; // MIN - MAX

and it is possible when i write like this: static int arg[2] = {140, 149, 10010, 10019, 20010, 20019}; // 3 different items

Link to comment
Share on other sites

 

int m_nTableMin[] = {141, 151, 161, 171, 181, 191};
int m_nTableMax[] = {149, 159, 169, 179, 189, 199};	
	
	for (int i = 0; i < _countof(m_nTableMin); i++)
	{
		for (int j = 0; j < _countof(m_nTableMax); j++)
		{		
			if (m_nTableMin[i] <= pkNewItem->GetVnum() && pkNewItem->GetVnum() <= m_nTableMax[j])
			{
				char szUpgradeAnnouncement[QUERY_MAX_LEN];
				snprintf(szUpgradeAnnouncement, sizeof(szUpgradeAnnouncement), "<Refine> Player [%s] upgraded item [%s] with succes!", GetName(), pkNewItem->GetName()); 
				BroadcastNotice(szUpgradeAnnouncement);
				// i have big dick omg ->  Do something -> BlowJob
			}
		}	
	}	

 

  • Love 1
Link to comment
Share on other sites

d0fc1cc03bcb6e0daf4f077c9e660dbd.png

@VegaS

hmm i add the refine-system...

 

code:

Spoiler

#ifndef ENABLE_ANNOUNCEMENT_REFINE_SUCCES
    #define ENABLE_ANNOUNCEMENT_REFINE_SUCCES
    #define ENABLE_ANNOUNCEMENT_REFINE_SUCCES_MIN_LEVEL 8

Spoiler

#ifdef ENABLE_ANNOUNCEMENT_REFINE_SUCCES
//mefunction745
    int m_nTableMin[] = {148, 158, 168, 178, 188, 198};
    int m_nTableMax[] = {149, 159, 169, 179, 189, 199};    
    
    for (int i = 0; i < _countof(m_nTableMin); i++)
    {
        for (int j = 0; j < _countof(m_nTableMax); j++)
        {        
            if (m_nTableMin <= pkNewItem->GetVnum() && pkNewItem->GetVnum() <= m_nTableMax[j])
            {
                char szUpgradeAnnouncement[QUERY_MAX_LEN];
                snprintf(szUpgradeAnnouncement, sizeof(szUpgradeAnnouncement), "<Refine> Player [%s] upgraded item [%s] with succes!", GetName(), pkNewItem->GetName()); 
                BroadcastNotice(szUpgradeAnnouncement);
                // lalala
            }
        }    
    }
#endif

 

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • Active Member
On 11. 9. 2016 at 10:03 PM, Endymion said:

13c02e7177184ddc8dc82906e5d3f9ff.png

Don't look at difference in item names, I used wrong item_proto in client. xd


http://paste.ubuntu.com/23166279/

Can you share your icons of stones? They are amazing!

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 1
  • Love 1

I'll be always helpful! 👊 

Link to comment
Share on other sites

2 hours ago, xRooT said:

ok nice Now I want to translate the text

  Reveal hidden contents

snprintf(szUpgradeAnnouncement, sizeof(szUpgradeAnnouncement), "<Refine> Player [%s] upgraded item %s with succes!", GetName(), buf);

And convert it to a file locale_string.txt hoooow :)

snprintf(szUpgradeAnnouncement, sizeof(szUpgradeAnnouncement), LC_TEXT("Refine info %s %s"), GetName(), buf);

"Refine info %s %s";
"<Refine> Player [%s] upgraded item %s with succes!";

Link to comment
Share on other sites

1 hour ago, Endymion said:

snprintf(szUpgradeAnnouncement, sizeof(szUpgradeAnnouncement), LC_TEXT("Refine info %s %s"), GetName(), buf);

"Refine info %s %s";
"<Refine> Player [%s] upgraded item %s with succes!";

ok nice but i can click name

a3223203ac.jpg

 

764026b61d.jpg

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

You code is bad vegas and you should feel bad too.

As i saw  here you always have a big mouth, but you codes is very bad.  I think is better and more simple like this.

int m_nTableMin[] = {141, 151, 161, 171, 181, 191};
int m_nTableMax[] = {149, 159, 169, 179, 189, 199};	

auto const &num = pkNewItem->GetVnum();

for (int i : m_nTableMin)
{
	for (int j : m_nTableMax)
	{
		if (i <= num && num <= j)
		{
			char szUpgradeAnnouncement[QUERY_MAX_LEN];
			
			snprintf(
				szUpgradeAnnouncement,
				sizeof(szUpgradeAnnouncement),
				"<Refine> "
				"Player [%s] "
				"upgraded item [%s] "
				"with succes! ",
				GetName(),
				pkNewItem->GetName()
				); 
			
			BroadcastNotice(szUpgradeAnnouncement);
		}
	}
}

 

:) I can review all of you codes if you want.

Please be friendly with me  Here i try to show you that you codes is bad  :D 

 

Regads

  • Love 1
Link to comment
Share on other sites

  • Premium
8 minutes ago, Asha said:

You code is bad vegas and you should feel bad too.

As i saw  here you always have a big mouth, but you codes is very bad.  I think is better and more simple like this.


int m_nTableMin[] = {141, 151, 161, 171, 181, 191};
int m_nTableMax[] = {149, 159, 169, 179, 189, 199};	

auto const &num = pkNewItem->GetVnum();

for (int i : m_nTableMin)
{
	for (int j : m_nTableMax)
	{
		if (i <= num && num <= j)
		{
			char szUpgradeAnnouncement[QUERY_MAX_LEN];
			
			snprintf(
				szUpgradeAnnouncement,
				sizeof(szUpgradeAnnouncement),
				"<Refine> "
				"Player [%s] "
				"upgraded item [%s] "
				"with succes! ",
				GetName(),
				pkNewItem->GetName()
				); 
			
			BroadcastNotice(szUpgradeAnnouncement);
		}
	}
}

 

:) I can review all of you codes if you want.

Please be friendly with me  Here i try to show you that you codes is bad  :D 

 

Regads

You're code seems really clean, btw you need at least c++11 to make it work as it uses "auto" for the pointer

Link to comment
Share on other sites

@VegaS

And master vegas  , here is some advices for you

Naming :

At least in my opinion, the pseudo-hungarian names like m_nTableMax and pkNewItem are much more problematic. Hungarian naming was originally invented for assembly language, back in the days of extremely primitive assemblers that did essentially no type enforcement. They were marginally useful with early C compilers that did minimal type enforcement as well.

In C++, Hungarian Notation is beyond useless, well into the range of being detrimental to your code's health.

Readibility :
You should worry less about length and more about readability. The code above does happen to be shorter, but the real improvement (IMO) is in readability and dependability. Range-based for loops (in particular) can do quite a lot to help eliminate off-by-one errors and such.
 
Best regards. :D  Be friendly with me please
 
Well, you can replace the auto with DWORD
DWORD &num = pkNewItem->GetVnum();
if you don't want to use modern programming things.
 
EDIT: why DWORD ? Because  GetVnum is DWORD
  • Love 1
Link to comment
Share on other sites

1 minute ago, galet said:

Yes I know about the pointer (btw I'm currently using c++11 soon c++14 or even 17 but there's no need for me right now) and I use a lot of "auto" in my code, either for replacing some boost features introduced in modern c++ versions or for better code using modern standarts

Good luck :D  With time you will improve.

  • Love 1
Link to comment
Share on other sites

  • 3 months later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 0

      Metin2 effect script files (MSE and MSA file) how can convert

    2. 10

      Multi Language System

    3. 0

      We are looking for a C++ and Python programmer

    4. 0

      [Quest Scheduler Request] Is there a way to make a quest run independet of player events? Lets say start quest automatically at server startup?

    5. 111

      Ulthar SF V2 (TMP4 Base)

    6. 0

      Quest function when 102.kill definition whereabouts help

    7. 5

      [M2 FILTER] Customized Client Filter

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • 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.