PtokaX forum

Archive => Archived 5.1 boards => Finished Scripts => Topic started by: YouAlreadyKnow on 17 May, 2006, 01:24:50

Title: Welcome script?
Post by: YouAlreadyKnow on 17 May, 2006, 01:24:50
hi i was wondering could some one make me a welcome script

i did a search on this fourm but didnt find any thing

i need the script to say  ''Welcome username To My-Block Privit DVD-r Hub Enjoy Your Stay :)''  when they enter then i want it to show this

?????????? Welcome To My-Block Private DVD-r Hub ??????????
                
                 Your nick is: YouAlreadyKnow
                 Your profile is: Reg
                 Your current IP: **.***.***.**
                 Your client is: DC++
                 Your client version is: 0.674
                 Your current mode is: Active
                 Your total hubs are: 1
                 Your open slots are: 2
                 Your share size is: 222.85 GB
                 Your description is:
                 Your connection is: DSL
                 Your email is: *************

?????????? Welcome To My-Block Private DVD-r Hub ??????????

so if some one can pls make this script for me

thanks for all your help

YAK
Title: Re: Welcome script?
Post by: 6Marilyn6Manson6 on 17 May, 2006, 08:08:50
--// WelcomeMessage made by 6Marilyn6Manson6 17/05/2006
BotName = "[ITA]WelCoMe" --frmHub:GetHubBotName(),
------------------------------------------------------
function Main()
frmHub:RegBot(BotName)
end
--// DoShareUnits
DoShareUnits = function(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.3f %s",intSize, sUnits);
else
return "0 Bytes"
end
end
------------------------------------------------------
function NewUserConnected(user)
local name,version = getHubVersion()
local timeanddate = os.date("%d-%m-%Y  %H:%M:%S")
local tmp = os.clock()
local weeks, days, hours, minutes, seconds = math.floor(tmp/604800), math.floor(math.mod(tmp/86400, 7)), math.floor(math.mod(tmp/3600, 24)), math.floor(math.mod(tmp/60, 60)), math.floor(math.mod(tmp/1, 60))
if frmHub:GetHubTopic() == nil then
HubTopic = "No Topic Set"
else
HubTopic = frmHub:GetHubTopic()
end
if user.sMyInfoString then
local disp = ""
doGetProfile =  GetProfileName(user.iProfile)
end
border1 = "  <=================Welcome To My-Block Private DVD-r Hub: "..user.sName.."========================>"
disp = "\r\n\r\n"..border1.."\r\n"
disp = disp.." ?Hub Version:\t\t\t"..name.." "..version.."\r\n"
disp = disp.." ?Hub Address: "..frmHub:GetHubAddress()..":"..frmHub:GetHubPort().."\r\n"
disp = disp.." ?Hub Name: "..(frmHub:GetHubName() or "N/A").."\r\n"
disp = disp.." ?Hub Description: "..(frmHub:GetHubDescr() or "N/A").."\r\n"
disp = disp.." ?Hub Topic: "..HubTopic.."\r\n"
disp = disp.." ?Local date and time: "..timeanddate.."\r\n"
disp = disp.."\r\n"
disp = disp.." ?Your Profile: "..doGetProfile.."\r\n"
disp = disp.." ?Your Nick: "..user.sName.."\r\n"
disp = disp.." ?Your Current IP: "..(user.sIP or "N/A").."\r\n"
disp = disp.." ?Your Client Is: "..(user.sClient or "N/A").."\r\n"
disp = disp.." ?Your Client Version Is: "..(user.sClientVersion or "N/A").."\r\n"
disp = disp.." ?Your Current Mode Is: "..user.sMode.."\r\n"
disp = disp.." ?Your Normal Hubs Are: "..(user.iNormalHubs or "N/A").."\r\n"
disp = disp.." ?Your ReG-ViP Hubs Are: "..(user.iRegHubs or "N/A").."\r\n"
disp = disp.." ?Your OPerator Hubs Are: "..(user.iOpHubs or "N/A").."\r\n"
disp = disp.." ?Your Total Hubs Are: "..(user.iHubs or "N/A").."\r\n"
disp = disp.." ?Your Open Slots Are: "..(user.iSlots or "N/A").."\r\n"
disp = disp.." ?Your Share Size Is: "..DoShareUnits(user.iShareSize).."\r\n"
disp = disp.." ?Your Description Is: "..(user.sDescription or "N/A").."\r\n"
disp = disp.." ?Your eMail Is: "..(user.sEmail or "N/A").."\r\n"
disp = disp.." ?Your Connection Is: "..(user.sConnection or "N/A").."\r\n"
disp = disp.." ?There Are Now "..frmHub:GetUsersCount().." of the "..frmHub:GetMaxUsers().." users online after "..weeks.." week(s) "..days.." day(s) "..hours.." hour(s) "..minutes.." minutes and "..seconds.." seconds\r\n\r\n"
user:SendData(BotName, disp)
disp = nil
end
------------------------------------------------------
OpConnected=NewUserConnected
--// 6Marilyn6Manson6
Title: Re: Welcome script?
Post by: YouAlreadyKnow on 17 May, 2006, 12:04:02
thank you verry much it was exactly what i needed and u added a few thing (that i like)

thanks for your help

YAK
Title: Re: Welcome script?
Post by: 6Marilyn6Manson6 on 17 May, 2006, 13:38:54
Quote from: YouAlreadyKnow on 17 May, 2006, 12:04:02
thank you verry much it was exactly what i needed and u added a few thing (that i like)

thanks for your help

YAK

Welcome ;)
Title: Re: Welcome script?
Post by: jiten on 17 May, 2006, 15:04:22
Please note that some user.* return nil or "".

