metin2-factory 1010 Posted December 10, 2016 Share Posted December 10, 2016 Hey, Using this the gm's are able to view each player local map cords in the map(via the command /user in game). Open cmd_gm.cpp and replace the class user_func with the following: Spoiler class user_func { public: LPCHARACTER m_ch; static int count; static char str[128]; static int str_len; user_func() : m_ch(NULL) {} void initialize(LPCHARACTER ch) { m_ch = ch; str_len = 0; count = 0; str[0] = '\0'; } void operator () (LPDESC d) { if (!d->GetCharacter()) return; TMapSetting& map_setting = SECTREE_MANAGER::instance().GetMap(d->GetCharacter()->GetMapIndex())->m_setting; int len = snprintf(str + str_len, sizeof(str) - str_len, "%s (%ld,%ld)%-16s", d->GetCharacter()->GetName(),(d->GetCharacter()->GetX() - map_setting.iBaseX)/100,(d->GetCharacter()->GetY() - map_setting.iBaseY)/100,""); if (len < 0 || len >= (int) sizeof(str) - str_len) len = (sizeof(str) - str_len) - 1; str_len += len; ++count; if (!(count % 4)) { m_ch->ChatPacket(CHAT_TYPE_INFO, str); str[0] = '\0'; str_len = 0; } } }; That's all, compile and have fun! 5 Link to comment Share on other sites More sharing options...
Premium mogulul 17 Posted December 10, 2016 Premium Share Posted December 10, 2016 very very useful! Link to comment Share on other sites More sharing options...
Kirosachi 8 Posted December 10, 2016 Share Posted December 10, 2016 You could do much easier tutorial, such as, for people tot understand: @//Add on /common/service.h #define ENABLE_COORDINATES_ON_COMMAND_USER @//1.) Search: int len = snprintf(str + str_len, sizeof(str) - str_len, "%-16s ", d->GetCharacter()->GetName()); @//2.) Replace with: #ifdef ENABLE_COORDINATES_ON_COMMAND_USER TMapSetting& map_setting = SECTREE_MANAGER::instance().GetMap(d->GetCharacter()->GetMapIndex())->m_setting; int len = snprintf(str + str_len, sizeof(str) - str_len, "%s (%ld,%ld)%-16s", d->GetCharacter()->GetName(),(d->GetCharacter()->GetX() - map_setting.iBaseX)/100,(d->GetCharacter()->GetY() - map_setting.iBaseY)/100,""); #else int len = snprintf(str + str_len, sizeof(str) - str_len, "%-16s ", d->GetCharacter()->GetName()); #endif Good release, thanks. 1 Link to comment Share on other sites More sharing options...
Aerrow 41 Posted December 10, 2016 Share Posted December 10, 2016 Only I see the mistake? Bad: int len = snprintf(str + str_len, sizeof(str) - str_len, "%s (%ld,%ld)%-16s", d->GetCharacter()->GetName(),(d->GetCharacter()->GetX() - map_setting.iBaseX)/100,(d->GetCharacter()->GetY() - map_setting.iBaseY)/100,""); Correct: int len = snprintf(str + str_len, sizeof(str) - str_len, "%-16s (%ld,%ld)", d->GetCharacter()->GetName(),(d->GetCharacter()->GetX() - map_setting.iBaseX)/100,(d->GetCharacter()->GetY() - map_setting.iBaseY)/100); Btw thanks for the idea. Link to comment Share on other sites More sharing options...
metin2-factory 1010 Posted December 10, 2016 Author Share Posted December 10, 2016 2 hours ago, Aerrow said: Only I see the mistake? Bad: int len = snprintf(str + str_len, sizeof(str) - str_len, "%s (%ld,%ld)%-16s", d->GetCharacter()->GetName(),(d->GetCharacter()->GetX() - map_setting.iBaseX)/100,(d->GetCharacter()->GetY() - map_setting.iBaseY)/100,""); Correct: int len = snprintf(str + str_len, sizeof(str) - str_len, "%-16s (%ld,%ld)", d->GetCharacter()->GetName(),(d->GetCharacter()->GetX() - map_setting.iBaseX)/100,(d->GetCharacter()->GetY() - map_setting.iBaseY)/100); Btw thanks for the idea. This is not a mistake but on purpose. the code as you mentioned will create spaces after the char name so it'd look ingame like: Banderos (X,Y)TopSinner (X,Y) i'v fixed this issue by creating the necessary spaces after cords display per char. 1 Link to comment Share on other sites More sharing options...
Aerrow 41 Posted December 10, 2016 Share Posted December 10, 2016 Hmm.. I see. But for coding this is not so pretty. Maybe if the coord was first, then the characters name. I think about this: (%ld,%ld) %-16s Link to comment Share on other sites More sharing options...
Recommended Posts