i want a script which alerts a user when a user he wants to talk with comes online
eg
+addalert kewl
u will be alerted when the user comes online
and when the user kewl comes online it ll send a pm to testing that kewl has joined the hub
something like this?
command is !online
-- OnlineChecker
-- Striped from MadSecurity
-- Made by Madman
-- Make a folder called Online in the Script folder
-- Added Op = NewUser, thanks Dessamator =)
-- Added so the command can be changed easy
-- Fixed Nick nil error
Bot = "OnlineChecker"
Cmd = "online"
function Main()
frmHub:RegBot(Bot)
end
function ChatArrival(curUser, data)
local data = string.sub(data,1, -2)
local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#](%S+)") -- Find commands
if cmd then -- Found command
cmd = string.lower(cmd)
local tCmds = {
[Cmd] = function(curUser, data)
local s,e,Nick = string.find(data, "%b<>%s+%S+%s+(%S+)") -- Find nick
if not Nick then
curUser:SendData(Bot, "I need a nick to check") return 1
end
OnNick = GetItemByName(Nick) -- Is nick online?
if OnNick then -- Yup
curUser:SendData(Bot, OnNick.sName.. " is online!") return 1 -- Tell us and stop
end
local file = io.open("Online/" ..Nick..".txt", "a+") -- Open file
if file then -- There was a file
file:write(curUser.sName.."\n") -- Add this
file:close() -- Close it
else -- There was no file
local file = io.open("Online/" ..Nick..".txt", "w+") -- Open in write mode
file:write(curUser.sName.. "\n") -- Write/create
file:close() -- Close
end
curUser:SendData(Bot, "Online check added 2 " ..Nick) return 1 -- tell us it's done
end,
}
if tCmds[cmd] then -- If the command was in table
return tCmds[cmd](curUser, data) -- Then execute it...
end
end
end
function NewUserConnected(curUser)
local file = io.open("Online/" ..curUser.sName.. ".txt")
if file then
file:close()
local file = io.input("Online/" ..curUser.sName.. ".txt")
while 1 do
local line = io.read()
if line == nil then
break
else
local s,e,Nick = string.find(line, "(%S+)")
OnNick = GetItemByName(Nick)
if OnNick then
OnNick:SendPM(Bot, curUser.sName.. " just went online @ " ..os.date("%X"))
end
end
end
file:close()
os.remove("Online/" ..curUser.sName.. ".txt")
end
end
OpConnected = NewUserConnected
[21:29] Syntax C:\ptokax\scripts\alert.lua:26: attempt to index local `file' (a nil value)
this is the error i get
i'm not at home atm.. but will check on it when i come home.. did u create the Online folder?
*edit*
made a small change... copy it again... and if u still get the error and have the Online folder... show me what you wrote to get the error....
i am not getting a pm instead i get in the main chat
Private message from OnlineChecker: testing just went online @ 10:31:38
and i havent touched the script :)
my bad...
Add this under
Bot = "OnlineChecker"
function Main()
frmHub:RegBot(Bot)
end
i want all users to use the cmd now only the ops can
hmm, u must be doing something wrong,there's nothing in that script stating that only ops can use the command, although the script is missing the "NewUserConnected = OpConnected"
no m8 didnt touch the script
have a look i tried to use the cmd as a reg user and it says you cant use this command
that error is probably from another script, there's nothing like that in this one !
hey i checked that script again
the problem appears when i run the script with the user hider script when i remove the user hider script it works fine
Then that script probarly has the command online 2... i updated the script.. copy it again and change the line
Cmd = "online"
to anyting you want...maybe
Cmd = "addalert"
And thanks Dessamator 4 reminding of the OpConnected = NewUserConnected =)
[21:23] Syntax C:\ptokax0.3.3.21\scripts\addalert.lua:37: attempt to index local `file' (a nil value)
ok got it t work.
can online check be added only to reg users
if user kkkk is not regged in the hub other users cant add online check to him.
madman pls find time for my request.
QuoteOriginally posted by kunal
madman pls find time for my request.
Sry dude... must have missed this thread...
-- OnlineChecker
-- Striped from MadSecurity
-- Made by Madman
-- Make a folder called Online in the Script folder
-- Added Op = NewUser, thanks Dessamator =)
-- Added so the command can be changed easy
-- Fixed Nick nil error
-- Added only reg user can be checked
Bot = "OnlineChecker"
Cmd = "online"
function Main()
frmHub:RegBot(Bot)
end
function ChatArrival(curUser, data)
local data = string.sub(data,1, -2)
local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#](%S+)") -- Find commands
if cmd then -- Found command
cmd = string.lower(cmd)
local tCmds = {
[Cmd] = function(curUser, data)
local s,e,Nick = string.find(data, "%b<>%s+%S+%s+(%S+)") -- Find nick
if not Nick then
curUser:SendData(Bot, "I need a nick to check") return 1
end
if frmHub:isNickRegged(Nick) then -- Is nick regged
OnNick = GetItemByName(Nick) -- Is nick online?
if OnNick then -- Yup
curUser:SendData(Bot, OnNick.sName.. " is online!") return 1 -- Tell us and stop
end
local file = io.open("Online/" ..Nick..".txt", "a+") -- Open file
if file then -- There was a file
file:write(curUser.sName.."\n") -- Add this
file:close() -- Close it
else -- There was no file
local file = io.open("Online/" ..Nick..".txt", "w+") -- Open in write mode
file:write(curUser.sName.. "\n") -- Write/create
file:close() -- Close
end
curUser:SendData(Bot, "Online check added 2 " ..Nick) -- tell us it's done
else
curUser:SendData(Bot, Nick.. " is not regged and cant be added to online check")
end
return 1
end,
}
if tCmds[cmd] then -- If the command was in table
return tCmds[cmd](curUser, data) -- Then execute it...
end
end
end
function NewUserConnected(curUser)
local file = io.open("Online/" ..curUser.sName.. ".txt")
if file then
file:close()
local file = io.input("Online/" ..curUser.sName.. ".txt")
while 1 do
local line = io.read()
if line == nil then
break
else
local s,e,Nick = string.find(line, "(%S+)")
OnNick = GetItemByName(Nick)
if OnNick then
OnNick:SendPM(Bot, curUser.sName.. " just went online @ " ..os.date("%X"))
end
end
end
file:close()
os.remove("Online/" ..curUser.sName.. ".txt")
end
end
OpConnected = NewUserConnected
*Edit*
Fixed an small error..
thank you madman. :)