Just as an example and to avoid possible syntax errors, you could use something like this:

(frmHub:GetHubName() or "n/a")

You could also have a look at InfoBot by Mutor and Psycho for more details.
Title: Re: Welcome script?
Post by: 6Marilyn6Manson6 on 17 May, 2006, 15:25:44
Done. Script update :D
Title: Re: Welcome script?
Post by: YouAlreadyKnow on 20 May, 2006, 21:26:43
i keep geting this


[15:33] Syntax ...block.no-ip.info)\scripts\WelcomeMessage-LUA_5.1.LUA:53: attempt to concatenate field `sEmail' (a nil value)


but i now see you updated the script mabee it will fix it

ill holla back if it does

agian thanks

YAK
Title: Re: Welcome script?
Post by: Psycho_Chihuahua on 20 May, 2006, 22:01:30
Here another way to fix it ;)

--// WelcomeMessage made by 6Marilyn6Manson6 17/05/2006
BotName = "[ITA]WelCoMe" --frmHub:GetHubBotName(),
------------------------------------------------------
function Main()
frmHub:RegBot(BotName)
end
--// DoShareUnits
DoShareUnits = function(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.3f %s",intSize, sUnits);
else
return "0 Bytes"
end
end
------------------------------------------------------
function GetEnable(enable)
if enable == nil or enable == "" then
enable = "N/A"
end
return enable
end

function NewUserConnected(user)
local name,version = getHubVersion()
local timeanddate = os.date("%d-%m-%Y  %H:%M:%S")
local tmp = os.clock()
local weeks, days, hours, minutes, seconds = math.floor(tmp/604800), math.floor(math.mod(tmp/86400, 7)), math.floor(math.mod(tmp/3600, 24)), math.floor(math.mod(tmp/60, 60)), math.floor(math.mod(tmp/1, 60))
if frmHub:GetHubTopic() == nil then
HubTopic = "No Topic Set"
else
HubTopic = frmHub:GetHubTopic()
end
if user.sMyInfoString then
local disp = ""
doGetProfile =  GetProfileName(user.iProfile)
end
border1 = "  <=================Welcome To My-Block Private DVD-r Hub: "..user.sName.."========================>"
disp = "\r\n\r\n"..border1.."\r\n"
disp = disp.." ?Hub Version:\t\t\t"..name.." "..version.."\r\n"
disp = disp.." ?Hub Address: "..frmHub:GetHubAddress()..":"..frmHub:GetHubPort().."\r\n"
disp = disp.." ?Hub Name: "..GetEnable(frmHub:GetHubName()).."\r\n"
disp = disp.." ?Hub Description: "..GetEnable(frmHub:GetHubDescr()).."\r\n"
disp = disp.." ?Hub Topic: "..HubTopic.."\r\n"
disp = disp.." ?Local date and time: "..timeanddate.."\r\n"
disp = disp.."\r\n"
disp = disp.." ?Your Nick: "..user.sName.."\r\n"
disp = disp.." ?Your Profile: "..doGetProfile.."\r\n"
disp = disp.." ?Your Current IP: "..GetEnable(user.sIP).."\r\n"
disp = disp.." ?Your Client Is: "..GetEnable(user.sClient).."\r\n"
disp = disp.." ?Your Client Version Is: "..GetEnable(user.sClientVersion).."\r\n"
disp = disp.." ?Your Current Mode Is: "..user.sMode.."\r\n"
disp = disp.." ?Your Normal Hubs Are: "..GetEnable(user.iNormalHubs).."\r\n"
disp = disp.." ?Your ReG-ViP Hubs Are: "..GetEnable(user.iRegHubs).."\r\n"
disp = disp.." ?Your OPerator Hubs Are: "..GetEnable(user.iOpHubs).."\r\n"
disp = disp.." ?Your Total Hubs Are: "..GetEnable(user.iHubs).."\r\n"
disp = disp.." ?Your Open Slots Are: "..GetEnable(user.iSlots).."\r\n"
disp = disp.." ?Your Share Size Is: "..DoShareUnits(user.iShareSize).."\r\n"
disp = disp.." ?Your Description Is: "..GetEnable(user.sDescription).."\r\n"
disp = disp.." ?Your Connection Is: "..GetEnable(user.sConnection).."\r\n"
disp = disp.." ?Your eMail Is: "..GetEnable(user.sEmail).."\r\n"
disp = disp.." ?There Are Now "..GetEnable(frmHub:GetUsersCount()).." of the "..GetEnable(frmHub:GetMaxUsers()).." users online after "..weeks.." week(s) "..days.." day(s) "..hours.." hour(s) "..minutes.." minutes and "..seconds.." seconds\r\n\r\n"
user:SendData(BotName, disp)
disp = nil
end
------------------------------------------------------
OpConnected=NewUserConnected
--// 6Marilyn6Manson6
Title: Re: Welcome script?
Post by: 6Marilyn6Manson6 on 20 May, 2006, 22:02:21
Post update sorry ;)
Title: Re: Welcome script?
Post by: 6Marilyn6Manson6 on 20 May, 2006, 22:06:12
Quote from: Psycho_Chihuahua on 20 May, 2006, 22:01:30
Here another way to fix it ;)


Psycho_Chihuahua your post not is correct because:

disp = disp.." ?Your Description Is: "..user.sDescription.."\r\n"
disp = disp.." ?Your Connection Is: "..user.sConnection.."\r\n"


this 2 line (in your post) can give same error of:
[15:33] Syntax ...block.no-ip.info)\scripts\WelcomeMessage-LUA_5.1.LUA:53: attempt to concatenate field `sEmail' (a nil value)
;). See my post :D
Title: Re: Welcome script?
Post by: Psycho_Chihuahua on 20 May, 2006, 22:09:57
i noticed and fixed my post already ;)
Title: Re: Welcome script?
Post by: 6Marilyn6Manson6 on 20 May, 2006, 22:12:39
Quote from: Psycho_Chihuahua on 20 May, 2006, 22:09:57
i noticed and fixed my post already ;)

