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

GlobalEvent Server Autoinfo <uptime, players>

hodleo

Formerly cbrm -Crypto enthusiast, Retired scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,598
Solutions
3
Reaction score
955
Location
Caribbean Sea
Well I was bored and made this easy script out of tfs uptime talkaction
What does it do? Simple. Every xx minutes(mine is 25m) a message is broadcasted displaying the server uptime and the amount the players online.
You may use it to broadcast any message if you modify it correctly.:thumbup:

If there is nobody online it'll print: "Nobody Online"
If there is just 1 player it'll print: "1 player online"
If there is more than 1 player online it'll print: "xx players online"
GlobalEvents TimeCalc Example: <!--1500seconds = [[25minutes]] x 60s-->
[26/10/2009 16:20:32] > Broadcast: "Server Info: 0 hours and 10 minutes online, Nobody online."

add line
@data/globalevents/globalevents.xml
Lua:
 <globalevent name="autoinfo" interval="1500" event="script" value="autoinfo.lua"/> <!--1500s = [25m] x 60s-->

create script @ data/globalevents/scripts/autoinfo.lua
Lua:
-- >>> AutoServer Info Script by Cybermaster <<< --
function onThink(interval, lastExecution)

local hours = math.ceil(getWorldUpTime() / 3600) - 1
local minutes = math.ceil((getWorldUpTime() - (3600 * hours)) / 60)
if minutes == 60 then minutes, hours = 0, hours + 1 end

local c, players = getWorldCreatures(0), ""
    if c < 1 then
        return true
    elseif c == 1 then
        players = "1 player online."
    elseif c > 1 then
        players = c..' players online.'
    end
    doBroadcastMessage('[ServerInfo] '..hours..' hours and '..minutes..' minutes online, '..players..'', 23)
    return true
end
 
Last edited:
rofl?
uhm rep plz?
 
Why it will broadcast "Nobody online", if nobody will se it?
lol maybe hoster wants to know it?
I'll add a paralel script that doesn't broadcast in the gui/console, just to players
 
Last edited:
You can use:
Code:
players = getWorldCreatures(0).. ' players online.'

instead of:
Code:
players = ''..getWorldCreatures(0)..' players online.'
 
You can use:
Code:
players = getWorldCreatures(0).. ' players online.'

instead of:
Code:
players = ''..getWorldCreatures(0)..' players online.'

He can use..
Lua:
players = c..' players online.'

instead of:
Code:
players = ''..getWorldCreatures(0)..' players online.'
 
Not tested
Code:
  -- >>> Server AutoInfo Script by Cybermaster <<< --
function onThink(interval, lastExecution)
    local hours = math.ceil(getWorldUpTime() / 3600) - 1
    local minutes = math.ceil((getWorldUpTime() - (3600 * hours)) / 60)
    if minutes == 60 then
        minutes, hours = 0, hours + 1
    end
    local c = getWorldCreatures(0)
    players = (c < 1 and "Nobody" or getWorldCreatures(0) .. "player") .. (c <= 1 and "" or "s") .. " online."
    doBroadcastMessage("[ServerInfo] " .. hours .. " hour" .. (hours == 1 and "" or "s") .. " and " .. minutes .. " minute" .. (minutes == 1 and "" or "s") .. " online, " .. players, 23)
    return true
end
 
Last edited:
Code:
local names = {[0] = "Nobody Online", "1 player online.", " players online}
local c = getWorldCreatures(0)
players = (c  > 1 and c..names[c] or names[c])
 
Can you make this with only that it will brodcast a massage. (what i whant ) ex. Botters will be banned

Rep++ of i get help
 
and the shortest

Code:
local uptime, players = getWorldUptime(), getWorldCreatures(0)
local hours, minutes = math.floor(uptime / 3600), math.floor((uptime % 3600) / 60) 
doBroadcastMessage("[ServerInfo] " .. hours .. " hour" .. (hours == 1 and "" or "s") .. " and " .. minutes .. " minute" .. (minutes == 1 and "" or "s") .. " online, " .. (c < 1 and "Nobody" or (c .. "player" .. (c > 1 and "s" or ""))) .. " online.", 23)
return true

:peace:
 
Last edited:
and the shortest

Code:
local uptime, players = getWorldUptime(), getWorldCreatures(0)
local hours, minutes = math.floor(uptime / 3600), math.floor((uptime % 3600) / 60) 
doBroadcastMessage("[ServerInfo] " .. hours .. " hour" .. (hours == 1 and "" or "s") .. " and " .. minutes .. " minute" .. (minutes == 1 and "" or "s") .. " online, " .. (c < 1 and "Nobody" or (c .. "player" .. (c > 1 and "s" or ""))) .. " online.", 23)
return true

:peace:
ehehehe elfystyled
 
and the shortest

Code:
local uptime, players = getWorldUptime(), getWorldCreatures(0)
local hours, minutes = math.floor(uptime / 3600), math.floor((uptime % 3600) / 60) 
doBroadcastMessage("[ServerInfo] " .. hours .. " hour" .. (hours == 1 and "" or "s") .. " and " .. minutes .. " minute" .. (minutes == 1 and "" or "s") .. " online, " .. (c < 1 and "Nobody" or (c .. "player" .. (c > 1 and "s" or ""))) .. " online.", 23)
return true
:peace:
Nice 0.o
 
Aff

Code:
[04/01/2010 22:02:35] [Error - LuaScriptInterface::loadFile] data/globalevents/scripts/autoinfo.lua:6: '<eof>' expected near 'end'
[04/01/2010 22:02:35] [Warning - Event::loadScript] Cannot load script (data/globalevents/scripts/autoinfo.lua)
[04/01/2010 22:02:35] data/globalevents/scripts/autoinfo.lua:6: '<eof>' expected near 'end'
 
Back
Top