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?
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
local function getPlayersOnline()
return Game.getPlayers()
end
sorry, tfs 0.4cant 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?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
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.
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?
Does doBroadcastMessage return a table ?
thank their codes in this forum are greatWhy use a loop?
You are just using more resources, if getPlayersOnline() returns a table then just check the size of the return value.
Could of used doBroadcastMessage but what would be the point if there is no one online to see it.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