Now is ok ;)
Title: Re: Welcome script?
Post by: 6Marilyn6Manson6 on 20 May, 2006, 22:46:49
Exist this:

if frmHub:GetHubTopic() == nil then
HubTopic = "No Topic Set"
else
HubTopic = frmHub:GetHubTopic()
end


but you recall GetEnable function in this line:

disp = disp.." ?Hub Topic: "..GetEnable(HubTopic).."\r\n"

I don't understand because you recall function :S
Title: Re: Welcome script?
Post by: Psycho_Chihuahua on 20 May, 2006, 22:56:25
oops  ::) - fixed now hehe

i was busy playing around with InfoBot at the same time.

--[[
InfoBot 1.50 LUA5/5.1
By Mutor        02/25/06
Show hub/user info to new connections, (pulled from another script)
Extended by Psycho_Chihuahua
Version 1.1
added - Shows PtokaX Hubversion and Substring
Version 1.2
added - show Script Informations or not (only active scripts are shown)
Version 1.21
added - show Windows Version (bluebears PtxUtilities required)
Version 1.3
added - Show PtokaX Location
added - Switch to turn Script Info's on or off
Version 1.40
Code shortened by Mutor
added - Toggle cmd to turn ShowScripts on/off (thnx Mutor - but i had to bugfix it ;) )
added - RC Menu by Profile to toggle ShowScripts
Version 1.50
Added Hubport to Hubaddress
Added AutoReg Status
Added Lua 5/5.1 Support
]]--
-- Start Settings
PtxVers = "aa1 Lua 5.1" -- PtokaX Version Substring
ShowScripts = "off" -- Show script Informations?  1=true/0=false
ToggleScripts = "!showscripts" -- Toggle ShowScripts on/off command
HubOwner = "Psycho_Chihuahua"
Greeting = "It's nice of you to stop by..."

-- RC Access to Toggle Cmd (1=allowed/0=deny)
RcAdmin = {
[0] = 1,    -- =[Master]=
[1] = 1,    -- =[OP]=
[2] = 0,    -- =[ViP]=
[3] = 0,    -- =[Reg]=
[4] = 0,    -- =[Custom Profile 1]=
[5] = 0,    -- =[Custom Profile 2]=
   [-1] = 0,    -- =[UnReg]=
}

-- End Settings
-- DO NOT EDIT ANYTHING BELOW UNLESS YOU KNOW WHAT YOU ARE DOING!! -- I should know - borked it myself ;)

Main = function()
if _VERSION == "Lua 5.1" then
libinit = package.loadlib("PxUtilities_l51.dll", "_libinit")
else
libinit = loadlib("PxUtilities.dll", "_libinit")
libinit()
end
end


function ChatArrival(user, data)
local s,e,cmd = string.find(data,"^%b<>%s(%p%w+)|")
if cmd and cmd == ToggleScripts then
if ShowScripts == "on" then
ShowScripts = "off"
else
ShowScripts = "on"
end
user:SendData(frmHub:GetHubBotName(),"ShowScripts is now "..ShowScripts)
return 1
end
end


NewUserConnected = function(user)
    if RcAdmin[user.iProfile] == 1 then
user:SendData("$UserCommand 1 3 "..frmHub:GetHubBotName().."\\InfoBot\\Toggle Showscripts$<%[mynick]> "..ToggleScripts.."&#124;");
end
DoInfo(user)
end

OpConnected = NewUserConnected

function GetEnable(enable)
if enable == nil or enable == "" then
enable = "not set"
end
return enable
end

