Skip to forum content

You are not logged in. Please login or register.


Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 17

1

Topic: /fcomment

Написал команду для комментирования друзей, что бы добавить себе в pvpgn делайте так:


В account_wrap.h добавить:

extern int account_set_friend_comment(t_account * account, int friendnum, const char * comment);
extern const char * account_get_friend_comment(t_account * account, int friendnum);

В account_wrap.cpp добавить:

extern int account_set_friend_comment(t_account * account, int friendnum, const char * comment)
{
    char key[256];
    if (friendnum < 0 || friendnum >= prefs_get_max_friends() || strlen(comment) == 0)
    {
        return -1;
    }
    std::sprintf(key, "friend\\%d\\comment", friendnum);

    return account_set_strattr(account, key, comment);
}

extern const char * account_get_friend_comment(t_account * account, int friendnum)
{
    char key[256];
    const char * comment;
    if (friendnum < 0 || friendnum >= prefs_get_max_friends())
    {
        return "bad request.";
    }
    std::sprintf(key, "friend\\%d\\comment", friendnum);
    comment = account_get_strattr(account, key);
    if (0 == _stricmp(comment, "(null)"))
        return " no comment ";
    else
        return comment;
}

В command.cpp добавить новую команду:

static int _handle_fcomment_command(t_connection * c, char const * text)
{
    t_account * my_acc = conn_get_account(c);
    t_account * friend_acc;
    t_friend * fr;
    t_list  * flist;
    int num, i;
    unsigned int uid;
    bool found = false;

    text = skip_command(text);
    char username[16];
    int space;
    for (space = 0; space < 17; space++)
        if (text[space] == ' ') break;
    if (space == 17)
    {
        message_send_text(c, message_type_error, c, "Bad username!");
        message_send_text(c, message_type_info, c, "usage: /fcomment <username> <comment>");
        return 0;
    }
    memcpy(username, text, space);
    text = skip_command(text);
    

    username[space] = '\0';
    num = account_get_friendcount(my_acc);
    flist = account_get_friends(my_acc);
    if (flist != NULL) {
        for (i = 0; i < num; i++)
        {
            if ((!(uid = account_get_friend(my_acc, i))) || (!(fr = friendlist_find_uid(flist, uid))))
            {
                eventlog(eventlog_level_error, __FUNCTION__, "friend uid in list");
                continue;
            }
            friend_acc = friend_get_account(fr);

            if (0 == _stricmp(username, account_get_name(friend_acc)))
            {
                found = true;
                account_set_friend_comment(my_acc, i, text);
                snprintf(msgtemp, sizeof(msgtemp), "You set comment \"%s\" for friend: %.16s", text,username);
                message_send_text(c, message_type_info, c, msgtemp);
            }
            else continue;
        }
    }


    if (!found)
    {
        message_send_text(c, message_type_error, c, "No friend with this username!");
        message_send_text(c, message_type_info, c, "usage: /fcomment <username> <comment>");
        return 0;
    }

    return 0;
}

И заменить команду static int _handle_friends_command(t_connection * c, char const * text)
на эту:

