Jump to content
×
×
  • Create New...

Players Local Map Cords Dddition


Recommended Posts

  • Moon

Hey,

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

615b9fad022c4f1f8e56b74b62c41136.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

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

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
  • Moon
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

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


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.