Jump to content
Maintenance ×
×
×
  • Create New...
  • 0

Ingame ban command


alberto2010

Question

hello guys, i want to make a ban command but i have a problem , this is the code:

ACMD(do_ban)
{
char arg1[256], arg2[256];
const char* name;
const char* reason;
if (!ch || ch->GetGMLevel() != GM_IMPLEMENTOR)
{
    sys_log(0, "do_ban without rights %s[%d]", ch->GetName(), ch->GetPlayerID());
    return;
}
two_arguments(argument, arg1, sizeof (arg1), arg2, sizeof(arg2));
if (!*arg1 || !*arg2)
{
    ch->ChatPacket(CHAT_TYPE_INFO, "Correct command form: /ban <player name> <reason>");
    return;
}
name = arg1;
reason = arg2;
LPDESC LDESC = DESC_MANAGER::instance().FindByCharacterName(name);
LPCHARACTER LCHARACTER = LDESC ? LDESC->GetCharacter() : NULL;
if (!LCHARACTER)
{
    ch->ChatPacket(CHAT_TYPE_INFO, "%s not found.", name);
    return;
}
if (LCHARACTER == ch)
{
    ch->ChatPacket(CHAT_TYPE_INFO, "You cant ban yourself!");
    return;
}
if (LCHARACTER->GetGMLevel() >= GM_LOW_WIZARD)
{
    ch->ChatPacket(CHAT_TYPE_INFO, "You cant do that.");
    return;
}
LCHARACTER = CHARACTER_MANAGER::instance().FindPC(name);
std::auto_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("UPDATE account.account SET status = 'BLOCK' WHERE id = %d", LCHARACTER->GetAID()));
std::auto_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("UPDATE player.player SET reason = %s WHERE id = %d", reason, LCHARACTER->GetAID()));
LDESC->DelayedDisconnect(5);
sys_log(0, "%s[%d] banned %s with reason: %s", ch->GetName(), ch->GetPlayerID(), name, reason);
ch->ChatPacket(CHAT_TYPE_INFO, "%s was banned with reason: %s", name, reason);
}

my problem is how i can use two directquery?

i get this when i try to compile:

cmd_gm.cpp:2836: error: redeclaration of 'std::auto_ptr<_SQLMsg> msg'
cmd_gm.cpp:2836: error: 'std::auto_ptr<_SQLMsg> msg' previously declared here
 

Link to comment
Share on other sites

  • Answers 1
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

1 answer to this question

Recommended Posts

  • 0
ACMD(do_ban)
{
char arg1[256], arg2[256];
const char* name;
const char* reason;
if (!ch || ch->GetGMLevel() != GM_IMPLEMENTOR)
{
    sys_log(0, "do_ban without rights %s[%d]", ch->GetName(), ch->GetPlayerID());
    return;
}
two_arguments(argument, arg1, sizeof (arg1), arg2, sizeof(arg2));
if (!*arg1 || !*arg2)
{
    ch->ChatPacket(CHAT_TYPE_INFO, "Correct command form: /ban <player name> <reason>");
    return;
}
name = arg1;
reason = arg2;
LPDESC LDESC = DESC_MANAGER::instance().FindByCharacterName(name);
LPCHARACTER LCHARACTER = LDESC ? LDESC->GetCharacter() : NULL;
if (!LCHARACTER)
{
    ch->ChatPacket(CHAT_TYPE_INFO, "%s not found.", name);
    return;
}
if (LCHARACTER == ch)
{
    ch->ChatPacket(CHAT_TYPE_INFO, "You cant ban yourself!");
    return;
}
if (LCHARACTER->GetGMLevel() >= GM_LOW_WIZARD)
{
    ch->ChatPacket(CHAT_TYPE_INFO, "You cant do that.");
    return;
}
LCHARACTER = CHARACTER_MANAGER::instance().FindPC(name);

  
DBManager::instance().DirectQuery("UPDATE account.account SET status = 'BLOCK' WHERE id = %d", LCHARACTER->GetAID());
DBManager::instance().DirectQuery("UPDATE player.player SET reason = %s WHERE id = %d", reason, LCHARACTER->GetAID());  

LDESC->DelayedDisconnect(5);
sys_log(0, "%s[%d] banned %s with reason: %s", ch->GetName(), ch->GetPlayerID(), name, reason);
ch->ChatPacket(CHAT_TYPE_INFO, "%s was banned with reason: %s", name, reason);
}

 

Link to comment
Share on other sites

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
  • Recently Browsing   0 members

    • No registered users viewing this page.


  • Activity

    1. 4

      problem Dargon Soul Changre Attribute

    2. 41

      Global Chat

    3. 4

      problem Dargon Soul Changre Attribute

    4. 2

      Startup Loading Window Library

    5. 28

      Ludus2: metin2 fan project

    6. 44

      Inbuild GR2 Animation

    7. 6

      Minimap Mob proto

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.