PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: bsalsa on 16 February, 2004, 16:48:11

Title: A simple welcome message
Post by: bsalsa on 16 February, 2004, 16:48:11
I am looking for a script that will send a welcome message in main chat of the user to all user/op that connects to the hub like this :

welcome" xxxx:.
your ip is" xxxx .
your isp is :"xxxx.
you have xxxx  gb shared.
you have xxx slots for upload xxx slots for download.
you are connected to :



thanks
Title: to make my self clear:
Post by: bsalsa on 16 February, 2004, 16:50:00
every user/op that connects to the hub will get this message in his mainchat window
Title:
Post by: Woodster on 16 February, 2004, 17:24:33
sBotName = "Bot_Name"

frmHub:RegBot(sBotName)

 

function CountMASTERs()
local tmp, online = GetUsersByProfile(GetProfileName(0)), {n=0}
if tmp then for id = 0, getn(tmp) do if GetItemByName(tmp[id]) then tinsert(online, tmp[id]) end end
end return online.n
end

function CountOPs()
local tmp, online = GetUsersByProfile(GetProfileName(1)), {n=0}
if tmp then for id = 0, getn(tmp) do if GetItemByName(tmp[id]) then tinsert(online, tmp[id]) end end
end return online.n
end


function CountVIPs()
local tmp, online = GetUsersByProfile(GetProfileName(2)), {n=0}
if tmp then for id = 0, getn(tmp) do if GetItemByName(tmp[id]) then tinsert(online, tmp[id]) end end
end return online.n
end

function CountRegs()
local tmp, online = GetUsersByProfile(GetProfileName(3)), {n=0}
if tmp then for id = 0, getn(tmp) do if GetItemByName(tmp[id]) then tinsert(online, tmp[id]) end end
end return online.n
end

function OpConnected(user)
local i,j,share = strfind(user.sMyInfoString, ".+%$(%d+)%$$")
usershare = format("%0.2f", tonumber(share)/(1024*1024*1024))

local tmp
tmp = "Welcome to "..frmHub:GetHubName().."\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Your Nick: "..user.sName.."\r\n"
tmp = tmp.."\t??? Your IP: "..user.sIP.."\r\n"
tmp = tmp.."\t??? Your share: "..usershare.."GB\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Hub Name: "..frmHub:GetHubName().."\r\n"
tmp = tmp.."\t??? Hub Address: ....\r\n"
tmp = tmp.."\t??? Hub Desc: "..frmHub:GetHubDescr().."\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? The Hub Cmd's >>> type !help and !rules.  Please Read and Abide by them! \r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Masters Online: "..CountMASTERs().."\r\n"
tmp = tmp.."\t??? Operators Online: "..CountOPs().."\r\n"
tmp = tmp.."\t??? VIPs Online: "..CountVIPs().."\r\n"
tmp = tmp.."\t??? REGs Online: "..CountRegs().."\r\n"
tmp = tmp.."\ \r\n"

user:SendPM(sBotName,tmp)
end


--function NewUserConnected(user)
--   local i,j,share = strfind(user.sMyInfoString, ".+%$(%d+)%$$")
--   usershare = format("%0.2f", tonumber(share)/(1024*1024*1024))

function NewUserConnected(user)
i,j,share = strfind(user.sMyInfoString, ".+%$(%d+)$")
-- this if routine is checking so if the share cannot be extracted , shre equals to zero. and
-- prevents nil / 1024 * 1024 * 1024 (which are causing the error)
if share == nil then
share = 0
end
usershare = format("%0.2f", tonumber(share)/(1024*1024*1024))  

