Active+ Member Doose 1603 Posted June 4, 2023 Active+ Member Share Posted June 4, 2023 This is the hidden content, please Sign In or Sign Up Alternative download links → This is the hidden content, please Sign In or Sign Up Hello Metin2 Dev. I'm here to present a Premium System. How does it work? Once use item, player gets Permanent Premium. Since this is V1, it only allows the player to expand the bravery cape. Premium shows it's activated on above left corner. Players can only activate Premium on certain maps (I chose City 1 of each kingdom, but you can choose other). In case of any problem, report here and i'll fix it. 148 4 1 1 1 21 4 93 Link to comment Share on other sites More sharing options...
BadRomani 14 Posted June 5, 2023 Share Posted June 5, 2023 (edited) Using FindAffect is always bad. You have to make a bool variable for this. Example: User case 31052: The variable in AddAffect in char_affect.cpp is returned true when it uses its object. For example: SetPremiumAffect(true) When the Effect is Deleted into the RemoveAffect in char_affect.cpp For example: SetPremiumAffect(false) When the player exits the game and re-enters the LoadAffect in char_affect.cpp For example: SetPremiumAffect(true) When you want to query the effect if (GetPremiumAffect()) { This effect is already used. return false } Example2 : if (GetPremiumAffect()) { //If there is an effect, run the codes. } Never Use FindAffect It Always Shits The Server. Edited June 5, 2023 by BadRomani Link to comment Share on other sites More sharing options...
Active+ Member Doose 1603 Posted June 5, 2023 Author Active+ Member Share Posted June 5, 2023 Thanks for the comment, i'll give it a check! Link to comment Share on other sites More sharing options...
BadRomani 14 Posted June 5, 2023 Share Posted June 5, 2023 3 minutes ago, Th1Doose said: Thanks for the comment, i'll give it a check! Example: char.h public: bool GetAttractRangerFindAffect() { return m_iAttractRangerFindAffect; } void SetAttractRangerFindAffect(bool affect) { m_iAttractRangerFindAffect = affect; } protected: bool m_iAttractRangerFindAffect; char_item.cpp case 72000: { if (GetAttractRangerFindAffect()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("DONT_USE")); return false; } AddAffect(AFFECT_CALL_ARCHER, POINT_NONE, 0, AFF_NONE, item->GetValue(0), 0, true); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Archers can now come to you.")); item->SetCount(item->GetCount() - 1); } break; char.cpp m_iAttractRangerFindAffect = false; affect.h AFFECT_CALL_ARCHER = 757, char_affect.cpp LoadAffect if (AFFECT_CALL_ARCHER == pElements->dwType) { SetAttractRangerFindAffect(true); } AddAffect if (dwType == AFFECT_CALL_ARCHER) { SetAttractRangerFindAffect(true); } RemoveAffect if (pkAff->dwType == AFFECT_CALL_ARCHER) { SetAttractRangerFindAffect(false); } How should the condition be? if (GetAttractRangerFindAffect()) AttractRanger(); 1 Link to comment Share on other sites More sharing options...
Active+ Member Doose 1603 Posted June 6, 2023 Author Active+ Member Share Posted June 6, 2023 8 hours ago, BadRomani said: Example: char.h public: bool GetAttractRangerFindAffect() { return m_iAttractRangerFindAffect; } void SetAttractRangerFindAffect(bool affect) { m_iAttractRangerFindAffect = affect; } protected: bool m_iAttractRangerFindAffect; char_item.cpp case 72000: { if (GetAttractRangerFindAffect()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("DONT_USE")); return false; } AddAffect(AFFECT_CALL_ARCHER, POINT_NONE, 0, AFF_NONE, item->GetValue(0), 0, true); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Archers can now come to you.")); item->SetCount(item->GetCount() - 1); } break; char.cpp m_iAttractRangerFindAffect = false; affect.h AFFECT_CALL_ARCHER = 757, char_affect.cpp LoadAffect if (AFFECT_CALL_ARCHER == pElements->dwType) { SetAttractRangerFindAffect(true); } AddAffect if (dwType == AFFECT_CALL_ARCHER) { SetAttractRangerFindAffect(true); } RemoveAffect if (pkAff->dwType == AFFECT_CALL_ARCHER) { SetAttractRangerFindAffect(false); } How should the condition be? if (GetAttractRangerFindAffect()) AttractRanger(); I studied your code and now i'm going to re-apply it to my system, thanks! Link to comment Share on other sites More sharing options...
Active+ Member Doose 1603 Posted June 8, 2023 Author Active+ Member Share Posted June 8, 2023 On 6/5/2023 at 5:18 PM, BadRomani said: Example: char.h public: bool GetAttractRangerFindAffect() { return m_iAttractRangerFindAffect; } void SetAttractRangerFindAffect(bool affect) { m_iAttractRangerFindAffect = affect; } protected: bool m_iAttractRangerFindAffect; char_item.cpp case 72000: { if (GetAttractRangerFindAffect()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("DONT_USE")); return false; } AddAffect(AFFECT_CALL_ARCHER, POINT_NONE, 0, AFF_NONE, item->GetValue(0), 0, true); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Archers can now come to you.")); item->SetCount(item->GetCount() - 1); } break; char.cpp m_iAttractRangerFindAffect = false; affect.h AFFECT_CALL_ARCHER = 757, char_affect.cpp LoadAffect if (AFFECT_CALL_ARCHER == pElements->dwType) { SetAttractRangerFindAffect(true); } AddAffect if (dwType == AFFECT_CALL_ARCHER) { SetAttractRangerFindAffect(true); } RemoveAffect if (pkAff->dwType == AFFECT_CALL_ARCHER) { SetAttractRangerFindAffect(false); } How should the condition be? if (GetAttractRangerFindAffect()) AttractRanger(); I tested it and i see a little problem with this. Everytime you restart the character you can reactivate the item. Which is caused by char.cpp. Quote m_iAttractRangerFindAffect = false; Link to comment Share on other sites More sharing options...
BadRomani 14 Posted June 12, 2023 Share Posted June 12, 2023 (edited) On 6/8/2023 at 2:28 PM, Th1Doose said: I tested it and i see a little problem with this. Everytime you restart the character you can reactivate the item. Which is caused by char.cpp. If you activate the effect and this effect is loaded in affect.sql (for example: Effect ID: 300), each time the character exits the game and re-enters, affect.sql will be triggered again in the LoadAffect function. So if there is 300 effect ID in affect.sql, this variable returns the correct value again. and if your value is correct in checkpoints For example: if(GetTrue()) work(); I have been using the system for a long time. It's never been a problem. Please check LoadAffect. Example: LoadAffect(....,....,...) SetEffect(true); RemoveAffect(....,....,...) SetEffect(false); condition/use if(GetEffect()) { You already have this effect. return false; } OR if(GetEffect()) { InitStartFunction();} Edited June 12, 2023 by BadRomani 1 Link to comment Share on other sites More sharing options...
Recommended Posts