--logonmsg with on/off trigs
--By Dessamator(some ideas and bug testing by jiten)
tConnect ={}
bot=frmHub:GetHubBotName()
file="onconnect.dat"
tDelay={}
---
function Main()
LoadFromFile(file)
SetTimer(1000)
StartTimer()
end
function ChatArrival(user, data)
data=string.sub(data,1,string.len(data)-1)
_,_,cmd=string.find(data, "%b<>%s+(%S+)")
if user.iProfile then
if (cmd=="!connectmsgoff") and tConnect[user.sName] then
tConnect[user.sName] =nil
user:SendData(bot,"Done, your connection to the hub will no longer be announced!!")
return 1
elseif (cmd=="!connectmsgon") then
tConnect[user.sName] =1
user:SendData(bot,"Done, your connection to the hub be announced!!")
return 1
end
end
end
ToArrival=ChatArrival
function NewUserConnected(user)
tDelay[user.sName] ={}
tDelay[user.sName]["time"] = "1"
end
OpConnected = NewUserConnected
function OnTimer()
for i,v in tDelay do
Delay = tDelay[i]["time"]
Delay = Delay- 1
tDelay[i]["time"] =Delay
if tDelay[i]["time"] ==0 and tConnect[GetItemByName(i).sName] then
if (GetItemByName(i).bRegistered) then
SendToAll(bot,GetProfileName(GetUserProfile(i)).." "..i.." Has Entered the hub!!")
else
SendToAll(bot,"User "..i.." Has Entered the hub!!")
end
end
end
end
--><----
function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.." = {\n"
for key, value in tTable do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end
function SaveToFile(file , table , tablename)
local handle = io.open(file,"w+")
handle:write(Serialize(table, tablename))
handle:flush()
handle:close()
end
function LoadFromFile(file)
local handle = io.open(file,"r")
if (handle ~= nil) then
dofile(file)
handle:flush()
handle:close()
end
end
function OnExit()
SaveToFile(file , tConnect , "tConnect")
tDelay[user.sName]["time"] = nil
end
Just in case someone asks whats it for, here's the answer, a simple script to activate or deactivate the logon msg for a user !!
looks nice, now you can advance with making their own messages , here's some info ;)
-- Custom Login by Typhoon?
-- Lua 5 ....
-- [URL]http://Piratez.dk[/URL]
-- Real Quick old Rip from old Sentinel? version..
-- Commands are
-- +newlogin - This changes the default login :)
-- +newlogout - This changes the default logout message :)
-- your nick is auto inserted in the midle of the text
BotName = "-Neo-"
sLogins = "Loginout.txt"
Announce = { LogInTable = {} , LogoutTable = {}, }
dofile(sLogins)
function Main()
frmHub:RegBot(BotName)
end
function NewUserConnected(user)
if Announce.LogInTable[user.sName] then
local msg = Announce.LogInTable[user.sName]
SendToAll(BotName,msg)
end
end
function OpConnected(user)
if Announce.LogInTable[user.sName] then
local msg = Announce.LogInTable[user.sName]
SendToAll(BotName,msg)
end
end
function ChatArrival(user, data)
local s,e,cmd = string.find( data, "%b<>%s+(%S*)" )
if cmd == "+newlogin" then
ChangeLogin(user,data)
elseif cmd == "+newlogout" then
ChangeLogout(user,data)
end
return 1
end
ChangeLogin = function(user,data)
local doGetProfile = GetProfileName(user.iProfile)
local s,e,cmd,message,message2 = string.find( data, "%b<>%s+(%S+)%s+(.*)%s:%s(.*)" )
if message == nil or message2 == nil then
Announce.LogInTable[user.sName] = "Welcomes "..doGetProfile.." "..user.sName.." Has entered the hub"
Save_File(sLogins,Announce, "Announce")
user:SendData(BotName,"Standard Login Enabled: "..doGetProfile.." "..user.sName.." Has entered the hub ")
user:SendData(BotName,"If you want to change it then use this : +newlogin message1 : message2")
else
Announce.LogInTable[user.sName] = "Welcomes "..message.." "..user.sName.." "..message2
Save_File(sLogins,Announce, "Announce")
user:SendData(BotName,"Login Changed to: "..message.." "..user.sName.." "..message2)
end
return 1
end
ChangeLogout = function(user,data)
local doGetProfile = GetProfileName(user.iProfile)
local s,e,cmd,message,message2 = string.find( data, "%b<>%s+(%S+)%s+(.*)%s:%s(.*)" )
if message == nil and message2 == nil then
Announce.LogoutTable[user.sName] = "Goodbyes to the "..doGetProfile.." "..user.sName.." Has left the hub"
Save_File(sLogins,Announce, "Announce")
user:SendData(BotName,"Standard Logout Enabled: "..doGetProfile.." "..user.sName.." Has left the hub ")
user:SendData(BotName,"If you want to change it then use this : +newlogout message1 : message2")
else
Announce.LogoutTable[user.sName] = "Goodbyes to "..message.." "..user.sName.." "..message2
Save_File(sLogins,Announce, "Announce")
user:SendData(BotName,"Logout Changed to: "..message.." "..user.sName.." "..message2)
end
return 1
end
-- Serialize --
Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" );
for key, value in tTable do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
Save_Serialize(value, sKey, hFile, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
hFile:write( sTab.."\t"..sKey.." = "..sValue);
end
hFile:write( ",\n");
end
hFile:write( sTab.."}");
end
Save_File = function(file,table , tablename )
local hFile = io.open (file , "w")
Save_Serialize(table, tablename, hFile);
hFile:close()
end
Typhoon?
*edit* copy paste is dangerous :)
ouch : function NewUserConnected(user,data)
:P
hmm, typhoon, so ur suggesting that i should add those extra functions???
if you like do so , i just share what i have in apropriate similar threads so others might get any use of it , my code could be modified but as it says it's an old rip from first Lua 5 version of Sentinel? , before i got my hands on the beta :)
Typhoon?
QuoteOriginally posted by Typhoon?
if you like do so , i just share what i have in apropriate similar threads so others might get any use of it , my code could be modified but as it says it's an old rip from first Lua 5 version of Sentinel? , before i got my hands on the beta :)
Typhoon?
hmm ok will do asap(less than a week hopefully)
anyways i dont think there will be a lot of changes, ur main code will b there, just a simple if statement probably !!
QuoteOriginally posted by kepp
ouch : function NewUserConnected(user,data)
:P
lol, hadnt seen that, post edited, :))
hmm, typhoon that script of yours is buggy, doesnt allow any msg in main!!!
ill try to sort it out l8r
QuoteOriginally posted by Dessamator
hmm, typhoon that script of yours is buggy, doesnt allow any msg in main!!!
ill try to sort it out l8r
just a misplaced return 1 .. remove it from ChatArrival then it works just tested it .. a bit to quickly ripped and a long time ago
Typhoon?
QuoteOriginally posted by Typhoon?
QuoteOriginally posted by Dessamator
hmm, typhoon that script of yours is buggy, doesnt allow any msg in main!!!
ill try to sort it out l8r
just a misplaced return 1 .. remove it from ChatArrival then it works just tested it .. a bit to quickly ripped and a long time ago
Typhoon?
yah i noticed it, and it also had another bug, either way its corrected(hopefully)
here it goes :::
-- Loginmsg v2 with on/off trigs
-- By Dessamator
-- Custom Login by Typhoon?
-- Lua 5 ....
-- [URL]http://Piratez.dk[/URL]
-- Real Quick old Rip from old Sentinel? version..
-- Commands are
-- !newlogin - This changes the default login :)
-- !newlogout - This changes the default logout message :)
-- your nick is auto inserted in the midle of the text
tConnect ={}
BotName =frmHub:GetHubBotName()
fConnect="onconnect.dat"
tDelay={}
sLogins = "Loginout.txt"
Announce = { LogInTable = {} , LogoutTable = {}, }
function Main()
LoadFromFile(sLogins)
LoadFromFile(fConnect)
frmHub:RegBot(BotName)
SetTimer(1000)
StartTimer()
end
function NewUserConnected(user)
tDelay[user.sName] ={}
tDelay[user.sName]["time"] = "1"
end
function OnTimer()
for i,v in tDelay do
Delay = tDelay[i]["time"]
Delay = Delay- 1
tDelay[i]["time"] =Delay
if tDelay[i]["time"] ==0 then
if Announce.LogInTable[GetItemByName(i).sName] and tConnect[GetItemByName(i).sName] then
local msg = Announce.LogInTable[GetItemByName(i).sName]
SendToAll(BotName,msg)
end
end
end
end
OpConnected = NewUserConnected
function ChatArrival(user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find( data, "%b<>%s+(%S*)")
if (cmd == "!newlogin") then
ChangeLogin(user,data)
return 1
elseif cmd == ("!newlogout") then
ChangeLogout(user,data)
return 1
elseif (cmd=="!msgoff") then
tConnect[user.sName] =nil
user:SendData(BotName,"Done, your connection to the hub will no longer be announced!!")
return 1
elseif (cmd=="!msgon") then
tConnect[user.sName] =1
user:SendData(BotName,"Done, your connection to the hub be announced!!")
return 1
end
if user.bRegistered then
doGetProfile = GetProfileName(user.iProfile)
else
doGetProfile = "User"
end
end
ToArrival=ChatArrival
ChangeLogin = function(user,data)
local s,e,cmd,message,message2 = string.find( data, "%b<>%s+(%S+)%s+(.*)%s:%s(.*)" )
if message == nil or message2 == nil then
Announce.LogInTable[user.sName] = "Welcomes "..doGetProfile.." "..user.sName.." Has entered the hub"
user:SendData(BotName,"Standard Login Enabled: "..doGetProfile.." "..user.sName.." Has entered the hub ")
user:SendData(BotName,"If you want to change it then use this : !newlogin message1 : message2")
else
Announce.LogInTable[user.sName] = "Welcomes "..message.." "..user.sName.." "..message2
user:SendData(BotName,"Login Changed to: "..message.." "..user.sName.." "..message2)
end
end
ChangeLogout = function(user,data)
local s,e,cmd,message,message2 = string.find( data, "%b<>%s+(%S+)%s+(.*)%s:%s(.*)" )
if message == nil and message2 == nil then
Announce.LogoutTable[user.sName] = "Goodbyes to the "..doGetProfile.." "..user.sName.." Has left the hub"
user:SendData(BotName,"Standard Logout Enabled: "..doGetProfile.." "..user.sName.." Has left the hub ")
user:SendData(BotName,"If you want to change it then use this : !newlogout message1 : message2")
else
Announce.LogoutTable[user.sName] = "Goodbyes to "..message.." "..user.sName.." "..message2
user:SendData(BotName,"Logout Changed to: "..message.." "..user.sName.." "..message2)
end
end
-- Serialize --
Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" );
for key, value in tTable do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
Save_Serialize(value, sKey, hFile, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
hFile:write( sTab.."\t"..sKey.." = "..sValue);
end
hFile:write( ",\n");
end
hFile:write( sTab.."}");
end
Save_File = function(file,table , tablename )
local hFile = io.open (file , "w")
Save_Serialize(table, tablename, hFile);
hFile:close()
end
function LoadFromFile(file)
local handle = io.open(file,"r")
if (handle ~= nil) then
dofile(file)
handle:flush()
handle:close()
end
end
function OnExit()
Save_File(sLogins,Announce, "Announce")
Save_File(fConnect,tConnect , "tConnect")
end
Done !!
Keep it coming m8 ;)
looking good m8 .. :)
Typhoon?
like i said, just a simple if statement, and removing some extra "rubbish", :D, and checking a buggy chatarrival !!
-- Loginmsg v2.1 with on/off trigs (removed timer,added myinfoarrival)
-- By Dessamator
-- Custom Login by Typhoon™
-- Lua 5 ....
-- [URL]http://Piratez.dk[/URL]
-- Real Quick old Rip from old Sentinel™ version..
-- Commands are
-- !newlogin - This changes the default login :)
-- !newlogout - This changes the default logout message :)
-- your nick is auto inserted in the midle of the text
tConnect ={}
BotName =frmHub:GetHubBotName()
fConnect="onconnect.dat"
sLogins = "Loginout.txt"
Announce = { LogInTable = {} , LogoutTable = {}, }
function Main()
LoadFromFile(sLogins)
LoadFromFile(fConnect)
frmHub:RegBot(BotName)
end
function NewUserConnected(user)
if Announce.LogInTable[user.sName] and tConnect[user.sName] then
msg = Announce.LogInTable[user.sName]
end
end
function MyINFOArrival(user,data)
if msg then
SendToAll(BotName,msg)
msg=nil
end
end
OpConnected = NewUserConnected
function ChatArrival(user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find( data, "%b<>%s+(%S*)")
if user.bRegistered then
doGetProfile = GetProfileName(user.iProfile)
else
doGetProfile = "User"
end
if (cmd == "!newlogin") then
ChangeLogin(user,data)
return 1
elseif cmd == ("!newlogout") then
ChangeLogout(user,data)
return 1
elseif (cmd=="!msgoff") then
tConnect[user.sName] =nil
user:SendData(BotName,"Done, your connection to the hub will no longer be announced!!")
return 1
elseif (cmd=="!msgon") then
tConnect[user.sName] =1
user:SendData(BotName,"Done, your connection to the hub be announced!!")
return 1
end
end
ToArrival=ChatArrival
ChangeLogin = function(user,data)
local s,e,cmd,message,message2 = string.find( data, "%b<>%s+(%S+)%s+(.*)%s:%s(.*)" )
if message == nil or message2 == nil then
Announce.LogInTable[user.sName] = "Welcomes "..doGetProfile.." "..user.sName.." Has entered the hub"
user:SendData(BotName,"Standard Login Enabled: "..doGetProfile.." "..user.sName.." Has entered the hub ")
user:SendData(BotName,"If you want to change it then use this : !newlogin message1 : message2")
else
Announce.LogInTable[user.sName] = "Welcomes "..message.." "..user.sName.." "..message2
user:SendData(BotName,"Login Changed to: "..message.." "..user.sName.." "..message2)
end
user:SendData(BotName,temp)
end
ChangeLogout = function(user,data)
local s,e,cmd,message,message2 = string.find( data, "%b<>%s+(%S+)%s+(.*)%s:%s(.*)" )
if message == nil and message2 == nil then
Announce.LogoutTable[user.sName] = "Goodbyes to the "..doGetProfile.." "..user.sName.." Has left the hub"
user:SendData(BotName,"Standard Logout Enabled: "..doGetProfile.." "..user.sName.." Has left the hub ")
user:SendData(BotName,"If you want to change it then use this : !newlogout message1 : message2")
else
Announce.LogoutTable[user.sName] = "Goodbyes to "..message.." "..user.sName.." "..message2
user:SendData(BotName,"Logout Changed to: "..message.." "..user.sName.." "..message2)
end
user:SendData(BotName,temp)
end
-- Serialize --
Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" );
for key, value in tTable do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
Save_Serialize(value, sKey, hFile, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
hFile:write( sTab.."\t"..sKey.." = "..sValue);
end
hFile:write( ",\n");
end
hFile:write( sTab.."}");
end
Save_File = function(file,table , tablename )
local hFile = io.open (file , "w")
Save_Serialize(table, tablename, hFile);
hFile:close()
end
function LoadFromFile(file)
local handle = io.open(file,"r")
if (handle ~= nil) then
dofile(file)
handle:flush()
handle:close()
end
end
function OnExit()
Save_File(sLogins,Announce, "Announce")
Save_File(fConnect,tConnect , "tConnect")
end
changed a few things, mayb for the best !!
Hi Dessamator
can you make this script so it is only op's that can change theirs login/out msg ?
hope you understand what i mean :rolleyes:
cheers
-- Loginmsg v2.1 with on/off trigs (removed timer,added myinfoarrival)
-- By Dessamator
-- Custom Login by Typhoon™
-- Lua 5 ....
-- [URL]http://Piratez.dk[/URL]
-- Real Quick old Rip from old Sentinel™ version..
-- Commands are
-- !newlogin - This changes the default login :)
-- !newlogout - This changes the default logout message :)
-- your nick is auto inserted in the midle of the text
-- Added right clickcommands with profiles by Cenobyte
-- Added Set To Profile by TT
SetTo = {
[0] = 1, -- Masters
[1] = 1, -- Operators
[2] = 1, -- Vips
[3] = 0, -- Regs
[4] = 1, -- Moderator
[5] = 1, -- NetFounder
[-1] = 0, -- Users
}
tConnect ={}
vMenu = "-=( Login/Logout )=-" -- Rightclick menu name
BotName = "-???j?-" -- Own botname
fConnect="onconnect.dat"
sLogins = "Loginout.txt"
SendComm = 1 -- Send user command [right click] "1"=yes "0"=no
Announce = { LogInTable = {} , LogoutTable = {}, }
function Main()
LoadFromFile(sLogins)
LoadFromFile(fConnect)
frmHub:RegBot(BotName)
end
function NewUserConnected(user)
if SendComm == 1 and SetTo[user.iProfile] == 1 then
user:SendData("$UserCommand 1 3 "..vMenu.."\\Change your login msg$<%[mynick]> !newlogin %[line:Start Message] : %[line:End Message]|")
user:SendData("$UserCommand 1 3 "..vMenu.."\\Turn your login on$<%[mynick]> !msgon|")
user:SendData("$UserCommand 1 3 "..vMenu.."\\Change your logout msg$<%[mynick]> !newlogout %[line:Start Message] : %[line:End Message]|")
user:SendData("$UserCommand 1 3 "..vMenu.."\\Turn your login off$<%[mynick]> !msgoff|")
if Announce.LogInTable[user.sName] and tConnect[user.sName] then
msg = Announce.LogInTable[user.sName]
end
end
end
function MyINFOArrival(user,data)
if msg then
SendToAll(BotName,msg)
msg=nil
end
end
OpConnected = NewUserConnected
function ChatArrival(user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find( data, "%b<>%s+(%S*)")
if user.bRegistered then
doGetProfile = GetProfileName(user.iProfile)
else
doGetProfile = "User"
end
if (cmd == "!newlogin") then
ChangeLogin(user,data)
return 1
elseif cmd == ("!newlogout") then
ChangeLogout(user,data)
return 1
elseif (cmd=="!msgoff") then
tConnect[user.sName] =nil
user:SendData(BotName,"Done, your connection to the hub will no longer be announced!!")
return 1
elseif (cmd=="!msgon") then
tConnect[user.sName] =1
user:SendData(BotName,"Done, your connection to the hub be announced!!")
return 1
end
end
ToArrival=ChatArrival
ChangeLogin = function(user,data)
local s,e,cmd,message,message2 = string.find( data, "%b<>%s+(%S+)%s+(.*)%s:%s(.*)" )
if message == nil or message2 == nil then
Announce.LogInTable[user.sName] = " "..doGetProfile.." "..user.sName.." Has entered the hub"
user:SendData(BotName,"Standard Login Enabled: "..doGetProfile.." "..user.sName.." Has entered the hub ")
user:SendData(BotName,"If you want to change it then use this : !newlogin message1 : message2")
else
Announce.LogInTable[user.sName] = ""..message.." "..user.sName.." "..message2
user:SendData(BotName,"Login Changed to: "..message.." "..user.sName.." "..message2)
end
user:SendData(BotName,temp)
end
ChangeLogout = function(user,data)
local s,e,cmd,message,message2 = string.find( data, "%b<>%s+(%S+)%s+(.*)%s:%s(.*)" )
if message == nil and message2 == nil then
Announce.LogoutTable[user.sName] = " "..doGetProfile.." "..user.sName.." Has left the hub"
user:SendData(BotName,"Standard Logout Enabled: "..doGetProfile.." "..user.sName.." Has left the hub ")
user:SendData(BotName,"If you want to change it then use this : !newlogout message1 : message2")
else
Announce.LogoutTable[user.sName] = " "..message.." "..user.sName.." "..message2
user:SendData(BotName,"Logout Changed to: "..message.." "..user.sName.." "..message2)
end
user:SendData(BotName,temp)
end
-- Serialize --
Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" );
for key, value in tTable do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
Save_Serialize(value, sKey, hFile, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
hFile:write( sTab.."\t"..sKey.." = "..sValue);
end
hFile:write( ",\n");
end
hFile:write( sTab.."}");
end
Save_File = function(file,table , tablename )
local hFile = io.open (file , "w")
Save_Serialize(table, tablename, hFile);
hFile:close()
end
function LoadFromFile(file)
local handle = io.open(file,"r")
if (handle ~= nil) then
dofile(file)
handle:flush()
handle:close()
end
end
function OnExit()
Save_File(sLogins,Announce, "Announce")
Save_File(fConnect,tConnect , "tConnect")
end
greetzz TT
wow thats was fast :D
many tnx it work perfect :]
cheers 8)
QuoteOriginally posted by GrinSlaW
wow thats was fast :D
many tnx it work perfect :]
cheers 8)
yep he saved me the hassle of changing it :)
hello
it?s possible to make the script send de mensage to all users like this:
vip [ user ] enter in the hub...
reg [ user ] enter in the hub...
but the op?s can modify ther mensage any way
best regards
badtrip
yep just change this :
if (cmd == "!newlogin") then
ChangeLogin(user,data)
return 1
elseif cmd == ("!newlogout") then
ChangeLogout(user,data)
return 1
elseif (cmd=="!msgoff") then
tConnect[user.sName] =nil
user:SendData(BotName,"Done, your connection to the hub will no longer be announced!!")
return 1
elseif (cmd=="!msgon") then
tConnect[user.sName] =1
user:SendData(BotName,"Done, your connection to the hub be announced!!")
return 1
end
to this :
if user.bOperator then
if (cmd == "!newlogin") then
ChangeLogin(user,data)
return 1
elseif cmd == ("!newlogout") then
ChangeLogout(user,data)
return 1
end
end
if (cmd=="!msgoff") then
tConnect[user.sName] =nil
user:SendData(BotName,"Done, your connection to the hub will no longer be announced!!")
return 1
elseif (cmd=="!msgon") then
tConnect[user.sName] =1
user:SendData(BotName,"Done, your connection to the hub be announced!!")
return 1
end
erm i dno if anyone has this problem
but for me the script works fine but outro's dont work
and with my vip's the script says its message 1-2 mins late.. im not hosting hub .. i dno if this is clash of other scripts running robocop disabled robocops intros n outros
so i dno..
sum1 enlighten me plz?
and outros dnt work at all