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

/save command doesn't work

Dorianek

Member
Joined
Nov 29, 2018
Messages
247
Reaction score
10
Location
Poland
The command does not work on tfs 1.2 8.6 can anyone help?

Lua:
local savingEvent = 0

function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end
    if(isNumber(param)) then
        stopEvent(savingEvent)
        save(tonumber(param) * 60 * 1000)
    else
        doSaveServer()
    end
    return true
end

function save(delay)
    doSaveServer()
    if(delay > 0) then
        savingEvent = addEvent(save, delay, delay)
    end
end
 
Try this:
Lua:
function onSay(player, words, param)
    if player:getAccountType() < 4 then return false end

    if param == "clean" then
        saveServer()
        cleanMap()
    else
        saveServer()
    end

    Game.broadcastMessage("Server is saving game.", MESSAGE_STATUS_WARNING)
end
If you need to save and clean the map, use /save "clean, else if you only need to save, use: /save
 
Last edited:
Your script is so messy you are trying to delay the save after attempting to do it with an incorrect function.

your script should be that way
Lua:
local savingEvent = 0

function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < 4 then
        return false
    end

    if (isNumber(param)) then
        stopEvent(savingEvent)
        save(tonumber(param) * 60 * 1000)
    else
        saveServer()
    end
    return true
end

function save(delay)
    if (delay > 0) then
        savingEvent = addEvent(function()
            saveServer()
        end, delay)
    end
end
 
Back
Top