Jump to content

Ban System - Ban Command with Reason


Sanchez

Recommended Posts

DBManager::instance().DirectQuery("INSERT INTO account.banlist (id, name, begins, finish, reason) VALUES ('%d', %s, NOW(), FROM_UNIXTIME(UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) + %i, %s)", LCHARACTER->GetAID(), LCHARACTER->GetName(), duration * 3600, reason);

Don't work.. i want to create a table with name: banlist  ( to have a ban list on the website ).

SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `banlist`
-- ----------------------------
DROP TABLE IF EXISTS `banlist`;
CREATE TABLE `banlist` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(24) CHARACTER SET ascii NOT NULL,
`begins` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`finish` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`reason` varchar(256) CHARACTER SET ascii DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin5;

But when i compile game i have errors...

y9mTFoB.png?1

 

My code:

ACMD(do_ban)
{
    // Args
    char arg1[256], arg2[256], arg3[256];
 
    // Local variables
    const char*  szName;
    const char*  szReason;
    int          iDuration;
 
    one_argument(two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2)), arg3, sizeof(arg3));
 
    // Invalid syntax
    if (!*arg1 || !*arg2 || !*arg3)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "Invalid Syntax, usage: <player name> <timp in ore> <motiv> tip: nu folosi space la motiv, foloseste: _");
        return;
    }
 
    szName      = arg1;
    iDuration   = atoi(arg2);
    szReason    = arg3;

    if (iDuration <= 0)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "Duratia nu poate fi 0 sau negativa.");
        return;
    }

    LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(szName);

    if (!tch)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "%s nu e online", szName);
        return;
    }

    if (!tch->GetDesc())
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "%s don't have desc", szName);
        return;
    }

    if (tch == ch)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "Esti tampit? Te banezi singur?");
        return;
    }

    if (tch->GetGMLevel() > GM_PLAYER)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "Nu poti bana un GM");
        return;
    }

    std::auto_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("UPDATE account.account SET availDt = FROM_UNIXTIME(UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) + %i), reason = '%s' WHERE id = %d", iDuration * 3600, szReason, tch->GetDesc()->GetAccountTable().id));
    std::auto_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("INSERT INTO account.banlist (id, name, begins, finish, reason) VALUES ('%d', %s, NOW(), FROM_UNIXTIME(UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) + %i, %s)", LCHARACTER->GetAID(), LCHARACTER->GetName(), duration * 3600, reason));
    
    tch->GetDesc()->DelayedDisconnect(5);

    sys_log(0, "%s[%d] a banat %s pentru %i ore cu motivul: %s", ch->GetName(), ch->GetPlayerID(), szName, iDuration, szReason);

    ch->ChatPacket(CHAT_TYPE_INFO, "%s a fost banat pentru %i ore cu motivul: %s", szName, iDuration, szReason);
}

 

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • 5 months later...
  • 3 weeks later...
  • 1 month later...

To me its working correctly,

but i need to know how to do :

----> capability to ban a player even if he is offline, (if i try to do that, it tells me  "is not playing"

-----> add a notice all message after i ban someone with name player ban reason  (like the phrase for syslog)

-----> add a notice all message after the ban of somone is finished and the player is capable to re-join.  (if its possible, if not i don t care)

Link to comment
Share on other sites

  • 1 year later...
Am 24.2.2016 um 17:04 schrieb Motumbo:

To me its working correctly,

but i need to know how to do :

----> capability to ban a player even if he is offline, (if i try to do that, it tells me  "is not playing"

-----> add a notice all message after i ban someone with name player ban reason  (like the phrase for syslog) - like /n (GM-Message) message

Same, can someone help?

I know, its an old thread. Excuse me.

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.