PtokaX forum

Archive => Archived 5.1 boards => Help with scripts => Topic started by: nEgativE on 30 August, 2006, 21:41:07

Title: [Request] Onjoin Script Convertion to L5.1
Post by: nEgativE on 30 August, 2006, 21:41:07
Hi there, could someone convert this script to L5.1 please.. i tried with Mutor's app.. but with no success :(
Thx in advance.



--> http://board.univ-angers.fr
--> Made by plop
--> Functions by nErBoS, [BR]Carlos
--> Convertion Lua5 by Jelf and heavily optimized by jiten

Bot = frmHub:GetHubBotName()
sChatBot = frmHub:GetOpChatName()

ALLUSERS={}
LEVELS = {["-1"]=0, ["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0, ["4"]=0, ["5"]=0, ["6"]=0, ["7"]=0, ["8"]=0, ["9"]=0, ["10"]=0, ["11"]=0, ["12"]=0}

Stat = {
uptime = 0,
share = 0,
users = 0,
}

sec = 1000
min = 60*sec

function ChatArrival(user, data)
if ALLUSERS[user.sName]==nil then ALLUSERS[user.sName]=1 LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1 end
s,e,cmd= string.find(data, "%b<>%s+(%S+)")
local commands = {
["!addreguser"]=1,
["!delreguser"]=1
}
if cmd ~= nil and commands[cmd] then SetTimer(5*1000) StartTimer() end
end

function NewUserConnected(user)
local usrshare = user.iShareSize
if loadfile("../logs/records.log") then
dofile("../logs/records.log")
local uptime,share,users = Stat["uptime"],Stat["share"],Stat["users"]
if (users < frmHub:GetUsersCount()) then Stat.users = frmHub:GetUsersCount() else Stat.users = users end
if share < frmHub:GetCurrentShareAmount() then Stat.share = frmHub:GetCurrentShareAmount() else Stat.share = share end
if uptime < frmHub:GetUpTime() then Stat.uptime = frmHub:GetUpTime() else Stat.uptime = uptime end
SaveToFile("../logs/records.log" , Stat , "Stat")
else
if (Stat.users < frmHub:GetUsersCount()) then Stat.users = frmHub:GetUsersCount() end
if Stat.share < frmHub:GetCurrentShareAmount() then Stat.share = frmHub:GetCurrentShareAmount() end
Stat.uptime = frmHub:GetUpTime()
SaveToFile("../logs/records.log" , Stat , "Stat")
end
if ALLUSERS[user.sName]==nil then ALLUSERS[user.sName]=1 LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1 end
Message(user)
end

OpConnected = NewUserConnected

function UserDisconnected(user)
if ALLUSERS[user.sName] then
ALLUSERS[user.sName]=nil
if LEVELS[tostring(user.iProfile)] > 0 then
LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
end
end
end

OpDisconnected = UserDisconnected

function Message(user)
local tmp,share,SC,hubshare,ttshare = "",user.iShareSize,os.clock(),frmHub:GetCurrentShareAmount(),tonumber(Stat.share)
local days,hours,minutes = math.floor(Stat.uptime/43200, 30), math.floor(math.mod(Stat.uptime/1440, 24)), math.floor(math.mod(Stat.uptime/60, 60))
if share == nil then
share = 0
end
if user.sMode == "A" then
tmp = "Activo"
elseif user.sMode == "P" then
tmp = "Passivo"
elseif user.sMode == "5" then
tmp = "Socks5"
SendPmToOps(sChatBot,"-?--- Utilizador: "..user.sName..", est? a usar o Cliente DC em Modo: "..(user.sMode or "Indispon?vel").." - IP: "..(user.sIP or "Indispon?vel").."")
else tmp = "Desconhe?ido"
SendPmToOps(sChatBot,"-?--- Utilizador: "..user.sName..", est? a usar o Cliente DC em Modo: "..(user.sMode or "Desconhe?ido").." - IP: "..(user.sIP or "Indispon?vel").."")
end
user:SendData("            -?--- Ligado: "..(user.iHubs or "0").." Hub's - Com registo: "..(user.iRegHubs or "0").." - Como Operador: "..(user.iOpHubs or "0").." ---?-")
user:SendData("            -?--- Partilha: "..rightSize( tonumber(share) ).." - Status: "..(GetProfileName(user.iProfile) or "Sem registo").." - Password: "..(frmHub:GetUserPassword(user.sName) or "Sem Password").." ---?-")
user:SendData("            -?--- Cliente: "..(user.sClient or "Indispon?vel").." - Vers?o: "..(user.sClientVersion or "Indispon?vel").." - Modo: "..tmp.." - Slot's: "..(user.iSlots or "0").." - Liga??o: "..(user.sConnection or "Indispon?vel").." ---?-")
user:SendData("      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
user:SendData("      =-=-= "..frmHub:GetHubName().." =-=-=")
user:SendData(" ")
user:SendData("            -?--- Partilha: "..rightSize( tonumber(hubshare) ) .." --?-- Lista de Comandos: !ajuda - !help ---?-")
user:SendData("            -?--- Uptime: " ..math.floor(SC/86400).." dia's "..math.floor(math.mod(SC/3600,24)).." hora's e "..math.floor(math.mod(SC/60,60)).." minuto's --?-- "..os.date().." ---?-")
user:SendData("            -?--- Online --?-- OP's: "..getOn(0) + getOn(1) + getOn(2).." - Moderadores: "..getOn(3).." - ViP's: "..getOn(4).." - [G*]: "..getOn(6) + getOn(7) + getOn(8) + getOn(9) + getOn(10).." - Membros: "..getOn(5) + getOn(6) + getOn(7) + getOn(8) + getOn(9) + getOn(10).." - Total: "..(frmHub:GetUsersCount()).." ---?-")
user:SendData("            -?--- Registos --?-- OP's: "..getAll(0) + getAll(1) + getAll(2).." - Moderadores: "..getAll(3).." - ViP's: "..getAll(4).." - Membros: "..getAll(5) + getAll(6) + getAll(7) + getAll(8) + getAll(9) + getAll(10).." ---?-")
user:SendData("            -?--- Registos --?-- laptop@: "..getAll(11).." - work@: "..getAll(12).." - [G*]: "..getAll(6) + getAll(7) + getAll(8) + getAll(9) + getAll(10).." - Total: "..table.getn(frmHub:GetRegisteredUsers()).." ---?-")
user:SendData("            -?--- Recordes --?-- Partilha: "..rightSize( tonumber(ttshare) ).." - Utilizadores: "..Stat.users.." - Uptime: "..days.." dia's ---?-")
user:SendData("      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
user:SendData("      =-=-= T?pico =-=-=")
user:SendData(" ")
user:SendData("      =-=-=-= "..(frmHub:GetHubTopic() or "Indispon?vel").." =-=-=-=")
user:SendData("      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
user:SendData(" ")
end

function getOn(p)
local r,t = frmHub:GetOnlineRegUsers(),0
for i,nick in r do
if nick.iProfile == p then
t = t + 1
end
end
return t
end

function getAll(p)
local r = table.getn(GetUsersByProfile(GetProfileName(p)))
return r
end

function rightSize(intSize)
if intSize ~= 0 then
local tUnits = { "Bytes", "KiB", "MiB", "GiB", "TiB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, table.getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else 
intSize = intSize / 1024;
end
end
return string.format("%0.1f %s",intSize, sUnits);
else
return "0 Bytes"
end
end

function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.." = {\n"
for key, value in tTable do
                local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
                if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
                else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end

function SaveToFile(file , table , tablename)
local handle = io.open(file,"w+")
handle:write(Serialize(table, tablename))
handle:flush()
handle:close()
end

Title: Re: [Request] Onjoin Script Convertion to L5.1
Post by: Madman on 31 August, 2006, 00:37:43


--> http://board.univ-angers.fr
--> Made by plop
--> Functions by nErBoS, [BR]Carlos
--> Convertion Lua5 by Jelf and heavily optimized by jiten

Bot = frmHub:GetHubBotName()
sChatBot = frmHub:GetOpChatName()

ALLUSERS={}
LEVELS = {["-1"]=0, ["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0, ["4"]=0, ["5"]=0, ["6"]=0, ["7"]=0, ["8"]=0, ["9"]=0, ["10"]=0, ["11"]=0, ["12"]=0}

Stat = {
uptime = 0,
share = 0,
users = 0,
}

sec = 1000
min pairs(= 60*sec

function ChatArrival(user, data)
if ALLUSERS[user.sName]==nil then ALLUSERS[user.sName]=1 LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1 end
s,e,cmd= string.find(data, "%b<>%s+(%S+)")
local commands = {
["!addreguser"]=1,
["!delreguser"]=1
}
if cmd ~= nil and commands[cmd] then SetTimer(5*1000) StartTimer() end
end

function NewUserConnected(user)
local usrshare = user.iShareSize
if loadfile("../logs/records.log") then
dofile("../logs/records.log")
local uptime,share,users = Stat["uptime"],Stat["share"],Stat["users"]
if (users < frmHub:GetUsersCount()) then Stat.users = frmHub:GetUsersCount() else Stat.users = users end
if share < frmHub:GetCurrentShareAmount() then Stat.share = frmHub:GetCurrentShareAmount() else Stat.share = share end
if uptime < frmHub:GetUpTime() then Stat.uptime = frmHub:GetUpTime() else Stat.uptime = uptime end
SaveToFile("../logs/records.log" , Stat , "Stat")
else
if (Stat.users < frmHub:GetUsersCount()) then Stat.users = frmHub:GetUsersCount() end
if Stat.share < frmHub:GetCurrentShareAmount() then Stat.share = frmHub:GetCurrentShareAmount() end
Stat.uptime = frmHub:GetUpTime()
SaveToFile("../logs/records.log" , Stat , "Stat")
end
if ALLUSERS[user.sName]==nil then ALLUSERS[user.sName]=1 LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1 end
Message(user)
end

OpConnected = NewUserConnected

function UserDisconnected(user)
if ALLUSERS[user.sName] then
ALLUSERS[user.sName]=nil
if LEVELS[tostring(user.iProfile)] > 0 then
LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
end
end
end

OpDisconnected = UserDisconnected

function Message(user)
local tmp,share,SC,hubshare,ttshare = "",user.iShareSize,os.clock(),frmHub:GetCurrentShareAmount(),tonumber(Stat.share)
local days,hours,minutes = math.floor(Stat.uptime/43200, 30), math.floor(math.fmod(Stat.uptime/1440, 24)), math.floor(math.fmod(Stat.uptime/60, 60))
if share == nil then
share = 0
end
if user.sMode == "A" then
tmp = "Activo"
elseif user.sMode == "P" then
tmp = "Passivo"
elseif user.sMode == "5" then
tmp = "Socks5"
SendPmToOps(sChatBot,"-?--- Utilizador: "..user.sName..", est? a usar o Cliente DC em Modo: "..(user.sMode or "Indispon?vel").." - IP: "..(user.sIP or "Indispon?vel").."")
else tmp = "Desconhe?ido"
SendPmToOps(sChatBot,"-?--- Utilizador: "..user.sName..", est? a usar o Cliente DC em Modo: "..(user.sMode or "Desconhe?ido").." - IP: "..(user.sIP or "Indispon?vel").."")
end
user:SendData("            -?--- Ligado: "..(user.iHubs or "0").." Hub's - Com registo: "..(user.iRegHubs or "0").." - Como Operador: "..(user.iOpHubs or "0").." ---?-")
user:SendData("            -?--- Partilha: "..rightSize( tonumber(share) ).." - Status: "..(GetProfileName(user.iProfile) or "Sem registo").." - Password: "..(frmHub:GetUserPassword(user.sName) or "Sem Password").." ---?-")
user:SendData("            -?--- Cliente: "..(user.sClient or "Indispon?vel").." - Vers?o: "..(user.sClientVersion or "Indispon?vel").." - Modo: "..tmp.." - Slot's: "..(user.iSlots or "0").." - Liga??o: "..(user.sConnection or "Indispon?vel").." ---?-")
user:SendData("      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
user:SendData("      =-=-= "..frmHub:GetHubName().." =-=-=")
user:SendData(" ")
user:SendData("            -?--- Partilha: "..rightSize( tonumber(hubshare) ) .." --?-- Lista de Comandos: !ajuda - !help ---?-")
user:SendData("            -?--- Uptime: " ..math.floor(SC/86400).." dia's "..math.floor(math.fmod(SC/3600,24)).." hora's e "..math.floor(math.fmod(SC/60,60)).." minuto's --?-- "..os.date().." ---?-")
user:SendData("            -?--- Online --?-- OP's: "..getOn(0) + getOn(1) + getOn(2).." - Moderadores: "..getOn(3).." - ViP's: "..getOn(4).." - [G*]: "..getOn(6) + getOn(7) + getOn(8) + getOn(9) + getOn(10).." - Membros: "..getOn(5) + getOn(6) + getOn(7) + getOn(8) + getOn(9) + getOn(10).." - Total: "..(frmHub:GetUsersCount()).." ---?-")
user:SendData("            -?--- Registos --?-- OP's: "..getAll(0) + getAll(1) + getAll(2).." - Moderadores: "..getAll(3).." - ViP's: "..getAll(4).." - Membros: "..getAll(5) + getAll(6) + getAll(7) + getAll(8) + getAll(9) + getAll(10).." ---?-")
user:SendData("            -?--- Registos --?-- laptop@: "..getAll(11).." - work@: "..getAll(12).." - [G*]: "..getAll(6) + getAll(7) + getAll(8) + getAll(9) + getAll(10).." - Total: "..table.maxn(frmHub:GetRegisteredUsers()).." ---?-")
user:SendData("            -?--- Recordes --?-- Partilha: "..rightSize( tonumber(ttshare) ).." - Utilizadores: "..Stat.users.." - Uptime: "..days.." dia's ---?-")
user:SendData("      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
user:SendData("      =-=-= T?pico =-=-=")
user:SendData(" ")
user:SendData("      =-=-=-= "..(frmHub:GetHubTopic() or "Indispon?vel").." =-=-=-=")
user:SendData("      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
user:SendData(" ")
end

function getOn(p)
local r,t = frmHub:GetOnlineRegUsers(),0
for i,nick in pairs(r) do
if nick.iProfile == p then
t = t + 1
end
end
return t
end

function getAll(p)
local r = table.maxn(GetUsersByProfile(GetProfileName(p)))
return r
end

function rightSize(intSize)
if intSize ~= 0 then
local tUnits = { "Bytes", "KiB", "MiB", "GiB", "TiB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, table.maxn(tUnits)) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else 
intSize = intSize / 1024;
end
end
return string.format("%0.1f %s",intSize, sUnits);
else
return "0 Bytes"
end
end

function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.." = {\n"
for key, value in pairs(tTable) do
                local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
                if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
                else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end

function SaveToFile(file , table , tablename)
local handle = io.open(file,"w+")
handle:write(Serialize(table, tablename))
handle:flush()
handle:close()
end


Mutor's converter worked just fine here...
Title: Re: [Request] Onjoin Script Convertion to L5.1
Post by: JueLz on 31 August, 2006, 06:32:54
Yes i have experienced some with the other versions but v 1.02 is all fine