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

TFS 1.X+ Problem with serversave globalevent

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
921
Location
Chile
Hello guys, im using tfs 1.3 and i have the default serversave from original tfs, but there's a small issue for me
i need the script to kick all players just after the game was saved, and someone told me that this script already kicks players when it's executed (altho i dont know in wich moment it kicks players)
anyway, this script doesn't kick players in any moment :/ so what might be failing? or how can i achieve what i need?

Also a kick durring the whole warning process wouldn't be what i need, cos ppl wont be able to login during that process wich last a couple of minutes >.<

thanks in advance!!

Code:
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('El juego hara save en 1 minuto. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    addEvent(serverSave, 60000)
end

local function firstServerSaveWarning()
    Game.broadcastMessage('El juego hara save en 3 minutos. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    addEvent(secondServerSaveWarning, 120000)
end

function onTime(interval)
    Game.broadcastMessage('El juego hara save en 5 minutos. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    Game.setGameState(GAME_STATE_STARTUP)
    addEvent(firstServerSaveWarning, 120000)
    return not shutdownAtServerSave
end
 
Solution
Code:
local cleanMapAtServerSave = false
local function serverSave()
    if cleanMapAtServerSave then
        cleanMap()
    end
    Game.setGameState(GAME_STATE_CLOSED) --don't need to use saveserver because this do the work
    Game.setGameState(GAME_STATE_NORMAL)
end
local function secondServerSaveWarning()
    Game.broadcastMessage('El juego hara save en 1 minuto. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    addEvent(serverSave, 60000)
end
local function firstServerSaveWarning()
    Game.broadcastMessage('El juego hara save en 3 minutos. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    addEvent(secondServerSaveWarning, 120000)
end
function onTime(interval)
    Game.broadcastMessage('El juego hara save...
Lua:
local shutdownAtServerSave = true
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('El juego hara save en 1 minuto. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    addEvent(serverSave, 60000)
end
local function firstServerSaveWarning()
    Game.broadcastMessage('El juego hara save en 3 minutos. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    addEvent(secondServerSaveWarning, 120000)
end
function onTime(interval)
    Game.broadcastMessage('El juego hara save en 5 minutos. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    Game.setGameState(GAME_STATE_STARTUP)
    addEvent(firstServerSaveWarning, 120000)
    return not shutdownAtServerSave
end
 
Lua:
local shutdownAtServerSave = true
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('El juego hara save en 1 minuto. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    addEvent(serverSave, 60000)
end
local function firstServerSaveWarning()
    Game.broadcastMessage('El juego hara save en 3 minutos. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    addEvent(secondServerSaveWarning, 120000)
end
function onTime(interval)
    Game.broadcastMessage('El juego hara save en 5 minutos. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    Game.setGameState(GAME_STATE_STARTUP)
    addEvent(firstServerSaveWarning, 120000)
    return not shutdownAtServerSave
end
that doesnt kick the players, it terminates the server :/
 
ain't that the same?
Yes, is the same.
check in your game.cpp

C++:
case GAME_STATE_SHUTDOWN: {

            g_globalEvents->execute(GLOBALEVENT_SHUTDOWN);
            //kick all players that are still online
            auto it = players.begin();
            while (it != players.end()) {
                it->second->kickPlayer(true);
                it = players.begin();
            }

            saveMotdNum();
            saveGameState();

            g_dispatcher.addTask(
                createTask(std::bind(&Game::shutdown, this)));

            g_scheduler.stop();
            g_databaseTasks.stop();
            g_dispatcher.stop();
            break;
        }
 
Yes, is the same.
check in your game.cpp

C++:
case GAME_STATE_SHUTDOWN: {

            g_globalEvents->execute(GLOBALEVENT_SHUTDOWN);
            //kick all players that are still online
            auto it = players.begin();
            while (it != players.end()) {
                it->second->kickPlayer(true);
                it = players.begin();
            }

            saveMotdNum();
            saveGameState();

            g_dispatcher.addTask(
                createTask(std::bind(&Game::shutdown, this)));

            g_scheduler.stop();
            g_databaseTasks.stop();
            g_dispatcher.stop();
            break;
        }
i see it says kick all players online, but in my case it's making a shutdown of the server, where can i find that? altho i have default tfs 1.3, shouldnt be wrong :S
 
i see it says kick all players online, but in my case it's making a shutdown of the server, where can i find that? altho i have default tfs 1.3, shouldnt be wrong :S

This make a shutdown, so what you need? No shutdown and save anyway?
 
No shutdown, only save with a mass kick, only kick players, not a server shutdown
like /closeserver
 
Code:
local cleanMapAtServerSave = false
local function serverSave()
    if cleanMapAtServerSave then
        cleanMap()
    end
    Game.setGameState(GAME_STATE_CLOSED) --don't need to use saveserver because this do the work
    Game.setGameState(GAME_STATE_NORMAL)
end
local function secondServerSaveWarning()
    Game.broadcastMessage('El juego hara save en 1 minuto. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    addEvent(serverSave, 60000)
end
local function firstServerSaveWarning()
    Game.broadcastMessage('El juego hara save en 3 minutos. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    addEvent(secondServerSaveWarning, 120000)
end
function onTime(interval)
    Game.broadcastMessage('El juego hara save en 5 minutos. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    Game.setGameState(GAME_STATE_STARTUP)
    addEvent(firstServerSaveWarning, 120000)
    return not shutdownAtServerSave
end
Should work as you want.
 
Solution
Code:
local cleanMapAtServerSave = false
local function serverSave()
    if cleanMapAtServerSave then
        cleanMap()
    end
    Game.setGameState(GAME_STATE_CLOSED) --don't need to use saveserver because this do the work
    Game.setGameState(GAME_STATE_NORMAL)
end
local function secondServerSaveWarning()
    Game.broadcastMessage('El juego hara save en 1 minuto. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    addEvent(serverSave, 60000)
end
local function firstServerSaveWarning()
    Game.broadcastMessage('El juego hara save en 3 minutos. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    addEvent(secondServerSaveWarning, 120000)
end
function onTime(interval)
    Game.broadcastMessage('El juego hara save en 5 minutos. Procura estar en una zona segura.', MESSAGE_STATUS_WARNING)
    Game.setGameState(GAME_STATE_STARTUP)
    addEvent(firstServerSaveWarning, 120000)
    return not shutdownAtServerSave
end
Should work as you want.
Thank you man it worked perfectly!!
 
Back
Top