• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Problem with ban / RedSkull

Zodia

Member
Joined
Feb 21, 2020
Messages
220
Reaction score
20
TFS 1.2 / Nostalrius 7.72.

Good afternoon guys. After a Redskull kills 6 times (which would result in a temporary ban from the killer) on my server, I'm getting this error:

Lua:
-  [Error - mysql_real_query] Query: INSERT INTO account_bans (account_id, reason, banned_at, expires_at, banned_by) VALUES (24174074, 'Too many unjustified kills', 1608230975, 1608490175, 1);
2020-12-17 18:49:35 -  Message: Cannot add or update a child row: a foreign key constraint fails (worldteste.account_bans, CONSTRAINT account_bans_ibfk_2 FOREIGN KEY (banned_by) REFERENCES players (id) ON DELETE CASCADE ON UPDATE CASCADE)

The killer simply disconnects, but is not banned as he should.
Does anyone know what I need to do in this case?


When I copied I received warnings. Can it be related?

TKS!
Post automatically merged:

In my player.cpp I found:

Lua:
// banishment for too many unjustified kills
            Database* db = Database::getInstance();

            std::ostringstream ss;
            ss << "INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (";
            ss << getAccount() << ", ";
            ss << db->escapeString("Too many unjustified kills") << ", ";
            ss << std::time(nullptr) << ", ";
            ss << std::time(nullptr) + g_config.getNumber(ConfigManager::BAN_LENGTH) << ", ";
            ss << "1);";

            db->executeQuery(ss.str());

            g_game.addMagicEffect(getPosition(), CONST_ME_GREEN_RINGS);
            g_game.removeCreature(this);
            disconnect();
        }
    }
}
 
Last edited:
Lua:
-- Limitadores para a tabela `account_bans`
--
ALTER TABLE `account_bans`
  ADD CONSTRAINT `account_bans_ibfk_1` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `account_bans_ibfk_2` FOREIGN KEY (`banned_by`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;


I deleted the line:

ADD CONSTRAINT account_bans_ibfk_2 FOREIGN KEY (banned_by) REFERENCES players (id) ON DELETE CASCADE ON UPDATE CASCADE;


in the server database. Now the redskull ban is working. Can this bring me some kind of problem?
 
Back
Top