static int _handle_friends_command(t_connection * c, char const * text)
{
    int i;
    t_account *my_acc = conn_get_account(c);

    text = skip_command(text);

    if (strstart(text, "add") == 0 || strstart(text, "a") == 0) {
        char msgtemp[MAX_MESSAGE_LEN];
        t_packet     * rpacket;
        t_connection     * dest_c;
        t_account        * friend_acc;
        t_server_friendslistreply_status status;
        t_game * game;
        t_channel * channel;
        char stat;
        t_list * flist;
        t_friend * fr;

        text = skip_command(text);

        if (text[0] == '\0') {
            message_send_text(c, message_type_info, c, "usage: /f add <username>");
            return 0;
        }

        if (!(friend_acc = accountlist_find_account(text))) {
            message_send_text(c, message_type_info, c, "That user does not exist.");
            return 0;
        }

        switch (account_add_friend(my_acc, friend_acc)) {
        case -1:
            message_send_text(c, message_type_error, c, "Server error.");
            return 0;
        case -2:
            message_send_text(c, message_type_info, c, "You can't add yourself to your friends list.");
            return 0;
        case -3:
            snprintf(msgtemp, sizeof(msgtemp), "You can only have a maximum of %d friends.", prefs_get_max_friends());
            message_send_text(c, message_type_info, c, msgtemp);
            return 0;
        case -4:
            snprintf(msgtemp, sizeof(msgtemp), "%.64s is already on your friends list!", text);
            message_send_text(c, message_type_info, c, msgtemp);
            return 0;
        }

        snprintf(msgtemp, sizeof(msgtemp), "Added %.64s to your friends list.", text);
        message_send_text(c, message_type_info, c, msgtemp);
        dest_c = connlist_find_connection_by_account(friend_acc);
        if (dest_c != NULL) {
            snprintf(msgtemp, sizeof(msgtemp), "%.64s added you to his/her friends list.", conn_get_username(c));
            message_send_text(dest_c, message_type_info, dest_c, msgtemp);
        }

        if ((conn_get_class(c) != conn_class_bnet) || (!(rpacket = packet_create(packet_class_bnet))))
            return 0;

        packet_set_size(rpacket, sizeof(t_server_friendadd_ack));
        packet_set_type(rpacket, SERVER_FRIENDADD_ACK);

        packet_append_string(rpacket, account_get_name(friend_acc));

        game = NULL;
        channel = NULL;

        if (!(dest_c))
        {
            bn_byte_set(&status.location, FRIENDSTATUS_OFFLINE);
            bn_byte_set(&status.status, 0);
            bn_int_set(&status.clienttag, 0);
        }
        else
        {
            bn_int_set(&status.clienttag, conn_get_clienttag(dest_c));
            stat = 0;
            flist = account_get_friends(my_acc);
            fr = friendlist_find_account(flist, friend_acc);
            if ((friend_get_mutual(fr)))    stat |= FRIEND_TYPE_MUTUAL;
            if ((conn_get_dndstr(dest_c)))  stat |= FRIEND_TYPE_DND;
            if ((conn_get_awaystr(dest_c))) stat |= FRIEND_TYPE_AWAY;
            bn_byte_set(&status.status, stat);
            if ((game = conn_get_game(dest_c)))
            {
                if (game_get_flag(game) != game_flag_private)
                    bn_byte_set(&status.location, FRIENDSTATUS_PUBLIC_GAME);
                else
                    bn_byte_set(&status.location, FRIENDSTATUS_PRIVATE_GAME);
            }
            else if ((channel = conn_get_channel(dest_c)))
            {
                bn_byte_set(&status.location, FRIENDSTATUS_CHAT);
            }
            else
            {
                bn_byte_set(&status.location, FRIENDSTATUS_ONLINE);
            }
        }

        packet_append_data(rpacket, &status, sizeof(status));

        if (game) packet_append_string(rpacket, game_get_name(game));
        else if (channel) packet_append_string(rpacket, channel_get_name(channel));
        else packet_append_string(rpacket, "");

        conn_push_outqueue(c, rpacket);
        packet_del_ref(rpacket);
    }
    else if (strstart(text, "msg") == 0 || strstart(text, "w") == 0 || strstart(text, "whisper") == 0 || strstart(text, "m") == 0)
    {
        char const *msg;
        int cnt = 0;
        t_connection * dest_c;
        t_elem  * curr;
        t_friend * fr;
        t_list  * flist;

        msg = skip_command(text);
        /* if the message test is empty then ignore command */
        if (msg[0] == '\0') {
            message_send_text(c, message_type_info, c, "Did not message any friends. Type some text next time.");
            return 0;
        }

        flist = account_get_friends(my_acc);
        if (flist == NULL)
            return -1;

        LIST_TRAVERSE(flist, curr)
        {
            if (!(fr = (t_friend*)elem_get_data(curr))) {
                eventlog(eventlog_level_error, __FUNCTION__, "found NULL entry in list");
                continue;
            }
            if (friend_get_mutual(fr)) {
                dest_c = connlist_find_connection_by_account(friend_get_account(fr));
                if (!dest_c) continue;
                message_send_text(dest_c, message_type_whisper, c, msg);
                cnt++;
            }
        }
        if (cnt)
            message_send_text(c, message_type_friendwhisperack, c, msg);
        else
            message_send_text(c, message_type_info, c, "All your friends are offline.");
    }
    else if (strstart(text, "r") == 0 || strstart(text, "remove") == 0
        || strstart(text, "del") == 0 || strstart(text, "delete") == 0) {

        int num;
        char msgtemp[MAX_MESSAGE_LEN];
        t_packet * rpacket;

        text = skip_command(text);

        if (text[0] == '\0') {
            message_send_text(c, message_type_info, c, "usage: /f remove <username>");
            return 0;
        }

        switch ((num = account_remove_friend2(my_acc, text))) {
        case -1: return -1;
        case -2:
            snprintf(msgtemp, sizeof(msgtemp), "%.64s was not found on your friends list.", text);
            message_send_text(c, message_type_info, c, msgtemp);
            return 0;
        default:
            snprintf(msgtemp, sizeof(msgtemp), "Removed %.64s from your friends list.", text);
            message_send_text(c, message_type_info, c, msgtemp);

            if ((conn_get_class(c) != conn_class_bnet) || (!(rpacket = packet_create(packet_class_bnet))))
                return 0;

            packet_set_size(rpacket, sizeof(t_server_frienddel_ack));
            packet_set_type(rpacket, SERVER_FRIENDDEL_ACK);

            bn_byte_set(&rpacket->u.server_frienddel_ack.friendnum, num);

            conn_push_outqueue(c, rpacket);
            packet_del_ref(rpacket);

            return 0;
        }
    }
    else if (strstart(text, "p") == 0 || strstart(text, "promote") == 0) {
        int num;
        int n;
        char msgtemp[MAX_MESSAGE_LEN];
        char const * dest_name;
        t_packet * rpacket;
        t_list * flist;
        t_friend * fr;
        t_account * dest_acc;
        unsigned int dest_uid;

        text = skip_command(text);

        if (text[0] == '\0') {
            message_send_text(c, message_type_info, c, "usage: /f promote <username>");
            return 0;
        }

        num = account_get_friendcount(my_acc);
        flist = account_get_friends(my_acc);
        for (n = 1; n < num; n++)
            if ((dest_uid = account_get_friend(my_acc, n)) &&
                (fr = friendlist_find_uid(flist, dest_uid)) &&
                (dest_acc = friend_get_account(fr)) &&
                (dest_name = account_get_name(dest_acc)) &&
                (strcasecmp(dest_name, text) == 0))
            {
                account_set_friend(my_acc, n, account_get_friend(my_acc, n - 1));
                account_set_friend(my_acc, n - 1, dest_uid);
                snprintf(msgtemp, sizeof(msgtemp), "Premoted %.64s in your friends list.", dest_name);
                message_send_text(c, message_type_info, c, msgtemp);

                if ((conn_get_class(c) != conn_class_bnet) || (!(rpacket = packet_create(packet_class_bnet))))
                    return 0;

                packet_set_size(rpacket, sizeof(t_server_friendmove_ack));
                packet_set_type(rpacket, SERVER_FRIENDMOVE_ACK);
                bn_byte_set(&rpacket->u.server_friendmove_ack.pos1, n - 1);
                bn_byte_set(&rpacket->u.server_friendmove_ack.pos2, n);

                conn_push_outqueue(c, rpacket);
                packet_del_ref(rpacket);
                return 0;
            }
    }
    else if (strstart(text, "d") == 0 || strstart(text, "demote") == 0) {
        int num;
        int n;
        char msgtemp[MAX_MESSAGE_LEN];
        char const * dest_name;
        t_packet * rpacket;
        t_list * flist;
        t_friend * fr;
        t_account * dest_acc;
        unsigned int dest_uid;

        text = skip_command(text);

        if (text[0] == '\0') {
            message_send_text(c, message_type_info, c, "usage: /f demote <username>");
            return 0;
        }

        num = account_get_friendcount(my_acc);
        flist = account_get_friends(my_acc);
        for (n = 0; n < num - 1; n++)
            if ((dest_uid = account_get_friend(my_acc, n)) &&
                (fr = friendlist_find_uid(flist, dest_uid)) &&
                (dest_acc = friend_get_account(fr)) &&
                (dest_name = account_get_name(dest_acc)) &&
                (strcasecmp(dest_name, text) == 0))
            {
                account_set_friend(my_acc, n, account_get_friend(my_acc, n + 1));
                account_set_friend(my_acc, n + 1, dest_uid);
                snprintf(msgtemp, sizeof(msgtemp), "Premoted %.64s in your friends list.", dest_name);
                message_send_text(c, message_type_info, c, msgtemp);

                if ((conn_get_class(c) != conn_class_bnet) || (!(rpacket = packet_create(packet_class_bnet))))
                    return 0;

                packet_set_size(rpacket, sizeof(t_server_friendmove_ack));
                packet_set_type(rpacket, SERVER_FRIENDMOVE_ACK);
                bn_byte_set(&rpacket->u.server_friendmove_ack.pos1, n);
                bn_byte_set(&rpacket->u.server_friendmove_ack.pos2, n + 1);

                conn_push_outqueue(c, rpacket);
                packet_del_ref(rpacket);
                return 0;
            }
    }
    else if (strstart(text, "list") == 0 || strstart(text, "l") == 0) {
        char const * frienduid;
        char status[128];
        char software[64];
        char msgtemp[MAX_MESSAGE_LEN];
        t_connection * dest_c;
        t_account * friend_acc;
        t_game const * game;
        t_channel const * channel;
        t_friend * fr;
        t_list  * flist;
        int num;
        unsigned int uid;

        message_send_text(c, message_type_info, c, "Your PvPGN - Friends List");
        message_send_text(c, message_type_info, c, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
        num = account_get_friendcount(my_acc);

        flist = account_get_friends(my_acc);
        if (flist != NULL) {
            for (i = 0; i < num; i++)
            {
                if ((!(uid = account_get_friend(my_acc, i))) || (!(fr = friendlist_find_uid(flist, uid))))
                {
                    eventlog(eventlog_level_error, __FUNCTION__, "friend uid in list");
                    continue;
                }


                software[0] = '\0';
                friend_acc = friend_get_account(fr);
                if (!(dest_c = connlist_find_connection_by_account(friend_acc)))
                    std::sprintf(status, ", offline");
                else {
                    std::sprintf(software, " using %s", clienttag_get_title(conn_get_clienttag(dest_c)));

                    if (friend_get_mutual(fr)) {
                        if ((game = conn_get_game(dest_c)))
                            std::sprintf(status, ", in game \"%.64s\"", game_get_name(game));
                        else if ((channel = conn_get_channel(dest_c))) {
                            if (strcasecmp(channel_get_name(channel), "Arranged Teams") == 0)
                                std::sprintf(status, ", in game AT Preparation");
                            else
                                std::sprintf(status, ", in channel \"%.64s\",", channel_get_name(channel));
                        }
                        else
                            std::sprintf(status, ", is in AT Preparation");
                    }
                    else {
                        if ((game = conn_get_game(dest_c)))
                            std::sprintf(status, ", is in a game");
                        else if ((channel = conn_get_channel(dest_c)))
                            std::sprintf(status, ", is in a chat channel");
                        else
                            std::sprintf(status, ", is in AT Preparation");
                    }
                }

                frienduid = account_get_name(friend_acc);
                if (software[0]) snprintf(msgtemp, sizeof(msgtemp), "%d: %s%.16s(%s)%.128s, %.64s", i + 1, friend_get_mutual(fr) ? "*" : " ", frienduid, account_get_friend_comment(my_acc, i), status, software);
                else snprintf(msgtemp, sizeof(msgtemp), "%d: %.16s(%s)%.128s", i + 1, frienduid, account_get_friend_comment(my_acc, i), status);
                message_send_text(c, message_type_info, c, msgtemp);
            }
        }
        message_send_text(c, message_type_info, c, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
        message_send_text(c, message_type_info, c, "End of Friends List");
    }
    else {
        message_send_text(c, message_type_info, c, "Friends List (Used in Arranged Teams and finding online friends.)");
        message_send_text(c, message_type_info, c, "Type: /f add <username> (adds a friend to your list)");
        message_send_text(c, message_type_info, c, "Type: /f del <username> (removes a friend from your list)");
        message_send_text(c, message_type_info, c, "Type: /f promote <username> (promote a friend in your list)");
        message_send_text(c, message_type_info, c, "Type: /f demote <username> (demote a friend in your list)");
        message_send_text(c, message_type_info, c, "Type: /f list (shows your full friends list)");
        message_send_text(c, message_type_info, c, "Type: /f msg (whispers a message to all your friends at once)");
    }

    return 0;
}

Скриншот:http://forums.harpywar.com/extensions/hcs_image_uploader/uploads/0/5500/5677/thumb/p18dbp6bsra7rmr7hen6mk1vh01.jpg

2

Re: /fcomment

Cub_one ,thanks for your contribution.

a question ¿ how do you change the background?

could you please share it

3

Re: /fcomment

Dante wrote:

Cub_one ,thanks for your contribution.

a question ¿ how do you change the background?

could you please share it

Качай тут www.d3scene.com/forum/warcraft-3 … 0-1-a.html

4

Re: /fcomment

Cub_bone ммм а как ты изменил фон в варике??

5

Re: /fcomment

yaphets wrote:

Cub_bone ммм а как ты изменил фон в варике??

зачем повторять вопрос, качай то что я выше дал если хочешь такой, а так гугли big_smile

6

Re: /fcomment

yaphets wrote:

Cub_bone ммм а как ты изменил фон в варике??

Кстати у него не фон, а картинка к примеру в .gif формате, она у него движется постоянно, как основная картинка в варике (там где башня и снег идет).

7

Re: /fcomment

Да нет вар не поддерживает гиф анимации по моему big_smile Я в 3dsmax'е все рисовал)

8

Re: /fcomment

Ммм... big_smile

9

Re: /fcomment

XOM91K wrote:

Ммм... big_smile

Ты еще живой штоле? :-D

По сабжу: после релога сервера или игрока, комментарии остаются?

10

Re: /fcomment

Сервер сохраняет все данные если выключаешь через ctrl+c консоль или по таймеру который в конфиге настраивается. Если закрыл процесс сервера то конечно ничего не сохранится.

11

Re: /fcomment

XOM91K wrote:
yaphets wrote:

Cub_bone ммм а как ты изменил фон в варике??

Кстати у него не фон, а картинка к примеру в .gif формате, она у него движется постоянно, как основная картинка в варике (там где башня и снег идет).

это не гиф. это модель .mdx.

12

Re: /fcomment

Suite wrote:
XOM91K wrote:
yaphets wrote:

Cub_bone ммм а как ты изменил фон в варике??

Кстати у него не фон, а картинка к примеру в .gif формате, она у него движется постоянно, как основная картинка в варике (там где башня и снег идет).

это не гиф. это модель .mdx.

Да ну?

13

Re: /fcomment

XOM91K это лично мое мнение.

14

Re: /fcomment

Я что, не написал что в 3dsmax'e сделал эту mdx модель?  yikes

15

Re: /fcomment

function of / fcomment what ?

16

Re: /fcomment

Suite wrote:

XOM91K это лично мое мнение.

шта

17

Re: /fcomment

Cub_bone wrote:

Я что, не написал что в 3dsmax'e сделал эту mdx модель?  yikes

странно багнулась опера, только что увидел этот пост О_О

Posts: 17

Pages 1

You must login or register to post a reply

Who now at forum

Currently view post: 1 guest, 0 registered users



Generated in 0.068 seconds (89% PHP - 11% DB) with 20 queries