• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Request Daily/Weekly/Monthly Frag system

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
1,067
Solutions
5
Reaction score
63
Using tfs 1.2 8.60
Would be great if it was editable via config.lua like
Daily = 25
Weekly = 50
Monthly = 100
frags
 
take a look here:
To bad i dont have path_10_11/vc14/theforgottenserver.sln
EDIT: FOUND

I dont get it why there is
teleportNewbies = true
newbieTownId = 11
newbieLevelThreshold = 5
and hes removing channels why is it needed for frag system then like for example he want to delete
enum BugReportType_t : uint8_t {
but i dont even have it in my enums.h

Then he want to add static constexpr int32_t CHANNEL_RULE_REP = 0x02; in const.h but there is no where i can add it because i dont even have it these three by default

static constexpr int32_t CHANNEL_GUILD = 0x00;
static constexpr int32_t CHANNEL_PARTY = 0x01;
static constexpr int32_t CHANNEL_PRIVATE = 0xFFFF;
so this tutorial would ruin my source, and half thinks would not work
 
Last edited:
This commit is not just to add old frag system ,if you read the changelog you will see: - Add support to skullSystem and ruleViolations to 7.x .
So you need to edit the part that corresponds to frag system.
You need to change: config.lua , migrations ,configmanager.cpp and configmanager.h (just the skull and ban part) ,iologindata.cpp, luascript.cpp and luascript.h (just the skull and ban part) ,player.cpp and player.h .
 
Last edited:
This commit is not just to add old frag system ,if you read the changelog you will see: - Add support to skullSystem and ruleViolations to 7.x .
So you need to edit the part that corresponds to frag system.
You need to change: config.lua , migrations ,configmanager.cpp and configmanager.h (just the skull and ban part) ,iologindata.cpp, luascript.cpp and luascript.h (just the skull and ban part) ,player.cpp and player.h .
1>..\src\iologindata.cpp(361): error C2228: left of '.storeQuery' must have class/struct/union
1>..\src\iologindata.cpp(361): note: type is 'Database *'
1>..\src\iologindata.cpp(361): note: did you intend to use '->' instead?
1>..\src\iologindata.cpp(742): error C2228: left of '.executeQuery' must have class/struct/union
1>..\src\iologindata.cpp(742): note: type is 'Database *'
1>..\src\iologindata.cpp(742): note: did you intend to use '->' instead?
1>luascript.cpp
1>mailbox.cpp
1>map.cpp
1>..\src\luascript.cpp(1775): error C2039: 'FRAG_TIME': is not a member of 'ConfigManager'
1>c:\server\src\configmanager.h(26): note: see declaration of 'ConfigManager'
1>..\src\luascript.cpp(1775): error C2065: 'FRAG_TIME': undeclared identifier
1>monster.cpp
1>monsters.cpp
1>movement.cpp
1>networkmessage.cpp
1>npc.cpp
1>otserv.cpp
1>outfit.cpp
1>outputmessage.cpp
1>party.cpp
1>player.cpp
1>position.cpp
1>protocol.cpp
1>protocolgame.cpp
1>protocollogin.cpp
1>..\src\player.cpp(2092): error C2039: 'lastHitIsPlayer': is not a member of 'Player'
1>c:\server\src\npc.h(29): note: see declaration of 'Player'
1>..\src\player.cpp(2092): error C3861: 'lastHitIsPlayer': identifier not found
1>..\src\player.cpp(2972): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2973): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2974): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2978): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2979): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2980): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(3955): error C2440: 'initializing': cannot convert from 'Database *' to 'Database &'
1>..\src\player.cpp(3973): error C2059: syntax error: '}'
1>..\src\player.cpp(3973): error C2143: syntax error: missing ';' before '}'
1>..\src\player.cpp(3976): error C2143: syntax error: missing ';' before '{'
1>..\src\player.cpp(3976): error C2447: '{': missing function header (old-style formal list?)
 
i tried with otx3 8.6 and compiled fine here , the warning C4018 is not a problem.
you have to remove registerEnumIn("configKeys", ConfigManager::FRAG_TIME) on luascript.cpp,
,iologindata.cpp line 361 change db.storeQuery for db->storeQuery ,try again and good luck =)

