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

Auto map clean script

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
870
Solutions
2
Reaction score
49
Hello i cant find anywhere auto map clean that happens every 2hours and puts warning before map is cleaned. It should remove items and corpses from map but no items from houses. TFS 1.2
 
Solution
Hello i cant find anywhere auto map clean that happens every 2hours and puts warning before map is cleaned. It should remove items and corpses from map but no items from houses. TFS 1.2

Lua:
local function cleanMapTimer(clean)
    if not clean then
        broadcastMessage("Map clean in 2 minutes. Be aware, there may be some lag.", MESSAGE_STATUS_WARNING)
        addEvent(cleanMapTimer, 2 * 60 * 1000, true)
    else
        cleanMap()
        broadcastMessage("Map cleaned.", MESSAGE_STATUS_WARNING)
    end
end

function onThink(interval, lastExecution)
    broadcastMessage("Map clean in 5 minutes.", MESSAGE_STATUS_WARNING)
    addEvent(cleanMapTimer, 3 * 60 * 1000, false)
    return true
end
Hello i cant find anywhere auto map clean that happens every 2hours and puts warning before map is cleaned. It should remove items and corpses from map but no items from houses. TFS 1.2

Lua:
local function cleanMapTimer(clean)
    if not clean then
        broadcastMessage("Map clean in 2 minutes. Be aware, there may be some lag.", MESSAGE_STATUS_WARNING)
        addEvent(cleanMapTimer, 2 * 60 * 1000, true)
    else
        cleanMap()
        broadcastMessage("Map cleaned.", MESSAGE_STATUS_WARNING)
    end
end

function onThink(interval, lastExecution)
    broadcastMessage("Map clean in 5 minutes.", MESSAGE_STATUS_WARNING)
    addEvent(cleanMapTimer, 3 * 60 * 1000, false)
    return true
end
 
Solution
Hello i cant find anywhere auto map clean that happens every 2hours and puts warning before map is cleaned. It should remove items and corpses from map but no items from houses. TFS 1.2

You could use this aswell, saves the map and cleans it aswell if you change 'false' to 'true'

Lua:
local shutdownAtServerSave = false
local cleanMapAtServerSave = false

local function serverSave()
    if shutdownAtServerSave then
        Game.setGameState(GAME_STATE_SHUTDOWN)
    else
        Game.setGameState(GAME_STATE_NORMAL)
    end

    if cleanMapAtServerSave then
        cleanMap()
    end

    saveServer()
end

local function secondServerSaveWarning()
    Game.broadcastMessage('Server is saving game in one minute. Please go to a safe place.', MESSAGE_STATUS_WARNING)
    addEvent(serverSave, 60000)
end

local function firstServerSaveWarning()
    Game.broadcastMessage('Server is saving game in 3 minutes. Please go to a safe place.', MESSAGE_STATUS_WARNING)
    addEvent(secondServerSaveWarning, 120000)
end

function onTime(interval)
    Game.broadcastMessage('Server is saving game in 5 minutes. Please go to a safe place.', MESSAGE_STATUS_WARNING)
    Game.setGameState(GAME_STATE_STARTUP)
    addEvent(firstServerSaveWarning, 120000)
    return not shutdownAtServerSave
end
 
Lua:
local function cleanMapTimer(clean)
    if not clean then
        broadcastMessage("Map clean in 2 minutes. Be aware, there may be some lag.", MESSAGE_STATUS_WARNING)
        addEvent(cleanMapTimer, 2 * 60 * 1000, true)
    else
        cleanMap()
        broadcastMessage("Map cleaned.", MESSAGE_STATUS_WARNING)
    end
end

function onThink(interval, lastExecution)
    broadcastMessage("Map clean in 5 minutes.", MESSAGE_STATUS_WARNING)
    addEvent(cleanMapTimer, 3 * 60 * 1000, false)
    return true
end
Is it in globalevents?
You could use this aswell, saves the map and cleans it aswell if you change 'false' to 'true'

Lua:
local shutdownAtServerSave = false
local cleanMapAtServerSave = false

local function serverSave()
    if shutdownAtServerSave then
        Game.setGameState(GAME_STATE_SHUTDOWN)
    else
        Game.setGameState(GAME_STATE_NORMAL)
    end

    if cleanMapAtServerSave then
        cleanMap()
    end

    saveServer()
end

local function secondServerSaveWarning()
    Game.broadcastMessage('Server is saving game in one minute. Please go to a safe place.', MESSAGE_STATUS_WARNING)
    addEvent(serverSave, 60000)
end

local function firstServerSaveWarning()
    Game.broadcastMessage('Server is saving game in 3 minutes. Please go to a safe place.', MESSAGE_STATUS_WARNING)
    addEvent(secondServerSaveWarning, 120000)
end

function onTime(interval)
    Game.broadcastMessage('Server is saving game in 5 minutes. Please go to a safe place.', MESSAGE_STATUS_WARNING)
    Game.setGameState(GAME_STATE_STARTUP)
    addEvent(firstServerSaveWarning, 120000)
    return not shutdownAtServerSave
end
I dont really like game shutdowns its kinda annoying
 
Nice then. How do i need to install it does it goes in globlalevent or events or global.lua?
Both are globalevents. Add this into your global and name the script clean_map.lua. Intervals in globalevents are in milliseconds so 1000 = 1 second. This is for 2 hours:
XML:
<globalevent name="Clean Map" interval="7200000" script="clean_map.lua" />

If you want to use bybbzan's code you need to change:
Lua:
function onTime(interval)
to
Lua:
function onThink(interval, lastExecution)
 
Both are globalevents. Add this into your global and name the script clean_map.lua. Intervals in globalevents are in milliseconds so 1000 = 1 second. This is for 2 hours:
XML:
<globalevent name="Clean Map" interval="7200000" script="clean_map.lua" />

If you want to use bybbzan's code you need to change:
Lua:
function onTime(interval)
to
Lua:
function onThink(interval, lastExecution)
I will use yours. Btw is true that it might lag server or its a bait? ;D
 
Back
Top