PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: kEwL on 14 July, 2005, 14:34:51

Title: user alert
Post by: kEwL on 14 July, 2005, 14:34:51
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
Title:
Post by: Madman on 14 July, 2005, 16:14:35
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
Title:
Post by: kEwL on 14 July, 2005, 18:00:24
[21:29] Syntax C:\ptokax\scripts\alert.lua:26: attempt to index local `file' (a nil value)

this is the error i get
Title:
Post by: Madman on 14 July, 2005, 18:57:40
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....
Title:
Post by: kEwL on 15 July, 2005, 07:02:38
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 :)
Title:
Post by: Madman on 15 July, 2005, 07:15:02
my bad...
Add this under
Bot = "OnlineChecker"
function Main()
frmHub:RegBot(Bot)
end
Title:
Post by: kEwL on 15 July, 2005, 07:33:38
i want all users to use the cmd now only the ops can
Title:
Post by: Dessamator on 15 July, 2005, 10:25:43
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"
Title:
Post by: kEwL on 15 July, 2005, 10:49:48
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
Title:
Post by: Dessamator on 15 July, 2005, 12:58:11
that error is probably from another script, there's nothing like that in this one !
Title:
Post by: kEwL on 15 July, 2005, 13:10:55
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
Title:
Post by: Madman on 15 July, 2005, 15:34:30
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 =)
Title:
Post by: kunal on 03 September, 2005, 17:53:07
[21:23] Syntax C:\ptokax0.3.3.21\scripts\addalert.lua:37: attempt to index local `file' (a nil value)
Title:
Post by: kunal on 16 September, 2005, 15:01:28
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.
Title:
Post by: kunal on 17 September, 2005, 08:08:51
madman pls find time for my request.
Title:
Post by: Madman on 17 September, 2005, 08:53:49
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..
Title:
Post by: kunal on 17 September, 2005, 09:25:59
thank you madman. :)