function AutoRegStatus(enable)
if enable == nil or enable == "" then
enable = "not active"
else enable = "active"
end
return enable
end

function minutestoh(minutes) -- gets minutes as arguments, returns a string with formatted time and 4 numbers as units
    if frac(minutes) > 0.5 then minutes=math.ceil(minutes) else minutes=math.floor(minutes) end
      local weeks,days,hours,mins
      local msg=""
        local a1,a2,a3=math.mod(minutes,10080),math.mod(minutes,1440),math.mod(minutes,60)
        if a1==minutes then weeks=0 else weeks=math.floor(minutes/10080) end
        if a2==minutes then days=0 else days=math.floor(a1/1440) end
        if a3==minutes then hours=0 else hours=math.floor(a2/60) end
        mins=math.mod(minutes,60)
        local tmp=
            {
              [" weeks "]=weeks,
              [" days "]=days,
              [" hours "]=hours,
              [" minutes"]=mins
            }
            local tmp2={" weeks "," days "," hours "," minutes"}
        for a,b in ipairs(tmp2) do
          if tmp[b] > 0 then
            msg=msg..tmp[b]..b
          end
        end
        if msg=="" then msg="0" end
        return msg,weeks,days,hours,mins
      end

function frac(num) -- returns fraction of a number (RabidWombat)
  return num - math.floor(num);
end

GetScript = function()
local tab = {}
local str = ""
local x = ""
for line in io.lines(frmHub:GetPtokaXLocation().."cfg/Scripts.xml") do
        local s,e,script = string.find(line,"<Name>([%w%s%p]+)</Name>")
        local s,e,enable = string.find(line,"<Enabled>(%d+)</Enabled>")
        if script then
                x = script
elseif enable then
        tab[x] = tonumber(enable)
        x = ""
end
end
for i,v in pairs(tab) do
if v == 1 then
        local s,e,version = string.find(i,"%v([%a%d%p]+)%.lua")
        if not version then version = "-" end
        str = str.."\tScript Name: "..string.format("%-25.15s",string.gsub(i,"%s.*","")).."\tVer: "..version.."\r\n"
end
end
return str
end

function DoInfo(user)
local Scripts = ""
name, ver = getHubVersion()
SerVer = PXU.GetWindowsVersion()
local _,W,D,H,M=minutestoh(frmHub:GetUpTime() / 60)
local Prof
local Topic
Prof= GetProfileName(user.iProfile) or "Unregistered User"
Topic = frmHub:GetHubTopic() or "There is no current topic."
local art = string.rep("?",40).."\r\n"
local ul = string.rep("?",14).."\r\n"
if ShowScripts == "on" then
Scripts = "\t"..art.."\tScript Information:\r\n\t"..ul..GetScript()
end
local tmp = "\r\n\r\n\t"..art.."\tHub Information:\r\n\t"..ul..
"\tWelcome:\t"..user.sName..", "..Greeting.."\r\n"..
"\tHub Name: \t"..GetEnable(frmHub:GetHubName())..",  "..Topic.."\r\n"..
"\tHub Version: \t"..name.." "..ver.." "..PtxVers.."\r\n"..
"\tServer Version: \t"..SerVer.."\r\n"..
"\tHub description:\t"..GetEnable(frmHub:GetHubDescr()).."\r\n"..
"\tHub Address:\t"..frmHub:GetHubAddress()..":"..frmHub:GetHubPort().."\r\n"..
"\tHub IP:\t\t"..frmHub:GetHubIp().."\r\n"..
"\tHubOwner:\t"..HubOwner.."\r\n"..
"\tAutoregister:\t"..AutoRegStatus(frmHub:GetAutoRegister()).."\r\n"..
"\tUptime:\t\t"..minutestoh(frmHub:GetUpTime() / 60).."\r\n"..
"\tPeak Users:\t"..GetEnable(frmHub:GetMaxUsersPeak()).."\r\n"..
"\tHub Share:\t"..string.format("%.2f Tb.",frmHub:GetCurrentShareAmount()/(1024 * 1024 * 1024 * 1024)).."\r\n"..
"\tThere Are Now:\t"..GetEnable(frmHub:GetUsersCount()).." of "..GetEnable(frmHub:GetMaxUsers()).." max users online.\r\n\r\n"..
"\t"..art.."\tYour Information:\r\n\t"..ul..
"\tUsername:\t"..user.sName.."\r\n"..
"\tUser Profile:\t"..Prof.."\r\n"..
"\tIP Address:\t"..GetEnable(user.sIP).."\r\n"..
"\tShare Size:\t"..string.format("%.2f Gb.",user.iShareSize/(1024 * 1024 * 1024)).."\r\n"..
"\tDC Tag:\t\t"..GetEnable(user.sTag).."\r\n"..
"\tDescription:\t"..GetEnable(user.sDescription).."\r\n"..
"\tEmail:\t\t"..GetEnable(user.sEmail).."\r\n"..
"\tConnection:\t"..GetEnable(user.sConnection).."\r\n\r\n"..
Scripts..
"\r\n\t"..art..
"\t? [ This information is only being shown to you ] ?\r\n\r\n\t"..art
user:SendData(tmp)
end
Title: Re: Welcome script?
Post by: 6Marilyn6Manson6 on 20 May, 2006, 23:02:44
OK :P
Title: Re: Welcome script?
Post by: YouAlreadyKnow on 21 May, 2006, 00:03:14
Quote from: Psycho_Chihuahua on 20 May, 2006, 22:01:30
Here another way to fix it ;)

