Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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!
I have a problem in TFS 1.5 when the player kills another and exits. Then 1 minute later, the player falls, whereas the character should stay for 15 minutes.
Sounds like noPongKickTime, property noPongKickTime in data/XML/vocations.xml or default 60000.
You can write some custom onLogout creatureEvent script that'd do some additional checks and make it return false in such cases.
Sounds like noPongKickTime, property noPongKickTime in data/XML/vocations.xml or default 60000.
You can write some custom onLogout creatureEvent script that'd do some additional checks and make it return false in such cases.
the problem is that I have a lot of things related to frags etc.. like the frag counter, the frags with old tibia system, and I also implemented the rule violation, so I don't know where these 2 errors come from.
Post automatically merged:
the pz is leaving quickly, the player can fall while he is pz, I have problems with banning if I kill too many. Looks like I'm a little screwed up here
Post automatically merged:
My player.cpp
C++:
void Player::addUnjustifiedDead(const Player* attacked)
{
if (hasFlag(PlayerFlag_NotGainInFight) || attacked == this || g_game.getWorldType() == WORLD_TYPE_PVP_ENFORCED) {
return;
}
sendTextMessage(MESSAGE_STATUS_WARNING, "Warning! The murder of " + attacked->getName() + " was not justified.");
// current unjustified kill!
murderTimeStamps.push_back(std::time(nullptr));
if (playerKillerEnd == 0) {
// white skull time, it only sets on first kill!
playerKillerEnd = std::time(nullptr) + g_config.getNumber(ConfigManager::WHITE_SKULL_TIME);
}
uint32_t murderResult = checkPlayerKilling();
if (murderResult >= 1) {
// red skull player
playerKillerEnd = std::time(nullptr) + g_config.getNumber(ConfigManager::RED_SKULL_TIME);
setSkull(SKULL_RED);
if (murderResult == 2) {
// 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();
}
}
}
void Player::checkSkullTicks(int64_t ticks)
{
time_t today = std::time(nullptr);
if (!hasCondition(CONDITION_INFIGHT) && ((skull == SKULL_RED && today >= playerKillerEnd) || (skull == SKULL_WHITE))) {
setSkull(SKULL_NONE);
}
}
uint32_t Player::checkPlayerKilling()
{
time_t today = std::time(nullptr);
uint32_t lastDay = 0;
uint32_t lastWeek = 0;
uint32_t lastMonth = 0;
uint64_t egibleMurders = 0;
time_t dayTimestamp = today - (24 * 60 * 60);
time_t weekTimestamp = today - (7 * 24 * 60 * 60);
time_t monthTimestamp = today - (30 * 24 * 60 * 60);
for (time_t currentMurderTimestamp : murderTimeStamps) {
if (currentMurderTimestamp > dayTimestamp) {
lastDay++;
}
if (currentMurderTimestamp > weekTimestamp) {
lastWeek++;
}
egibleMurders = lastMonth + 1;
if (currentMurderTimestamp <= monthTimestamp) {
egibleMurders = lastMonth;
}
lastMonth = egibleMurders;
}
if (lastDay >= g_config.getNumber(ConfigManager::KILLS_DAY_BANISHMENT) ||
lastWeek >= g_config.getNumber(ConfigManager::KILLS_WEEK_BANISHMENT) ||
lastMonth >= g_config.getNumber(ConfigManager::KILLS_MONTH_BANISHMENT)) {
return 2; // banishment!
}
if (lastDay >= g_config.getNumber(ConfigManager::KILLS_DAY_RED_SKULL) ||
lastWeek >= g_config.getNumber(ConfigManager::KILLS_WEEK_RED_SKULL) ||
lastMonth >= g_config.getNumber(ConfigManager::KILLS_MONTH_RED_SKULL)) {
return 1; // red skull!
}
return 0;
}
[Error - mysql_real_query] Query: INSERT INTO `account_bans`
(`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`)
VALUES (4, 'Too many unjustified kills', 1710725427, 1713317427, 1);
Message: Cannot add or update a child row: a
foreign key constraint fails
(`otserver`.`account_bans`, CONSTRAINT `account_bans_ibfk_2`
FOREIGN KEY (`banned_by`)
REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)
I also get this bug when I'm going to be banned, so I'm not banned anymore. :/
Post automatically merged:
Post automatically merged:
the problem is that I have a lot of things related to frags etc.. like the frag counter, the frags with old tibia system, and I also implemented the rule violation, so I don't know where these 2 errors come from.
Post automatically merged:
the pz is leaving quickly, the player can fall while he is pz, I have problems with banning if I kill too many. Looks like I'm a little screwed up here
Post automatically merged:
My player.cpp
C++:
void Player::addUnjustifiedDead(const Player* attacked)
{
if (hasFlag(PlayerFlag_NotGainInFight) || attacked == this || g_game.getWorldType() == WORLD_TYPE_PVP_ENFORCED) {
return;
}
sendTextMessage(MESSAGE_STATUS_WARNING, "Warning! The murder of " + attacked->getName() + " was not justified.");
// current unjustified kill!
murderTimeStamps.push_back(std::time(nullptr));
if (playerKillerEnd == 0) {
// white skull time, it only sets on first kill!
playerKillerEnd = std::time(nullptr) + g_config.getNumber(ConfigManager::WHITE_SKULL_TIME);
}
uint32_t murderResult = checkPlayerKilling();
if (murderResult >= 1) {
// red skull player
playerKillerEnd = std::time(nullptr) + g_config.getNumber(ConfigManager::RED_SKULL_TIME);
setSkull(SKULL_RED);
if (murderResult == 2) {
// 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();
}
}
}
void Player::checkSkullTicks(int64_t ticks)
{
time_t today = std::time(nullptr);
if (!hasCondition(CONDITION_INFIGHT) && ((skull == SKULL_RED && today >= playerKillerEnd) || (skull == SKULL_WHITE))) {
setSkull(SKULL_NONE);
}
}
uint32_t Player::checkPlayerKilling()
{
time_t today = std::time(nullptr);
uint32_t lastDay = 0;
uint32_t lastWeek = 0;
uint32_t lastMonth = 0;
uint64_t egibleMurders = 0;
time_t dayTimestamp = today - (24 * 60 * 60);
time_t weekTimestamp = today - (7 * 24 * 60 * 60);
time_t monthTimestamp = today - (30 * 24 * 60 * 60);
for (time_t currentMurderTimestamp : murderTimeStamps) {
if (currentMurderTimestamp > dayTimestamp) {
lastDay++;
}
if (currentMurderTimestamp > weekTimestamp) {
lastWeek++;
}
egibleMurders = lastMonth + 1;
if (currentMurderTimestamp <= monthTimestamp) {
egibleMurders = lastMonth;
}
lastMonth = egibleMurders;
}
if (lastDay >= g_config.getNumber(ConfigManager::KILLS_DAY_BANISHMENT) ||
lastWeek >= g_config.getNumber(ConfigManager::KILLS_WEEK_BANISHMENT) ||
lastMonth >= g_config.getNumber(ConfigManager::KILLS_MONTH_BANISHMENT)) {
return 2; // banishment!
}
if (lastDay >= g_config.getNumber(ConfigManager::KILLS_DAY_RED_SKULL) ||
lastWeek >= g_config.getNumber(ConfigManager::KILLS_WEEK_RED_SKULL) ||
lastMonth >= g_config.getNumber(ConfigManager::KILLS_MONTH_RED_SKULL)) {
return 1; // red skull!
}
return 0;
}
The problem is related to the code inserting a row with banned_by set to 1 for an automated excessive frag ban.
You got that error because you have no player with the id of 1.
Make a player with the database row id of 1 called "the system".
Then anytime someone gets an automatic excessive frag ban, it will say:
Your account has been banned until 16 Apr 2024 by the system.
I solved it. The problem now lies with the player when he takes the frag and loses his skull quickly. The time is wrong, I don't know why the time is normal.
23:55 Warning! The murder of Kin on Carunia was not justified.
exit....
23:56 character logout... and lose skull.
void Player::addUnjustifiedDead(const Player* attacked)
{
if (hasFlag(PlayerFlag_NotGainInFight) || attacked == this || g_game.getWorldType() == WORLD_TYPE_PVP_ENFORCED) {
return;
}
sendTextMessage(MESSAGE_STATUS_WARNING, "Warning! The murder of " + attacked->getName() + " was not justified.");
// current unjustified kill!
murderTimeStamps.push_back(std::time(nullptr));
if (playerKillerEnd == 0) {
// white skull time, it only sets on first kill!
playerKillerEnd = std::time(nullptr) + g_config.getNumber(ConfigManager::WHITE_SKULL_TIME);
}
uint32_t murderResult = checkPlayerKilling();
if (murderResult >= 1) {
// red skull player
playerKillerEnd = std::time(nullptr) + g_config.getNumber(ConfigManager::RED_SKULL_TIME);
setSkull(SKULL_RED);
if (murderResult == 2) {
// 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();
}
}
}
I solved it. The problem now lies with the player when he takes the frag and loses his skull quickly. The time is wrong, I don't know why the time is normal.
23:55 Warning! The murder of Kin on Carunia was not justified.
exit....
23:56 character logout... and lose skull.
void Player::addUnjustifiedDead(const Player* attacked)
{
if (hasFlag(PlayerFlag_NotGainInFight) || attacked == this || g_game.getWorldType() == WORLD_TYPE_PVP_ENFORCED) {
return;
}
sendTextMessage(MESSAGE_STATUS_WARNING, "Warning! The murder of " + attacked->getName() + " was not justified.");
// current unjustified kill!
murderTimeStamps.push_back(std::time(nullptr));
if (playerKillerEnd == 0) {
// white skull time, it only sets on first kill!
playerKillerEnd = std::time(nullptr) + g_config.getNumber(ConfigManager::WHITE_SKULL_TIME);
}
uint32_t murderResult = checkPlayerKilling();
if (murderResult >= 1) {
// red skull player
playerKillerEnd = std::time(nullptr) + g_config.getNumber(ConfigManager::RED_SKULL_TIME);
setSkull(SKULL_RED);
if (murderResult == 2) {
// 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();
}
}
}
In Player::addUnjustifiedDead
Looks like you can remove this, its only really used for red skull,
your ticks are looking at the infight condition to remove the white skull, and that looks all fine.
C++:
if (playerKillerEnd == 0) {
// white skull time, it only sets on first kill!
playerKillerEnd = std::time(nullptr) + g_config.getNumber(ConfigManager::WHITE_SKULL_TIME);
}
So yeah, something else is removing the infight condition, could be a pong/logout issue...
sendTextMessage(MESSAGE_EVENT_ADVANCE, "Warning! The murder of " + attacked->getName() + " was not justified.");
skullTicks += g_config.getNumber(ConfigManager::FRAG_TIME);
but my code is
Lua:
sendTextMessage(MESSAGE_STATUS_WARNING, "Warning! The murder of " + attacked->getName() + " was not justified.");
// current unjustified kill!
murderTimeStamps.push_back(std::time(nullptr));
Post automatically merged:
After exiting, in just 1 minute I lose pk and the character disappears. If anyone can help me I would appreciate it.
Post automatically merged:
I'm testing it, and I saw that the pk respects it while I'm on the character, now I need to find out where the setting is when force logout (exit)
I wanted to take advantage of you Roddet, who is a moderator, and could you tell me why I can't select the solution options. I've been trying to make an appointment for a while now and I haven't been able to, I think it's been more than a year.
I wanted to take advantage of you Roddet, who is a moderator, and could you tell me why I can't select the solution options. I've been trying to make an appointment for a while now and I haven't been able to, I think it's been more than a year. View attachment 83066
If the script only solves the problem, then mark it as 'up' and comment/uncover at the same time, for example, 'thank you, working perfectly 100%,' etc. Then wait a few minutes or hours; a moderator or administrator will see your comment and be happy that it was a solution provided by someone who helped you, and will mark it as a solution. Done!