local tmp
tmp = "Welcome to "..frmHub:GetHubName().."\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Your Nick: "..user.sName.."\r\n"
tmp = tmp.."\t??? Your IP: "..user.sIP.."\r\n"
tmp = tmp.."\t??? Your share: "..usershare.."GB\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Hub Name: "..frmHub:GetHubName().."\r\n"
tmp = tmp.."\t??? Hub Address: ....\r\n"
tmp = tmp.."\t??? Hub Desc: "..frmHub:GetHubDescr().."\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? The Hub Cmd's >>> type !help and !rules.  Please Read and Abide by them! \r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Users Online: "..frmHub:GetUsersCount().."\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Masters Online: "..CountMASTERs().."\r\n"
tmp = tmp.."\t??? Operators Online: "..CountOPs().."\r\n"
tmp = tmp.."\t??? VIPs Online: "..CountVIPs().."\r\n"
tmp = tmp.."\t??? REGs Online: "..CountRegs().."\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? To see the NEWEST additions, type  !tag \r\n"
tmp = tmp.."\t??? The Hub Cmd's >>> type !help and !rules.  Read them!! \r\n"
tmp = tmp.."\t??? Be sure to READ EVERYTHING in the Main chat window!! \r\n"
tmp = tmp.."\t??? If you like this hub, don't forget to add it to your favorites by typing /fav in mainchat \r\n"
 
user:SendPM(sBotName,tmp)
end

Hope its what you wanted
Title:
Post by: Woodster on 16 February, 2004, 17:29:06
Sorry not quite what you wanted but it send to everyone via PM
Title: working
Post by: bsalsa on 16 February, 2004, 19:11:32
i fixed it to my needs and all is working fine (in mainchat as i wanted)
here is the finished script :


sBotName = "welcome"

frmHub:RegBot(sBotName)



function CountMASTERs()
local tmp, online = GetUsersByProfile(GetProfileName(0)), {n=0}
if tmp then for id = 0, getn(tmp) do if GetItemByName(tmp[id]) then tinsert(online, tmp[id]) end end
end return online.n
end

function CountOPs()
local tmp, online = GetUsersByProfile(GetProfileName(1)), {n=0}
if tmp then for id = 0, getn(tmp) do if GetItemByName(tmp[id]) then tinsert(online, tmp[id]) end end
end return online.n
end


function CountVIPs()
local tmp, online = GetUsersByProfile(GetProfileName(2)), {n=0}
if tmp then for id = 0, getn(tmp) do if GetItemByName(tmp[id]) then tinsert(online, tmp[id]) end end
end return online.n
end

function CountRegs()
local tmp, online = GetUsersByProfile(GetProfileName(3)), {n=0}
if tmp then for id = 0, getn(tmp) do if GetItemByName(tmp[id]) then tinsert(online, tmp[id]) end end
end return online.n
end

function OpConnected(user)
local i,j,share = strfind(user.sMyInfoString, ".+%$(%d+)%$$")
usershare = format("%0.2f", tonumber(share)/(1024*1024*1024))

local tmp
local tmp

tmp = tmp.."\t??? Your Nick: "..user.sName.."\r\n"
tmp = tmp.."\t??? Your IP: "..user.sIP.."\r\n"
tmp = tmp.."\t??? Your share: "..usershare.."GB\r\n"
tmp = tmp.."\t??? Total Friends Online: "..frmHub:GetUsersCount().."\r\n"

user:SendData(sBotName,tmp)
end


--function NewUserConnected(user)
-- local i,j,share = strfind(user.sMyInfoString, ".+%$(%d+)%$$")
-- usershare = format("%0.2f", tonumber(share)/(1024*1024*1024))

function NewUserConnected(user)
i,j,share = strfind(user.sMyInfoString, ".+%$(%d+)$")
-- this if routine is checking so if the share cannot be extracted , shre equals to zero. and
-- prevents nil / 1024 * 1024 * 1024 (which are causing the error)
if share == nil then
share = 0
end
usershare = format("%0.2f", tonumber(share)/(1024*1024*1024))

local tmp

tmp = tmp.."\t??? Your Nick: "..user.sName.."\r\n"
tmp = tmp.."\t??? Your IP: "..user.sIP.."\r\n"
tmp = tmp.."\t??? Your share: "..usershare.."GB\r\n"
tmp = tmp.."\t??? Total Friends Online: "..frmHub:GetUsersCount().."\r\n"

user:SendData(sBotName,tmp)
end


but i think it can be more short/ less memory....
can anyone  help me make it better ????
thanks
Title:
Post by: uNiOn on 09 March, 2004, 17:48:09
hey m8 did try this script out but when i log on as an operator it shiws me how mutch im sharing,,,,
And when i logg on as an user it says my share is zero
Cheers =)
Title:
Post by: uNiOn on 09 March, 2004, 17:50:14
and oe more thungy it comes as a pm when im op... but comes in the main chat when im an user only... =)
Title:
Post by: kepp on 09 March, 2004, 19:48:34
sBotName = "Bot_Name"

