Jump to content

Extend costume time


Go to solution Solved by TMP4,

Recommended Posts

Hi.

I need a little help in this code:

								case 84014:
								case 84015:
								case 84016:
								case 84017:
								case 84018:
								{
									LPITEM item2;

									if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
									{
										return false;
									}

									if (item2->IsExchanging())
									{
										return false;
									}

									if (item2->IsEquipped())
									{
										ChatPacket(CHAT_TYPE_INFO, LC_TEXT("CANT_USE_ON_EQUIPPED_ITEM"));
										return false;
									}

									if (item2->GetType() != ITEM_COSTUME)
									{
										ChatPacket(CHAT_TYPE_INFO, LC_TEXT("CAN_USE_ONLY_COSTUMES"));
										return false;
									}

									if (item2->GetVnum() >= 74001 && item2->GetVnum() <= 75612)
									{
										ChatPacket(CHAT_TYPE_INFO, LC_TEXT("CANT_USE_ON_SIMPLE_HAIR"));
										return false;
									}

									long day = item->GetValue(0) * 60 * 60 * 24;
									ITEM_MANAGER::instance().RemoveItem(item);
									ChatPacket(CHAT_TYPE_INFO, LC_TEXT("COSTUME_TIME_EXTENDED"));
									item2->SetSocket(0, item2->GetSocket(0) + day);
								}
								break;

How to specify that the time does not exceed 30 days on a costume?

-Thanks in advance.

Link to comment
Share on other sites

  • Contributor
  • Solution
                                    long calulcatedDay = item2->GetSocket(0) + (item->GetValue(0) * 60 * 60 * 24);
                                    ITEM_MANAGER::instance().RemoveItem(item);
                                    ChatPacket(CHAT_TYPE_INFO, LC_TEXT("COSTUME_TIME_EXTENDED"));
                                    if (calulcatedDay > 2592000)
                                        calulcatedDay = 2592000;
                                    item2->SetSocket(0, calulcatedDay);

Or with ternary operator:

Spoiler
									long calulcatedDay = item2->GetSocket(0) + (item->GetValue(0) * 60 * 60 * 24);
									ITEM_MANAGER::instance().RemoveItem(item);
									ChatPacket(CHAT_TYPE_INFO, LC_TEXT("COSTUME_TIME_EXTENDED"));
									long finalDay = (calulcatedDay > 2592000) ? 2592000 : calulcatedDay;
									item2->SetSocket(0, finalDay);

 

 

Edited by TMP4
  • 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



  • Similar Content

  • Activity

    1. 13

      Metin2 Closed Beta Content (2003-2004)

    2. 25

      [SRC] Metin2 on LINUX - The Old Metin2 Project

    3. 2

      United/Club/Midgard serverfiles?

    4. 13

      Metin2 Closed Beta Content (2003-2004)

    5. 13

      Metin2 Closed Beta Content (2003-2004)

  • 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.