pvpgn / pvpgn-server

Next generation of PvPGN server
https://pvpgn.pro
GNU General Public License v2.0
556 stars 155 forks source link

/summon <player> #42

Open RElesgoe opened 10 years ago

RElesgoe commented 10 years ago
static int _handle_summon_command(t_connection * c, char const *text)
{
    t_channel * channel;
    t_connection *  user;

    std::vector<std::string> args = split_command(text, 1);

    if (args[1].empty())
    {
        describe_command(c, args[0].c_str());
        return 0;
    }
    text = args[1].c_str(); // player to be summoned

    if (!accountlist_find_account(text))
    {
        message_send_text(c, message_type_error, c, localize(c, "Account {} does not exist.", text));
        return 0;
    }

    if (user = connlist_find_connection_by_accountname(text))
    {
        message_send_text(c, message_type_error, c, localize(c, "{} is not online.", text));
        return 0;
    }

    if (channel = conn_get_channel(user))
    {
        if (strcasecmp(channel_get_name(conn_get_channel(c)), channel_get_name(channel)) == 0)
        {
            message_send_text(c, message_type_info, c, localize(c, "{} is already in the same channel as you.", text));
            return 0;
        }

        conn_set_channel(user, channel_get_name(conn_get_channel(c)))

        if ((conn_get_clienttag(user) == CLIENTTAG_WARCRAFT3_UINT) || (conn_get_clienttag(user) == CLIENTTAG_WAR3XP_UINT))
            conn_update_w3_playerinfo(user);
        command_set_flags(user);

        message_send_text(c, message_type_info, c, localize(c, "{} has been summoned.", text));
    }
    else
    {
        message_send_text(c, message_type_error, c, localize(c, "{} is currently in a game.", text));
    }

    return 0;
}

Summons <player> to the same channel as you. This code is untested

cen1 commented 10 years ago

This seems potentially dangerous and abusable. Is it supposed to be under higher CGs?

RElesgoe commented 10 years ago

Yeah, those with higher CGs should be able to use it, not regular players

HarpyWar commented 10 years ago

May be add this command and allow it for all users, but destination user must confirm it by writing /summon yes (the same syntax for /clan command when invite user into a clan)

RElesgoe commented 10 years ago

@HarpyWar I disagree, if a player wants another player to come to the same channel, he can just /whisper the other player to come and if the other player wants to accept the request, he just types /j <channel>.