edit*= ahh i forgot to say ,you shouldn't have changed this part: if (lastHitPlayer) { on player.cpp line 2092
 
Last edited:
i tried with otx3 8.6 and compiled fine here , the warning C4018 is not a problem.
you have to remove registerEnumIn("configKeys", ConfigManager::FRAG_TIME) on luascript.cpp,
,iologindata.cpp line 361 change db.storeQuery for db->storeQuery ,try again and good luck =)

edit*= ahh i forgot to say ,you shouldn't have changed this part: if (lastHitPlayer) { on player.cpp line 2092
1>..\src\iologindata.cpp(742): error C2228: left of '.executeQuery' must have class/struct/union
1>..\src\iologindata.cpp(742): note: type is 'Database *'
1>..\src\iologindata.cpp(742): note: did you intend to use '->' instead?

And

1>..\src\player.cpp(2972): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2973): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2974): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2978): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2979): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2980): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(3955): error C2440: 'initializing': cannot convert from 'Database *' to 'Database &'
1>..\src\player.cpp(3973): error C2059: syntax error: '}'
1>..\src\player.cpp(3973): error C2143: syntax error: missing ';' before '}'
1>..\src\player.cpp(3976): error C2143: syntax error: missing ';' before '{'
1>..\src\player.cpp(3976): error C2447: '{': missing function header (old-style formal list?)
 
iologindata.cpp line 361 change db.storeQuery for db->storeQuery ,try again and good luck =)
and you will need to change your talkaction kills for something like this:
LUA:
function onSay(player, words, param)
    if Game.getWorldType() == WORLD_TYPE_PVP_ENFORCED then
        player:showTextDialog(1998, "Your character has not murders history.", false)
        return false
    end
    
    local today = os.time()
    local skullTicks = player:getPlayerKillerEnd()
    local lastDay = 0
    local lastWeek = 0
    local lastMonth = 0
    local egibleMurders = 0
    local dayTimestamp = today - (24 * 60 * 60)
    local weekTimestamp = today - (7 * 24 * 60 * 60)
    local monthTimestamp = today - (30 * 24 * 60 * 60)
    
    local killsDayRedSkull = configManager.getNumber(configKeys.KILLS_DAY_RED_SKULL)
    local killsWeekRedSkull = configManager.getNumber(configKeys.KILLS_WEEK_RED_SKULL)
    local killsMonthRedSkull = configManager.getNumber(configKeys.KILLS_MONTH_RED_SKULL)
    
    local killsDayBanishment = configManager.getNumber(configKeys.KILLS_DAY_BANISHMENT)
    local killsWeekBanishment = configManager.getNumber(configKeys.KILLS_WEEK_BANISHMENT)
    local killsMonthBanishment = configManager.getNumber(configKeys.KILLS_MONTH_BANISHMENT)
    
    for _, timestamp in pairs(player:getMurderTimestamps()) do
        if timestamp > dayTimestamp then
            lastDay = lastDay + 1
        end
        
        if timestamp > weekTimestamp then
            lastWeek = lastWeek + 1
        end
        
        egibleMurders = lastMonth + 1
        
        if timestamp <= monthTimestamp then
            egibleMurders = lastMonth
        end
        
        lastMonth = egibleMurders
    end
    
    local message = ""
    
    message = message .. "\n"
        
    message = message .. "Last murders within 24 hours " .. lastDay .. "\n"
    message = message .. "Last murders within a week " .. lastDay .. "\n"
    message = message .. "Last murders within a month " .. lastDay .. "\n"
    
    message = message .. "\n"
    
    message = message .. "Players you may kill for a red skull:\n"
    message = message .. "- Within 24 hours " .. killsDayRedSkull - lastDay .. " murders.\n"
    message = message .. "- Within a week " .. killsWeekRedSkull - lastWeek .. " murders.\n"
    message = message .. "- Within a month " .. killsMonthRedSkull - lastDay .. " murders.\n"
        
    message = message .. "\n"
    
    message = message .. "Players you may kill for a banishment:\n"
    message = message .. "- Within 24 hours " .. killsDayBanishment - lastDay .. " murders.\n"
    message = message .. "- Within a week " .. killsWeekBanishment - lastWeek .. " murders.\n"
    message = message .. "- Within a month " .. killsMonthBanishment - lastDay .. " murders.\n"
            
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, message)
    return false
