Код
_TRACEBACK=debug.traceback
tProfiles = {
[0]="Администратор",
[1]="Модератор",
[2]="VIP",
[3]="Юзер",
[-1]="Гость"
}
function OnStartup()
sHelloMsg = LoadText(Core.sMainDir.."texts/motd.txt")
end
function LoadText(sFileWay)
local sMessage = ""
local sFile = io.open(sFileWay, "r" )
if sFile then
sMessage = sFile:read("*all")
sFile:close()
end
return sMessage
end
function DoShareUnits(iSize)
local tShareUnits = {"Б", "КБ", "МБ", "ГБ", "ТБ", "ПБ"}
local iTableSize = table.maxn(tShareUnits)
local iSize = tonumber(iSize)
local sUnits = ""
for iTablePos = 1, iTableSize do
if iSize < 1024 or iTablePos == iTableSize then
sUnits = tShareUnits[iTablePos]
break
else
iSize = iSize / 1024
end
end
local sSize = string.format("%0.2f %s", iSize, sUnits)
local sSize = string.gsub(sSize, "%.", ",")
local _,_, s1stChar, s2ndChar = string.find(sSize, "%d+,(%d)(%d)")
local s1stChar, s2ndChar = tonumber(s1stChar), tonumber(s2ndChar)
if s2ndChar == 0 then
sSize = string.gsub(sSize, ","..s1stChar..s2ndChar, ","..s1stChar)
if s1stChar == 0 then
sSize = string.gsub(sSize, ","..s1stChar, "")
end
end
return sSize
end
function OnUserEnter(tUser)
local sHelloMsg = sHelloMsg:gsub("%[(%S+)%]", {
onlineusers = Core.GetUsersCount(),
hubshare = DoShareUnits(Core.GetTotalShare()),
nick = tUser.sNick,
ip = tUser.sIP,
profile = tProfiles[tUser.iProfile],
port = tUser.iPortConn,
realport = tUser.iPort,
mac = tUser.sMacAddress,
--[[description = tUser.sDescription,
tag = tUser.sTag,
client = tUser.sClient,
clientversion = tUser.sClientVersion,
mode = tUser.sMode,
normalhubs = tUser.iNormalHubs,
reghubs = tUser.iRegHubs,
ophubs = tUser.iOpHubs,
hubs = tUser.iHubs,
slots = tUser.iSlots,
llimit = tUser.iLlimit,]]
})
Core.SendToUser(tUser,sHelloMsg,"Network")
end