Jump to content

C++ Costume time extend


Recommended Posts

                    case USE_EXTEND_TIME:
                        {
                            LPITEM item2;

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

                            if (item2->IsExchanging())
                            {
                                ChatPacket(CHAT_TYPE_INFO, "You can't use it while trading.");
                                return false;
                            }

                            if (item2->IsEquipped())
                            {
                                ChatPacket(CHAT_TYPE_INFO, "You cannot use it on equipped item.");
                                return false;
                            }

                            if (item2->GetType() != ITEM_COSTUME || (item2->GetSubType() != COSTUME_BODY && item2->GetSubType() != COSTUME_HAIR))
                            {
                                return false;
                            }

                            item2->SetSocket(0, item2->GetSocket(0) + item->GetValue(0));
                            item->SetCount(item->GetCount() - 1);
                            ChatPacket(CHAT_TYPE_INFO, "Item time has been extended!");
                        }
                        break;

Hi all.

I need a little help.

How do I fix the item's maximum 7 days?

If the item is 7 days old, then you cannot increase your time any further.

Thanks for help, and sorry for my bad english.

Link to comment
Share on other sites

  • Forum Moderator

I don't understand very well what you want, but you can try something like this.

static const DWORD COSTUME_EXTEND_TIME_LIMIT = 7 * 24 * 60 * 60;
const DWORD remain_sec = item2->GetSocket(ITEM_SOCKET_REMAIN_SEC);

if (remain_sec >= COSTUME_EXTEND_TIME_LIMIT)
{
	ChatPacket(CHAT_TYPE_INFO, "COSTUME_EXTEND_TIME_LIMIT");
	return false;
}
  • Love 3
Link to comment
Share on other sites

Acum 3 ore, VegaS™ a spus:

I don't understand very well what you want, but you can try something like this.


static const DWORD COSTUME_EXTEND_TIME_LIMIT = 7 * 24 * 60 * 60;
const DWORD remain_sec = item2->GetSocket(ITEM_SOCKET_REMAIN_SEC);

if (remain_sec >= COSTUME_EXTEND_TIME_LIMIT)
{
	ChatPacket(CHAT_TYPE_INFO, "COSTUME_EXTEND_TIME_LIMIT");
	return false;
}

Depend of your costume type, if is REAL_TIME and REAL_TIME_FIRST_USE you need to use get_global_time() for time verification, will be something like this

 

static const DWORD COSTUME_EXTEND_TIME_LIMIT = (7 * 24 * 60 * 60) - get_global_time();

 

  • Love 2
Link to comment
Share on other sites

#_#

I made it like this some months ago:

case USE_EXTEND_TIME:
{
	LPITEM item2;

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

	if (item2->IsExchanging() || item2->IsEquipped())
		return false;

	if (item2->GetType() != ITEM_COSTUME || (item2->GetSubType() != COSTUME_BODY && item2->GetSubType() != COSTUME_HAIR && item2->GetSubType() != COSTUME_MOUNT && item2->GetSubType() != COSTUME_WEAPON))
		return false;
	
	int extendTime = (item2->GetSocket(0) + item->GetValue(0)) - get_global_time();
	if (extendTime >= item2->GetDuration())
	{
		ChatPacket(CHAT_TYPE_INFO, LC_TEXT("COSTUME_LIMIT_REACHED_MAX"));
		return false;
	}

	item2->SetSocket(0, item2->GetSocket(0) + item->GetValue(0));
	item->SetCount(item->GetCount() - 1);
	ChatPacket(CHAT_TYPE_INFO, LC_TEXT("COSTUME_TIME_LIMIT_EXTENDED"));
}
break;

 

Link to comment
Share on other sites

  • Forum Moderator

Just now arrived from work, sorry for late answer.

On 11/11/2019 at 10:52 PM, ManiacRobert said:

Depend of your costume type, if is REAL_TIME and REAL_TIME_FIRST_USE you need to use get_global_time() for time verification, will be something like this


(7 * 24 * 60 * 60) - get_global_time();

If he do what you said, 604800 - current_timestamp =  > -1kkk.

The correct way and single way to do it properly, is the the next one:

This is the hidden content, please

  • Metin2 Dev 9
  • Scream 1
  • Love 6
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



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