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

Clean map when it reaches 0 players online

Morcega Negra

Banned User
Joined
Aug 4, 2015
Messages
102
Solutions
1
Reaction score
8
Does anyone know if you can perform a script that gives clean on the map, if the server goes with 0 players online? or clean in only a particular item?
 
cant give a 100% working script since u dont said what distro version blablabla u are using
so i m giving general tips
PHP:
function onLogout(player)

    local i = -1

    for _, cid in ipairs(getPlayersOnline()) do
        i = i +1
    end

    if i < 1 then
        doCleanMap()    //    cleanMap()
    end


    return true
end

if getplayersonline fail add this before

PHP:
local function getPlayersOnline()
    return Game.getPlayers()
end
 
cant give a 100% working script since u dont said what distro version blablabla u are using
so i m giving general tips
PHP:
function onLogout(player)

    local i = -1

    for _, cid in ipairs(getPlayersOnline()) do
        i = i +1
    end

    if i < 1 then
        doCleanMap()    //    cleanMap()
    end


    return true
end

if getplayersonline fail add this before

PHP:
local function getPlayersOnline()
    return Game.getPlayers()
end
sorry, tfs 0.4
 
cant give a 100% working script since u dont said what distro version blablabla u are using
so i m giving general tips
PHP:
function onLogout(player)

    local i = -1

    for _, cid in ipairs(getPlayersOnline()) do
        i = i +1
    end

    if i < 1 then
        doCleanMap()    //    cleanMap()
    end


    return true
end

if getplayersonline fail add this before

PHP:
local function getPlayersOnline()
    return Game.getPlayers()
end
Why use a loop?
You are just using more resources, if getPlayersOnline() returns a table then just check the size of the return value.
Code:
function onLogout(player)
    if #getPlayersOnline() < 1 then
        -- this is so you can see it in the console
        print("Since no one is online start cleaning the map.")
        doCleanMap() 
    end
    return true
end
Could of used doBroadcastMessage but what would be the point if there is no one online to see it.
 
Last edited:

Does doBroadcastMessage return a table ?
No.. sigh.. I used print() to print to the console as a notification that the script executed, doBroadcastMessage would also print to the console but it would display to all players online, however since the goal is to clean the map when the last player logs out then what would be the point of using doBroadcastMessage if no one were online to see it?
 
Why use a loop?
You are just using more resources, if getPlayersOnline() returns a table then just check the size of the return value.
Code:
function onLogout(player)
    if #getPlayersOnline() < 1 then
        -- this is so you can see it in the console
        print("Since no one is online start cleaning the map.")
        doCleanMap()
    end
    return true
end
Could of used doBroadcastMessage but what would be the point if there is no one online to see it.
thank their codes in this forum are great
 
Back
Top