Well, I have a question. How do I convert this code to LUA 5 ? The problem is that the SendToVips isn't working anymore.
BotName = "?bot?"
controltrigs={["join"]=1,["login"]=2,["hub"]=3}
supervip = {}
fSuperVip = "logs/svip.txt" -- Path of file that contains SuperVips
function ChatArrival(user,data)
if not user.bOperator then
LoadFromFile(fSuperVip)
for key, value in controltrigs do
if( string.find( string.lower(data), key) ) then
s,e,onlymes = string.find(data, "%b<> (.*)")
SendPmToOps (BotName, "Control: <"..user.sName.."> ("..user.sIP..") told in main: "..onlymes.."")
SendToVips("Control: <"..user.sName.."> ("..user.sIP..") told in main: "..onlymes)
end
end
end
end
function ToArrival(user,data)
local _, _, to, from, msg = string.find(data, "^%$To:%s+(%S+)%s+From:%s+(%S+)%s-%$%b<>%s+(.*)|")
local nick = GetItemByName(to)
if not user.bOperator then
for key, value in controltrigs do
if( string.find( string.lower(data), key) ) then
s,e,whoTo,from,mes = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.*)")
SendPmToOps (BotName, "Control: <"..user.sName.."> ("..user.sIP..") said to <"..to.."> in PVT this: "..mes.."")
SendToVips("Control: <"..user.sName.."> ("..user.sIP..") said to <"..to.."> in PVT this: "..mes)
end
end
end
end
function SendToVips(msg)
local usr,aux
for usr, aux in supervip do
if (GetItemByName(usr) ~= nil) then
GetItemByName(usr):SendPM(BotName, msg)
end
end
end
function LoadFromFile(file)
local f,e = io.open( file, "r" )
if f then
local r = f:read( "*a" )
f:close()
return r
else
return nil,"loadfile failed: "..e
end
end
Thanks in advance.
Best regards,
jiten
here you go:
SendToVips = function(from,message)
for _,Users in GetUsersByProfile("VIP") do
SendToNick(Users, "<"..from.."> "..message)
end
end
SendPmToVips = function(from,message)
for _,Users in GetUsersByProfile("VIP") do
SendPmToNick(Users, from, message)
end
end
I guess I should work... not tested by Am pretty sure it should work.
// NL
Hi there NL. Well, I guess i didn't explain exactly what this script was meant for, so I'm going to post all of the script (the first post is edited).
This script warns the Operators and the KVIPs about certain triggers. The KVIP nicks are stored in a file - logs/svip.txt - like this:
supervip = {["kviptest"]=1,}
Thanks in advance.
Best regards,
jiten
Please add a "SendToLevel" and a "SendPmToLevel" function.
As you can see sacrifices have already begun ...
( Ooh and a way to get a table of all the connected userobjects too pretty pls ;)
Hi there...
Well, I tried to use NL's SendToVips and SendPmToVips but I get this error when typing any of the triggers:
Syntax ...ktop\16.04rls\scripts\warnvip.lua_5.0.lua:165: attempt to concatenate local `message' (a nil value)
Thanks in advance.
Best regards,
jiten
QuoteOriginally posted by jiten
Hi there...
Well, I tried to use NL's SendToVips and SendPmToVips but I get this error when typing any of the triggers:
Syntax ...ktop\16.04rls\scripts\warnvip.lua_5.0.lua:165: attempt to concatenate local `message' (a nil value)
Thanks in advance.
Best regards,
jiten
By the look of my code there should be no problem, have you used the function correct ???
SendToVips(BotName, "Your Message to VIP's here")
SendPmToVips(BotName, "Your Message to VIP's here")
Oops! The code was OK. Guess I was in the moon ;)
But, there's one problem. The message should be sent to the users stored in this file, so called KVIPs: "logs/svip.txt" and not to every VIP.
Best regards.
yah, i tried it also doesnt seem to b able to read nicks in a table something to do with the
Quotefor _,Users in supervip do
, dunno mayb im wrong
Hi,
The problem is on the LoadFile function, you are only reading the file not loading the code...
BotName = "?bot?"
controltrigs={["join"]=1,["login"]=2,["hub"]=3}
supervip = {}
fSuperVip = "logs/svip.txt" -- Path of file that contains SuperVips
function ChatArrival(user,data)
if not user.bOperator then
LoadFromFile(fSuperVip)
for key, value in controltrigs do
if( string.find( string.lower(data), key) ) then
s,e,onlymes = string.find(data, "%b<> (.*)")
SendPmToOps (BotName, "Control: <"..user.sName.."> ("..user.sIP..") told in main: "..onlymes.."")
SendToVips("Control: <"..user.sName.."> ("..user.sIP..") told in main: "..onlymes)
end
end
end
end
function ToArrival(user,data)
local _, _, to, from, msg = string.find(data, "^%$To:%s+(%S+)%s+From:%s+(%S+)%s-%$%b<>%s+(.*)|")
local nick = GetItemByName(to)
if not user.bOperator then
for key, value in controltrigs do
if( string.find( string.lower(data), key) ) then
s,e,whoTo,from,mes = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.*)")
SendPmToOps (BotName, "Control: <"..user.sName.."> ("..user.sIP..") said to <"..to.."> in PVT this: "..mes.."")
SendToVips("Control: <"..user.sName.."> ("..user.sIP..") said to <"..to.."> in PVT this: "..mes)
end
end
end
end
function SendToVips(msg)
local usr,aux
for usr, aux in supervip do
if (GetItemByName(usr) ~= nil) then
GetItemByName(usr):SendPM(BotName, msg)
end
end
end
function LoadFromFile(file)
local handle = io.open(file,"r")
if (handle ~= nil) then
dofile(file)
handle:flush()
handle:close()
end
end
Best regards, nErBoS
yap nerbos u were right, it works perfectly now, thanks :D
Thanks for the help, nErBoS.
Now it's working perfectly.