end
 
and you will need to change your talkaction kills for something like this:
LUA:
function onSay(player, words, param)
    if Game.getWorldType() == WORLD_TYPE_PVP_ENFORCED then
        player:showTextDialog(1998, "Your character has not murders history.", false)
        return false
    end
  
    local today = os.time()
    local skullTicks = player:getPlayerKillerEnd()
    local lastDay = 0
    local lastWeek = 0
    local lastMonth = 0
    local egibleMurders = 0
    local dayTimestamp = today - (24 * 60 * 60)
    local weekTimestamp = today - (7 * 24 * 60 * 60)
    local monthTimestamp = today - (30 * 24 * 60 * 60)
  
    local killsDayRedSkull = configManager.getNumber(configKeys.KILLS_DAY_RED_SKULL)
    local killsWeekRedSkull = configManager.getNumber(configKeys.KILLS_WEEK_RED_SKULL)
    local killsMonthRedSkull = configManager.getNumber(configKeys.KILLS_MONTH_RED_SKULL)
  
    local killsDayBanishment = configManager.getNumber(configKeys.KILLS_DAY_BANISHMENT)
    local killsWeekBanishment = configManager.getNumber(configKeys.KILLS_WEEK_BANISHMENT)
    local killsMonthBanishment = configManager.getNumber(configKeys.KILLS_MONTH_BANISHMENT)
  
    for _, timestamp in pairs(player:getMurderTimestamps()) do
        if timestamp > dayTimestamp then
            lastDay = lastDay + 1
        end
      
        if timestamp > weekTimestamp then
            lastWeek = lastWeek + 1
        end
      
        egibleMurders = lastMonth + 1
      
        if timestamp <= monthTimestamp then
            egibleMurders = lastMonth
        end
      
        lastMonth = egibleMurders
    end
  
    local message = ""
  
    message = message .. "\n"
      
    message = message .. "Last murders within 24 hours " .. lastDay .. "\n"
    message = message .. "Last murders within a week " .. lastDay .. "\n"
    message = message .. "Last murders within a month " .. lastDay .. "\n"
  
    message = message .. "\n"
  
    message = message .. "Players you may kill for a red skull:\n"
    message = message .. "- Within 24 hours " .. killsDayRedSkull - lastDay .. " murders.\n"
    message = message .. "- Within a week " .. killsWeekRedSkull - lastWeek .. " murders.\n"
    message = message .. "- Within a month " .. killsMonthRedSkull - lastDay .. " murders.\n"
      
    message = message .. "\n"
  
    message = message .. "Players you may kill for a banishment:\n"
    message = message .. "- Within 24 hours " .. killsDayBanishment - lastDay .. " murders.\n"
    message = message .. "- Within a week " .. killsWeekBanishment - lastWeek .. " murders.\n"
    message = message .. "- Within a month " .. killsMonthBanishment - lastDay .. " murders.\n"
          
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, message)
    return false
end
Ok fixed those errors, so now what about

1>..\src\player.cpp(2972): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2973): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2974): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2978): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2979): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2980): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(3955): error C2440: 'initializing': cannot convert from 'Database *' to 'Database &'


signed/unsigned

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!
}

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!
}

and what about database error

if (murderResult == 2) {
// banishment for too many unjustified kills
Database& db = Database::getInstance();

maybe it should be
Database db = Database::getInstance();
dunno
 
change Database& db for Database* db
Yea fixed all errors thanks. As far as i know warnings isnt bad but do you have an idea how to fix those unsigned? Since it makes source dirty
1>..\src\player.cpp(2972): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2973): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2974): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2978): warning C4018: '>=': signed/unsigned mismatch
1>..\src\player.cpp(2979): warning C4018: '>=': signed/unsigned mismatch
 
Back
Top