Jump to content

Ban IP System


Recommended Posts

  • Honorable Member

M2 Download Center

This is the hidden content, please
( Internal )

This is the hidden content, please
( GitHub )

https://metin2.download/picture/V8c6YtUR94dQuCY6Z4cf2pbj299sr9cC/.png

Create /usr/game/auth/BANIP. Then find IP at player.player ip table and add to file. 

Don't forget the left a space at the end.

Example:

 

185348QPMGTRE.png

Gm Command: 

This is the hidden content, please

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 139
  • Eyes 1
  • Dislove 3
  • Not Good 1
  • Think 1
  • Confused 1
  • Scream 3
  • Lmao 2
  • Good 37
  • Love 6
  • Love 81

 

Link to comment
Share on other sites

  • 1 year later...
  • 2 years later...

Hello @ Mali thanks for the system, and sorry to revive this, this is a little update to after use the command and the players are kicked, the account automaticaly have "BLOCK" on navicat

Open ipban.cpp and replace function with:

Spoiler

#ifdef IP_BAN <--Change with your macro
void do_ipban(LPCHARACTER ch, const char *argument, int cmd, int subcmd)
{
    char arg1[256];
    one_argument(argument, arg1, sizeof(arg1));

    if (!*arg1) {
        ch->ChatPacket(CHAT_TYPE_INFO, "Uso: ipban <nombre>");
        return;
    }

    std::unique_ptr<SQLMsg> checkAccountStatus(DBManager::instance().DirectQuery("SELECT status FROM account.account WHERE id = (SELECT account_id FROM player.player WHERE name = '%s')", arg1));

    if (checkAccountStatus->Get()->uiNumRows)
    {
        const auto statusRow = mysql_fetch_row(checkAccountStatus->Get()->pSQLResult);
        const std::string accountStatus(statusRow[0]);

        if (accountStatus == "BLOCK")
        {
            ch->ChatPacket(CHAT_TYPE_INFO, "La cuenta de %s's esta actualmente baneada.", arg1);
            return;
        }
        else {
            std::unique_ptr<SQLMsg> blockAccount(DBManager::instance().DirectQuery("UPDATE account.account SET status = 'BLOCK' WHERE id = (SELECT account_id FROM player.player WHERE name = '%s')", arg1));

            if (blockAccount->Get()->uiAffectedRows > 0) {
                ch->ChatPacket(CHAT_TYPE_INFO, "La cuenta de %s's ha sido baneada.", arg1);
            }
            else {
                ch->ChatPacket(CHAT_TYPE_INFO, "Error al bnear la cuenta de %s's .", arg1);
                return;
            }
        }
    }
    else {
        ch->ChatPacket(CHAT_TYPE_INFO, "No se encuentra al jugador %s", arg1);
        return;
    }

    LPDESC d = DESC_MANAGER::instance().FindByCharacterName(arg1);

    if (d && d->GetCharacter()) {
        if (ch == d->GetCharacter()) {
            ch->ChatPacket(CHAT_TYPE_INFO, "No puedes banearte a ti mismo.");
            return;
        }

        if (d->GetCharacter()->IsGM()) {
            ch->ChatPacket(CHAT_TYPE_INFO, "No puedes banear a un GameMaster.");
            return;
        }

        std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("SELECT ip FROM player.player WHERE name = '%s'", d->GetCharacter()->GetName()));

        if (msg->Get()->uiNumRows) {
            const auto row = mysql_fetch_row(msg->Get()->pSQLResult);
            AddBanIP(row[0]);
            ch->ChatPacket(CHAT_TYPE_INFO, "El jugador %s ha sido baneado, con ip: %s", d->GetCharacter()->GetName(), row[0]);
            DESC_MANAGER::instance().DestroyDesc(d);  // Desconectar al jugador inmediatamente
        }
        else {
            ch->ChatPacket(CHAT_TYPE_INFO, "Error al busca la IP %s", arg1);
        }
    }
    else {
        ch->ChatPacket(CHAT_TYPE_INFO, "No se encuentra %s", arg1);
    }
}
#endif

It's a shame we have to restart to apply the changes, because until then you can continue connecting/creating accounts, I'm still looking into this, anyway, thank you very much, you always do an incredible job.

9454b76c65ca624b3d918493f2978b12.gif

Edited by Metin2 Dev International
Core X - External 2 Internal

KH.jpg

Nicks: Nazox Krone Nagato Yahiko Yakiro
Proyecto: Trabajando en el.
Compañeros & firma: DreamHQ  - 2009-2015 [Nostalgia]

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.