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

Lua Warn to gods when a player log in to the game

Jeyci

Banned User
Joined
May 6, 2023
Messages
289
Solutions
3
Reaction score
36
Hello,
would like to request an script that warns or send a message to the gods or gamemaster when a player has logged in to the game, sending the player name in the default channel

i use tfs 1.5 protocol 8.6
 
Solution
Hello,
would like to request an script that warns or send a message to the gods or gamemaster when a player has logged in to the game, sending the player name in the default channel

i use tfs 1.5 protocol 8.6
Lua:
onlineMods = onlineMods or {}

local cLogin = CreatureEvent("weON")
function cLogin.onLogin(player)
  if player:getAccountType() >= ACCOUNT_TYPE_GAMEMASTER then
    onlineMods[player:getName()] = true
  else
    local msg = ('%s has logged in.'):format(player:getName())
    for name, _ in pairs(onlineMods) do
      local p = Player(name)
      if p then
        p:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE,msg)
      end
    end
  end
  return true
end
cLogin:register()
Hello,
would like to request an script that warns or send a message to the gods or gamemaster when a player has logged in to the game, sending the player name in the default channel

i use tfs 1.5 protocol 8.6
Lua:
onlineMods = onlineMods or {}

local cLogin = CreatureEvent("weON")
function cLogin.onLogin(player)
  if player:getAccountType() >= ACCOUNT_TYPE_GAMEMASTER then
    onlineMods[player:getName()] = true
  else
    local msg = ('%s has logged in.'):format(player:getName())
    for name, _ in pairs(onlineMods) do
      local p = Player(name)
      if p then
        p:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE,msg)
      end
    end
  end
  return true
end
cLogin:register()
 
Solution
Lua:
onlineMods = onlineMods or {}

local cLogin = CreatureEvent("weON")
function cLogin.onLogin(player)
  if player:getAccountType() >= ACCOUNT_TYPE_GAMEMASTER then
    onlineMods[player:getName()] = true
  else
    local msg = ('%s has logged in.'):format(player:getName())
    for name, _ in pairs(onlineMods) do
      local p = Player(name)
      if p then
        p:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE,msg)
      end
    end
  end
  return true
end
cLogin:register()
thank, it works. but it warns to players that are in gamemaster account too. would be possible to change this

if player:getAccountType() >= ACCOUNT_TYPE_GAMEMASTER then for something like if character is gamemaster? and not the whole acc
 
thank, it works. but it warns to players that are in gamemaster account too. would be possible to change this

if player:getAccountType() >= ACCOUNT_TYPE_GAMEMASTER then for something like if character is gamemaster? and not the whole acc

registerEnum(ACCOUNT_TYPE_NORMAL)
registerEnum(ACCOUNT_TYPE_TUTOR)
registerEnum(ACCOUNT_TYPE_SENIORTUTOR)
registerEnum(ACCOUNT_TYPE_GAMEMASTER)
registerEnum(ACCOUNT_TYPE_COMMUNITYMANAGER)
registerEnum(ACCOUNT_TYPE_GOD)
 
thank, it works. but it warns to players that are in gamemaster account too. would be possible to change this

if player:getAccountType() >= ACCOUNT_TYPE_GAMEMASTER then for something like if character is gamemaster? and not the whole acc
Yes,

 
Lua:
onlineMods = onlineMods or {}

local cLogin = CreatureEvent("weON")
function cLogin.onLogin(player)
  if player:getGroup():getAccess() then
    onlineMods[player:getName()] = true
  else
    local msg = ('%s has logged in.'):format(player:getName())
    for name, _ in pairs(onlineMods) do
      local p = Player(name)
      if p then
        p:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE,msg)
      end
    end
  end
  return true
end
cLogin:register()
 
Something like this (untested):
Lua:
local mods = {}
local minAccountType = ACCOUNT_TYPE_GAMEMASTER
local minGroup = 3

local cLogin = CreatureEvent("weON")
function cLogin.onLogin(player)
    if player:getAccountType() >= minAccountType and player:getGroup():getId() >= minGroup then
        mods[player:getName()] = true
    else
        local msg = ('%s has logged in.'):format(player:getName())
        for modName, _ in pairs(mods) do
            local mod = Player(modName)
            if not mod then
                mods[modName] = nil
            else
                mod:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, msg)  
            end
        end
    end
    return true
end
cLogin:register()
* Not sure if enumerators exist for group ID's
 
Last edited:
Something like this (untested):
Lua:
local mods = {}
local minAccountType = ACCOUNT_TYPE_GAMEMASTER
local minGroup = 3

local cLogin = CreatureEvent("weON")
function cLogin.onLogin(player)
    if player:getAccountType() >= minAccountType and player:getGroup():getId() >= minGroup then
        mods[player:getName()] = true
    else
        local msg = ('%s has logged in.'):format(player:getName())
        for modName, _ in pairs(mods) do
            local mod = Player(modName)
            if not mod then
                mods[modName] = nil
            else
                mod:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, msg) 
            end
        end
    end
    return true
end
cLogin:register()
* Not sure if enumerators exist for group ID's
not working :( but gonna use pips one's no worries, thank you all guys
 
Back
Top