• 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 TFS 1.2 Player kill w/o frag

Hernest

New Member
Joined
Jul 26, 2010
Messages
152
Reaction score
3
Location
poland
Hello, can somebody help me with it? I want to do something like: when globalstorage == 1 then player kill is not adding a frag, something like killing without consequences. There is any short way to do it?
 
You could try adding this to player, its just a conversion of the internal addUnjustifiedDead from c++ to lua.
Code:
function Player:addUnjustifiedDead(attacked)

    if getPlayerFlagValue(self, PlayerFlag_NotGainInFight) or attacked == self or Game.getWorldType() == WORLD_TYPE_PVP_ENFORCED then
        return
    end
    -- storage value to prevent a frag
    if attacked:getStorageValue(123456) == 1 then
        return
    end

    self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Warning! The murder of " .. attacked:getName() .. " was not justified.")

    local skullTicks = configManager.getNumber(configKeys.FRAG_TIME)

    if (self:getSkull() != SKULL_BLACK) then
        if (configManager.getNumber(configKeys.KILLS_TO_BLACK)) != 0 and (skullTicks > (configManager.getNumber(configKeys.KILLS_TO_BLACK) - 1) * (configManager.getNumber(configKeys.FRAG_TIME))) then
            self:setSkull(SKULL_BLACK)
        elseif self:getSkull() != SKULL_RED and configManager.getNumber(configKeys.KILLS_TO_RED) != 0 and skullTicks > (configManager.getNumber(configKeys.KILLS_TO_RED) - 1) * configManager.getNumber(configKeys.FRAG_TIME) then
            self:setSkull(SKULL_RED)
        end
    end
    return
end
 
Last edited:
In creaturescripts, there should already be a playerdeath.lua and if I am not mistaken, it handles frags by adding the players death to the database with a timestamp of when that player was killed.
I guess the simple way would be while globalstorage is set to 1 then default `unjustified` in the querry to 0

Example:
Old: (unjustified and 1 or 0)

New: ((unjustified and globalstorage <= 0 and 1) or 0)
 
Back
Top