frmHub:RegBot(sBotName)

function GetOnline(pro)
local user,t = GetUsersByProfile(pro),0
for index,val in user do
if GetItemByName(user) then
t = t + 1
end
end
return t
end

function OpConnected(user)
local i,j,share = strfind(user.sMyInfoString, ".+%$(%d+)%$$")
usershare = format("%0.2f", tonumber(share)/(1024*1024*1024))

local tmp
tmp = "Welcome to "..frmHub:GetHubName().."\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Your Nick: "..user.sName.."\r\n"
tmp = tmp.."\t??? Your IP: "..user.sIP.."\r\n"
tmp = tmp.."\t??? Your share: "..usershare.."GB\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Hub Name: "..frmHub:GetHubName().."\r\n"
tmp = tmp.."\t??? Hub Address: ....\r\n"
tmp = tmp.."\t??? Hub Desc: "..frmHub:GetHubDescr().."\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? The Hub Cmd's >>> type !help and !rules. Please Read and Abide by them! \r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Masters Online: "..GetOnline("Master").."\r\n"
tmp = tmp.."\t??? Operators Online: "..GetOnline("Operator").."\r\n"
tmp = tmp.."\t??? VIPs Online: "..GetOnline("VIP").."\r\n"
tmp = tmp.."\t??? REGs Online: "..GetOnline("Reg").."\r\n"
tmp = tmp.."\ \r\n"

user:SendPM(sBotName,tmp)
end


--function NewUserConnected(user)
-- local i,j,share = strfind(user.sMyInfoString, ".+%$(%d+)%$$")
-- usershare = format("%0.2f", tonumber(share)/(1024*1024*1024))

function NewUserConnected(user)
i,j,share = strfind(user.sMyInfoString, ".+%$(%d+)$")
-- this if routine is checking so if the share cannot be extracted , shre equals to zero. and
-- prevents nil / 1024 * 1024 * 1024 (which are causing the error)
if share == nil then
share = 0
end
usershare = format("%0.2f", tonumber(share)/(1024*1024*1024))

local tmp
tmp = "Welcome to "..frmHub:GetHubName().."\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Your Nick: "..user.sName.."\r\n"
tmp = tmp.."\t??? Your IP: "..user.sIP.."\r\n"
tmp = tmp.."\t??? Your share: "..usershare.."GB\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Hub Name: "..frmHub:GetHubName().."\r\n"
tmp = tmp.."\t??? Hub Address: ....\r\n"
tmp = tmp.."\t??? Hub Desc: "..frmHub:GetHubDescr().."\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? The Hub Cmd's >>> type !help and !rules. Please Read and Abide by them! \r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Users Online: "..frmHub:GetUsersCount().."\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? Masters Online: "..GetOnline("Master").."\r\n"
tmp = tmp.."\t??? Operators Online: "..GetOnline("Operator").."\r\n"
tmp = tmp.."\t??? VIPs Online: "..GetOnline("VIP").."\r\n"
tmp = tmp.."\t??? REGs Online: "..GetOnline("Reg").."\r\n"
tmp = tmp.."\ \r\n"
tmp = tmp.."\t??? To see the NEWEST additions, type !tag \r\n"
tmp = tmp.."\t??? The Hub Cmd's >>> type !help and !rules. Read them!! \r\n"
tmp = tmp.."\t??? Be sure to READ EVERYTHING in the Main chat window!! \r\n"
tmp = tmp.."\t??? If you like this hub, don't forget to add it to your favorites by typing /fav in mainchat \r\n"

user:SendPM(sBotName,tmp)
end
Title:
Post by: uNiOn on 09 March, 2004, 20:46:07
It works perfect... but still got the little prob with it... it aint showing users share it still stands zero (0)....  

Cheers
Title:
Post by: uNiOn on 24 March, 2004, 14:57:09
It aint workin like it should.... still got problems with it.... when a normal user logs on it says that they share is 0.00 gb and it comes as pm for op's... can u fix that... thx...


Cheers