--// WelcomeMessage made by 6Marilyn6Manson6 17/05/2006
BotName = "[ITA]WelCoMe" --frmHub:GetHubBotName(),
------------------------------------------------------
function Main()
frmHub:RegBot(BotName)
end
--// DoShareUnits
DoShareUnits = function(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.3f %s",intSize, sUnits);
else
return "0 Bytes"
end
end
------------------------------------------------------
function GetEnable(enable)
if enable == nil or enable == "" then
enable = "N/A"
end
return enable
end

function NewUserConnected(user)
local name,version = getHubVersion()
local timeanddate = os.date("%d-%m-%Y  %H:%M:%S")
local tmp = os.clock()
local weeks, days, hours, minutes, seconds = math.floor(tmp/604800), math.floor(math.mod(tmp/86400, 7)), math.floor(math.mod(tmp/3600, 24)), math.floor(math.mod(tmp/60, 60)), math.floor(math.mod(tmp/1, 60))
if frmHub:GetHubTopic() == nil then
HubTopic = "No Topic Set"
else
HubTopic = frmHub:GetHubTopic()
end
if user.sMyInfoString then
local disp = ""
doGetProfile =  GetProfileName(user.iProfile)
end
border1 = "  <=================Welcome To My-Block Private DVD-r Hub: "..user.sName.."========================>"
disp = "\r\n\r\n"..border1.."\r\n"
disp = disp.." ?Hub Version:\t\t\t"..name.." "..version.."\r\n"
disp = disp.." ?Hub Address: "..frmHub:GetHubAddress()..":"..frmHub:GetHubPort().."\r\n"
disp = disp.." ?Hub Name: "..GetEnable(frmHub:GetHubName()).."\r\n"
disp = disp.." ?Hub Description: "..GetEnable(frmHub:GetHubDescr()).."\r\n"
disp = disp.." ?Hub Topic: "..HubTopic.."\r\n"
disp = disp.." ?Local date and time: "..timeanddate.."\r\n"
disp = disp.."\r\n"
disp = disp.." ?Your Nick: "..user.sName.."\r\n"
disp = disp.." ?Your Profile: "..doGetProfile.."\r\n"
disp = disp.." ?Your Current IP: "..GetEnable(user.sIP).."\r\n"
disp = disp.." ?Your Client Is: "..GetEnable(user.sClient).."\r\n"
disp = disp.." ?Your Client Version Is: "..GetEnable(user.sClientVersion).."\r\n"
disp = disp.." ?Your Current Mode Is: "..user.sMode.."\r\n"
disp = disp.." ?Your Normal Hubs Are: "..GetEnable(user.iNormalHubs).."\r\n"
disp = disp.." ?Your ReG-ViP Hubs Are: "..GetEnable(user.iRegHubs).."\r\n"
disp = disp.." ?Your OPerator Hubs Are: "..GetEnable(user.iOpHubs).."\r\n"
disp = disp.." ?Your Total Hubs Are: "..GetEnable(user.iHubs).."\r\n"
disp = disp.." ?Your Open Slots Are: "..GetEnable(user.iSlots).."\r\n"
disp = disp.." ?Your Share Size Is: "..DoShareUnits(user.iShareSize).."\r\n"
disp = disp.." ?Your Description Is: "..GetEnable(user.sDescription).."\r\n"
disp = disp.." ?Your Connection Is: "..GetEnable(user.sConnection).."\r\n"
disp = disp.." ?Your eMail Is: "..GetEnable(user.sEmail).."\r\n"
disp = disp.." ?There Are Now "..GetEnable(frmHub:GetUsersCount()).." of the "..GetEnable(frmHub:GetMaxUsers()).." users online after "..weeks.." week(s) "..days.." day(s) "..hours.." hour(s) "..minutes.." minutes and "..seconds.." seconds\r\n\r\n"
user:SendData(BotName, disp)
disp = nil
end
------------------------------------------------------
OpConnected=NewUserConnected
--// 6Marilyn6Manson6

thanks alot using this update now..so fare so good

thanks for all ur help

YAK
Title: Re: Welcome script?
Post by: 6Marilyn6Manson6 on 21 May, 2006, 12:39:54
Quote from: Mutor on 21 May, 2006, 05:12:04
DoShareUnits is incomplete, you may want to work on that.

Im sorry Mutor but.. DoShareUnits function is complete and work very nice :D
Title: Re: Welcome script?
Post by: Markitos on 21 May, 2006, 13:02:55
Quote from: Mutor on 21 May, 2006, 05:12:04
DoShareUnits is incomplete, you may want to work on that.
From Scripting:Utilities:Center   ;D
function GetByteUnit(intSize)
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return format("%0.2f %s",intSize, sUnits);
end
Title: Re: Welcome script?
Post by: 6Marilyn6Manson6 on 21 May, 2006, 13:10:09
Quote from: Markitos on 21 May, 2006, 13:02:55
Quote from: Mutor on 21 May, 2006, 05:12:04
DoShareUnits is incomplete, you may want to work on that.
From Scripting:Utilities:Center? ?;D
function GetByteUnit(intSize)
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return format("%0.2f %s",intSize, sUnits);
end


I think Markitos's function is incomplete...because if user have 0 in shared...this function give error. And for close this thread... in other script I see my same function made of jiten ;)

Here for example:

--$Rev Blocker by jiten
--restriction for those who have less than MinSlots and MinShare
--some ideas taken from leech bot and ShaveShare v4.8 by Herodes

kb = 1024 
mb = 1024 ^ 2
gb = 1024 ^ 3

MinShare = 500*mb -- in MBs
MinSlots = 3

function DoShareUnits(intSize) --- Thanks to kepp and NotRambitWombat
if intSize ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
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 "nothing"
end
end

function ConnectToMeArrival(curUser,data)
if curUser.iShareSize < MinShare or curUser.iSlots < MinSlots then
curUser:SendData("*** You have to share at least "..DoShareUnits(MinShare).." and/or have "..MinSlots.." slots open to be able do download.")
return 1
end
end

RevConnectToMeArrival = ConnectToMeArrival


and jiten is a super lua scripter :D
Title: Re: Welcome script?
Post by: 6Marilyn6Manson6 on 21 May, 2006, 17:26:46
Yes, 2 decimal is ok, all script use 1 or max 2 decimal, but I love 3 decimal :P
Title: Re: Welcome script?
Post by: Dino on 31 May, 2006, 16:57:30
Quote from: 6Marilyn6Manson6 on 17 May, 2006, 13:38:54
Quote from: YouAlreadyKnow on 17 May, 2006, 12:04:02
thank you verry much it was exactly what i needed and u added a few thing (that i like)

Here is the Script in portugese
By me Gasolina dc++
mozhub.no-ip.info:411










--// WelcomeMessage made by 6Marilyn6Manson6 17/05/2006
BotName = "Vibe-Bot" --frmHub:GetHubBotName(),
------------------------------------------------------
function Main()
frmHub:RegBot(BotName)
end
--// DoShareUnits
DoShareUnits = function(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.3f %s",intSize, sUnits);
else
return "0 Bytes"
end
end
------------------------------------------------------
function NewUserConnected(user)
local name,version = getHubVersion()
local timeanddate = os.date("%d-%m-%Y  %H:%M:%S")
local tmp = os.clock()
local weeks, days, hours, minutes, seconds = math.floor(tmp/604800), math.floor(math.mod(tmp/86400, 7)), math.floor(math.mod(tmp/3600, 24)), math.floor(math.mod(tmp/60, 60)), math.floor(math.mod(tmp/1, 60))
if frmHub:GetHubTopic() == nil then
HubTopic = "No Topic Set"
else
HubTopic = frmHub:GetHubTopic()
end
if user.sMyInfoString then
local disp = ""
doGetProfile =  GetProfileName(user.iProfile)
end
border1 = "  <=================Seja Bem Vindo ao MoZ-Vibe?: "..user.sName.."========================>"
disp = "\r\n\r\n"..border1.."\r\n"
disp = disp.." ? Soft ware do hubn:\t\t\t"..name.." "..version.."\r\n"
disp = disp.." ? Endere?o do hub: "..frmHub:GetHubAddress()..":"..frmHub:GetHubPort().."\r\n"
disp = disp.." ? Nome do Hub: "..(frmHub:GetHubName() or "N/A").."\r\n"
disp = disp.." ? Descri??o do Hub: "..(frmHub:GetHubDescr() or "N/A").."\r\n"
disp = disp.." ? Topico do hub: "..HubTopic.."\r\n"
disp = disp.." ? Hora e data: "..timeanddate.."\r\n"
disp = disp.."\r\n"
disp = disp.." ? Seu perfil: "..doGetProfile.."\r\n"
disp = disp.." ? Seu Nick: "..user.sName.."\r\n"
disp = disp.." ? O seu  IP: "..(user.sIP or "N/A").."\r\n"
disp = disp.." ? Seu cliente: "..(user.sClient or "N/A").."\r\n"
disp = disp.." ? A vers?o do seu cliente ?: "..(user.sClientVersion or "N/A").."\r\n"
disp = disp.." ? O seu modo ?: "..user.sMode.."\r\n"
disp = disp.." ? Hubs registado como user normal: "..(user.iNormalHubs or "N/A").."\r\n"
disp = disp.." ? Hubs registado como  Reg-Vip : "..(user.iRegHubs or "N/A").."\r\n"
disp = disp.." ? Hubs como Operador: "..(user.iOpHubs or "N/A").."\r\n"
disp = disp.." ? Hubs hubs em que se encontra: "..(user.iHubs or "N/A").."\r\n"
disp = disp.." ? Slot abertos: "..(user.iSlots or "N/A").."\r\n"
disp = disp.." ? O seu share ? de: "..DoShareUnits(user.iShareSize).."\r\n"
disp = disp.." ? A sua descri??o: "..(user.sDescription or "N/A").."\r\n"
disp = disp.." ? O seu e mail ?: "..(user.sEmail or "N/A").."\r\n"
disp = disp.." ? A sua connec??o ?: "..(user.sConnection or "N/A").."\r\n"
disp = disp.." ? Agora est?o "..frmHub:GetUsersCount().." dos Maximos users "..frmHub:GetMaxUsers().." Apos de "..weeks.." semana(s) "..days.." dias(s) "..hours.." houra(s) "..minutes.." minutos e "..seconds.." segundos\r\n\r\n"
user:SendData(BotName, disp)
disp = nil
end
------------------------------------------------------
OpConnected=NewUserConnected
--// 6Marilyn6Manson6
Title: Re: Welcome script?
Post by: 6Marilyn6Manson6 on 31 May, 2006, 17:12:01
I Love Multilanguage :D
Title: Re: Welcome script?
Post by: Helios on 08 June, 2006, 22:29:22
Syntax F:\recupero\Ptokax\Ptokax\scripts\welcome.lua:53: attempt to concatenate global 'doGetProfile' (a nil value)
lol any1 fix it
Title: Re: Welcome script?
Post by: Helios on 08 June, 2006, 22:34:09
this error is generated by infobot

Syntax F:\recupero\Ptokax\Ptokax\scripts\infobot.lua:187: 'end' expected (to close 'function' at line 147) near '<eof>'

Syntax F:\recupero\Ptokax\Ptokax\scripts\infobot.lua:150: attempt to index global 'PXU' (a nil value)

i use ptokax 3.0.4.0k with lua 5.1
Title: Re: Welcome script?
Post by: 6Marilyn6Manson6 on 09 June, 2006, 08:21:17
Quote
This stems from bad technique in creating the variable.
Quote

Mmm not is bad technique but only small distraction :D
Title: Re: Welcome script?
Post by: Psycho_Chihuahua on 09 June, 2006, 09:18:06
well i've checked InfoBot on both k0 Lua 5.02 and k1 Lua 5.1 and it works fine for me.

And Helios as i have stated on the other forum - please give me better details of information on how you got that error - cause i aint gettin no errors ;)

and by the way if you get:
attempt to index global 'PXU' (a nil value)
that means you havent got the version 1.6d as i have put everything together in that one - so you shouldnt get that error as PxUtilities is shipped in the package.

InfoBot 1.6d (http://ptxscriptdb.psycho-chihuahua.net/e107_plugins/docrep_menu/docrep.php?0.getdoc.84.22.)
unpack as is into ptokax root folder then everything is where its supposed to be - libs in root and script in scripts
Title: Re: Welcome script?
Post by: Helios on 09 June, 2006, 18:16:12
Syntax F:\recupero\Ptokax\Ptokax\scripts\welcome.lua:53: attempt to concatenate global 'doGetProfile' (a nil value)
Title: Re: Welcome script?
Post by: Helios on 09 June, 2006, 18:20:58
Quote from: Mutor on 09 June, 2006, 02:22:59
Quote from: Helios on 08 June, 2006, 22:29:22
Syntax F:\recupero\Ptokax\Ptokax\scripts\welcome.lua:53: attempt to concatenate global 'doGetProfile' (a nil value)
lol any1 fix it

This stems from bad technique in creating the variable.
doGetProfile =  GetProfileName(user.iProfile)

Will fail on an unregistered user, where  GetProfileName(user.iProfile) will return nil
When it's possible for such a call to return nil [false] it's best to use the or statement
There is also no reason for a global variable here.

so, you might try...

local doGetProfile =  GetProfileName(user.iProfile) or "Unregistered User"

to avoid that error.

Quote from: Helios on 08 June, 2006, 22:34:09
i use ptokax 3.0.4.0k with lua 5.1

It is important to post the full Px version, 0.3.4.0k0 = LUA 5.02, or 0.3.4.0k1 = LUA 5.1 for example.
I do know that that has been addressed [and hopefully fixed by Psycho Chihuahua] in a recent update.
It's a matter of how libs are handled differently in the two LUA versions.
One last thing, you should post this in the InfoBot thread. No here, as it has no bearing.

i have installed this


changed old string with ---------------------> local doGetProfile =  GetProfileName(user.iProfile) or "Unregistered User"

error report   [19:11] Syntax F:\recupero\Ptokax\Ptokax\scripts\welcome.lua:53: attempt to concatenate global 'doGetProfile' (a nil value)
Title: Re: Welcome script?
Post by: Psycho_Chihuahua on 10 June, 2006, 00:29:09
PtokaX doesn't seem to like doGetProfile - i got the same Error there. But its easy to fix - just use a different Var

--// WelcomeMessage made by 6Marilyn6Manson6 17/05/2006
BotName = "[ITA]WelCoMe" --frmHub:GetHubBotName(),
------------------------------------------------------
function Main()
frmHub:RegBot(BotName)
end
--// DoShareUnits
DoShareUnits = function(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.3f %s",intSize, sUnits);
else
return "0 Bytes"
end
end
------------------------------------------------------
function NewUserConnected(user)
local doGetProfile = "Unregistered User"
if user.iProfile ~= -1 then doGetProfile = GetProfileName(user.iProfile) end
local name,version = getHubVersion()
local timeanddate = os.date("%d-%m-%Y  %H:%M:%S")
local tmp = os.clock()
local weeks, days, hours, minutes, seconds = math.floor(tmp/604800), math.floor(math.mod(tmp/86400, 7)), math.floor(math.mod(tmp/3600, 24)), math.floor(math.mod(tmp/60, 60)), math.floor(math.mod(tmp/1, 60))
if frmHub:GetHubTopic() == nil then
HubTopic = "No Topic Set"
else
HubTopic = frmHub:GetHubTopic()
end
if user.sMyInfoString then
local disp = ""
end
border1 = "  <=================Welcome To My-Block Private DVD-r Hub: "..user.sName.."========================>"
disp = "\r\n\r\n"..border1.."\r\n"
disp = disp.." ?Hub Version:\t\t\t"..name.." "..version.."\r\n"
disp = disp.." ?Hub Address: "..frmHub:GetHubAddress()..":"..frmHub:GetHubPort().."\r\n"
disp = disp.." ?Hub Name: "..(frmHub:GetHubName() or "N/A").."\r\n"
disp = disp.." ?Hub Description: "..(frmHub:GetHubDescr() or "N/A").."\r\n"
disp = disp.." ?Hub Topic: "..HubTopic.."\r\n"
disp = disp.." ?Local date and time: "..timeanddate.."\r\n"
disp = disp.."\r\n"
disp = disp.." ?Your Profile: "..doGetProfile.."\r\n"
disp = disp.." ?Your Nick: "..user.sName.."\r\n"
disp = disp.." ?Your Current IP: "..(user.sIP or "N/A").."\r\n"
disp = disp.." ?Your Client Is: "..(user.sClient or "N/A").."\r\n"
disp = disp.." ?Your Client Version Is: "..(user.sClientVersion or "N/A").."\r\n"
disp = disp.." ?Your Current Mode Is: "..user.sMode.."\r\n"
disp = disp.." ?Your Normal Hubs Are: "..(user.iNormalHubs or "N/A").."\r\n"
disp = disp.." ?Your ReG-ViP Hubs Are: "..(user.iRegHubs or "N/A").."\r\n"
disp = disp.." ?Your OPerator Hubs Are: "..(user.iOpHubs or "N/A").."\r\n"
disp = disp.." ?Your Total Hubs Are: "..(user.iHubs or "N/A").."\r\n"
disp = disp.." ?Your Open Slots Are: "..(user.iSlots or "N/A").."\r\n"
disp = disp.." ?Your Share Size Is: "..DoShareUnits(user.iShareSize).."\r\n"
disp = disp.." ?Your Description Is: "..(user.sDescription or "N/A").."\r\n"
disp = disp.." ?Your eMail Is: "..(user.sEmail or "N/A").."\r\n"
disp = disp.." ?Your Connection Is: "..(user.sConnection or "N/A").."\r\n"
disp = disp.." ?There Are Now "..frmHub:GetUsersCount().." of the "..frmHub:GetMaxUsers().." users online after "..weeks.." week(s) "..days.." day(s) "..hours.." hour(s) "..minutes.." minutes and "..seconds.." seconds\r\n\r\n"
user:SendData(BotName, disp)
disp = nil
end
------------------------------------------------------
OpConnected=NewUserConnected
--// 6Marilyn6Manson6


As you see all i did was change 'doGetProfile' to 'Prof' and voila it worked.
Title: Re: Welcome script?
Post by: Madman on 10 June, 2006, 01:53:21
Px has no problem with doGetProfile...
How ever.. is has a prob with line 36... witch is the reason you get a nil error
remove it and it's solved aswell... ;)
Title: Re: Welcome script?
Post by: Helios on 10 June, 2006, 01:58:59
tnx 1000 Psycho_Chihuahua it work fine now
Title: Re: Welcome script?
Post by: Helios on 12 June, 2006, 07:23:56
[08:17] Syntax F:\recupero\Ptokax\Ptokax\scripts\welcome.lua:42: attempt to call global 'GetEnable' (a nil value)

lol

Title: Re: Welcome script?
Post by: Psycho_Chihuahua on 12 June, 2006, 08:26:07
And how do you get that????


There is no GetEnable Call in welcome.lua
Title: Re: Welcome script?
Post by: Helios on 12 June, 2006, 09:09:48
i have tested it for 3 days no error
now get this error don't understand why
Title: Re: Welcome script?
Post by: Psycho_Chihuahua on 12 June, 2006, 09:24:14
it is still not possible to get a GetEnable Error unless you added something and doing so - borked it.

if no GetEnable in Script = impossible to get such an Error