Chookez 71 Posted November 11, 2019 Share Posted November 11, 2019 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 More sharing options...
Forum Moderator VegaS™ 10274 Posted November 11, 2019 Forum Moderator Share Posted November 11, 2019 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; } 3 Check my GitHub Profile Click to find all the threads started by me [TOOL] Text file loader + JSON Link to comment Share on other sites More sharing options...
Syriza 234 Posted November 11, 2019 Share Posted November 11, 2019 Thanks Vegas-Sama Link to comment Share on other sites More sharing options...
Premium WeedHex 635 Posted November 11, 2019 Premium Share Posted November 11, 2019 Nice idea. Link to comment Share on other sites More sharing options...
Chookez 71 Posted November 11, 2019 Author Share Posted November 11, 2019 I'll try it soon, thanks in advance. Link to comment Share on other sites More sharing options...
ManiacRobert 429 Posted November 11, 2019 Share Posted November 11, 2019 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(); 2 Link to comment Share on other sites More sharing options...
Heathcliff 183 Posted November 12, 2019 Share Posted November 12, 2019 #_# 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 More sharing options...
Forum Moderator VegaS™ 10274 Posted November 12, 2019 Forum Moderator Share Posted November 12, 2019 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 Sign In or Sign Up 9 1 8 Check my GitHub Profile Click to find all the threads started by me [TOOL] Text file loader + JSON Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now