Jump to content
  • 0

Extend costume time


Chookez

Question

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

2 answers to this question

Recommended Posts

  • 1
  • Distinguished Member
                                    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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

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.