Jump to content

Players Local Map Cords Dddition


metin2-factory

Recommended Posts

Hey,

Using this the gm's are able to view each player local map cords in the map(via the command /user in game).

.png

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!

  • Love 5
Link to comment
Share on other sites

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.

  • Love 1
Link to comment
Share on other sites

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

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.

  • Love 1
Link to comment
Share on other sites

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.