--User/Profile Account manager v1.1
--By Dessamator
--Request By 6Marilyn6Manson6(or something like it)
--Commands : !regenable -- to enable an account
-- !regdisable -- to disable an account
-- !regstatus -- to see disabled account
-- !disableprofile -- to disable a profile
-- !enableprofile -- to enable a profile
-- !dprofiles -- to see disabled profiles
tReg = {}
tProfiles = {}
file ="accounts.dat"
file1="profiles.dat"
--Config
bot =frmHub:GetHubBotName() -- Bot name
--
function Main()
LoadFromFile(file)
LoadFromFile(file1)
end
function ChatArrival(user,data)
data=string.sub(data, 1,-2)
s,e,cmd,usr=string.find(data,"%b<>%s+(%S+)%s+(%S+)")
if user.bOperator then
if cmd=="!regdisable" and not(tReg[usr]) then
tReg[usr] = 1
user:SendData(bot,usr.." has been disabled!")
return 1
elseif cmd=="!regenable" and (tReg[usr]) then
tReg[usr] =nil
user:SendData(bot,usr.." has been enabled!")
return 1
elseif cmd=="!disableprofile" and tonumber(usr) then
tProfiles[usr] = 1
user:SendData(bot,GetProfileName(usr).." Profile has been disabled!")
return 1
elseif cmd=="!enableprofile" and tonumber(usr) then
tProfiles[usr] = nil
user:SendData(bot,GetProfileName(usr).." Profile has been enabled!")
return 1
end
s,e,cmd,usr=string.find(data,"%b<>%s+(%S+)")
if cmd=="!regstatus" then
local temp="\r\n\These are the disabled accounts :\r\n"
for tUser,pos in tReg do
temp=temp.."\t\Nick :"..tUser.."\r\n"
end
user:SendData(bot,temp)
elseif cmd=="!dprofiles" then
local temp="\r\n\These are the disabled Profiles :\r\n"
for profile,pos in tProfiles do
temp=temp.."\t\Profile : "..GetProfileName(profile).."\r\n"
end
user:SendData(bot,temp)
end
end
end
function OnExit()
SaveToFile(file, tReg,"tReg")
SaveToFile(file1, tProfiles,"tProfiles")
end
function ValidateNickArrival(User, Data)
for usr,pos in tReg do
if User.sName == usr then
User:SendData(bot,"Your account has been disabled!")
DisconnectByName(User.sName)
return 1
end
end
for profile,pos in tProfiles do
if User.iProfile == tonumber(profile) then
User:SendData(bot,"Your Profile has been disabled!")
DisconnectByName(User.sName)
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
Change:
--Request By Marylin Manson(or something like it)
to:
--Request By 6Marilyn6Manson6(or something like it)
hihihi now comment is correct :P LooooooooL
Done !
Now is ok :P
Works perfect! Thanks
QuoteOriginally posted by TommyGun
Works perfect! Thanks
ur welcome !
I have tried this script ( which is very kool :) ) . But it seems that ANY profile has the ability to do this instead of just MASTERS and Ops. I tested it several times before posting, Reg members can use the commands as well as MASTERS. Is there something maybe I can change in the script so as only MASTERS and Ops have these rights?
QuoteOriginally posted by XPMAN
I have tried this script ( which is very kool :) ) . But it seems that ANY profile has the ability to do this instead of just MASTERS and Ops. I tested it several times before posting, Reg members can use the commands as well as MASTERS. Is there something maybe I can change in the script so as only MASTERS and Ops have these rights?
lol, i did it intentionally , to help others learn, well to add that
just edit the code like this ::
function ChatArrival(user,data)
data=string.sub(data, 1,-2)
s,e,cmd,usr=string.find(data,"%b<>%s+(%S+)%s+(%S+)")
[COLOR=blue]if user.bOperator the[/COLOR] n
if cmd=="!regdisable" and not(tReg[usr]) then
tReg[usr] = 1
user:SendData(bot,usr.." has been disabled!")
return 1
elseif cmd=="!regenable" and (tReg[usr]) then
tReg[usr] =nil
user:SendData(bot,usr.." has been enabled!")
return 1
elseif cmd=="!disableprofile" and tonumber(usr) then
tProfiles[usr] = 1
user:SendData(bot,GetProfileName(usr).." Profile has been disabled!")
return 1
elseif cmd=="!enableprofile" and tonumber(usr) then
tProfiles[usr] = nil
user:SendData(bot,GetProfileName(usr).." Profile has been enabled!")
return 1
end
s,e,cmd,usr=string.find(data,"%b<>%s+(%S+)")
if cmd=="!regstatus" then
local temp="\r\n\These are the disabled accounts :\r\n"
for tUser,pos in tReg do
temp=temp.."\t\Nick :"..tUser.."\r\n"
end
user:SendData(bot,temp)
elseif cmd=="!dprofiles" then
local temp="\r\n\These are the disabled Profiles :\r\n"
for profile,pos in tProfiles do
temp=temp.."\t\Profile : "..GetProfileName(profile).."\r\n"
end
user:SendData(bot,temp)
[COLOR=blue]end[/COLOR]
end
end
and add those lines in blue !
Meanie............... :D
QuoteOriginally posted by XPMAN
Meanie............... :D
indeed, ;)
works fine! nice script it possible to make right click menu for this script with this commands???
--Commands : !regenable -- to enable an account
-- !regdisable -- to disable an account
-- !regstatus -- to see disabled account
-- !disableprofile -- to disable a profile
-- !enableprofile -- to enable a profile
-- !dprofiles -- to see disabled profiles
thx anyway :)
well, u can do it urself , check the lua5 right click howto, if u still cant after trying that, some1 will make it for u
Done! works fine for me :))
--User/Profile Account manager v1.1
--By Dessamator
--Add Right Click Menu By Sneaky
--Request By 6Marilyn6Manson6(or something like it)
--Commands : !regenable -- to enable an account
-- !regdisable -- to disable an account
-- !regstatus -- to see disabled account
-- !disableprofile -- to disable a profile
-- !enableprofile -- to enable a profile
-- !dprofiles -- to see disabled profiles
tReg = {}
tProfiles = {}
file ="accounts.dat"
file1="profiles.dat"
--Config
bot =frmHub:GetHubBotName() -- Bot name
--
function Main()
LoadFromFile(file)
LoadFromFile(file1)
end
function ChatArrival(user,data)
data=string.sub(data, 1,-2)
s,e,cmd,usr=string.find(data,"%b<>%s+(%S+)%s+(%S+)")
if user.bOperator then
if cmd=="!regdisable" and not(tReg[usr]) then
tReg[usr] = 1
user:SendData(bot,usr.." has been disabled!")
return 1
elseif cmd=="!regenable" and (tReg[usr]) then
tReg[usr] =nil
user:SendData(bot,usr.." has been enabled!")
return 1
elseif cmd=="!disableprofile" and tonumber(usr) then
tProfiles[usr] = 1
user:SendData(bot,GetProfileName(usr).." Profile has been disabled!")
return 1
elseif cmd=="!enableprofile" and tonumber(usr) then
tProfiles[usr] = nil
user:SendData(bot,GetProfileName(usr).." Profile has been enabled!")
return 1
end
s,e,cmd,usr=string.find(data,"%b<>%s+(%S+)")
if cmd=="!regstatus" then
local temp="\r\n\These are the disabled accounts :\r\n"
for tUser,pos in tReg do
temp=temp.."\t\Nick :"..tUser.."\r\n"
end
user:SendData(bot,temp)
elseif cmd=="!dprofiles" then
local temp="\r\n\These are the disabled Profiles :\r\n"
for profile,pos in tProfiles do
temp=temp.."\t\Profile : "..GetProfileName(profile).."\r\n"
end
user:SendData(bot,temp)
end
end
end
function OnExit()
SaveToFile(file, tReg,"tReg")
SaveToFile(file1, tProfiles,"tProfiles")
end
function ValidateNickArrival(User, Data)
for usr,pos in tReg do
if User.sName == usr then
User:SendData(bot,"Your account has been disabled!")
DisconnectByName(User.sName)
return 1
end
end
for profile,pos in tProfiles do
if User.iProfile == tonumber(profile) then
User:SendData(bot,"Your Profile has been disabled!")
DisconnectByName(User.sName)
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 OpConnected(curUser)
if curUser.bUserCommand then
curUser:SendData("$UserCommand 1 3 Profile Account\\Enable An Account$<%[mynick]> !regenable %[line:Account]|")
curUser:SendData("$UserCommand 1 3 Profile Account\\Disable An Account$<%[mynick]> !regdisable %[line:Account]|")
curUser:SendData("$UserCommand 1 3 Profile Account\\See Disabled Account$<%[mynick]> !regstatus|")
curUser:SendData("$UserCommand 1 3 Profile Account\\Disable A Profile$<%[mynick]> !disableprofile %[line:Profile]|")
curUser:SendData("$UserCommand 1 3 Profile Account\\Enable A Profile$<%[mynick]> !enableprofile %[line:Profile]|")
curUser:SendData("$UserCommand 1 3 Profile Account\\See Disabled Profiles$<%[mynick]> !dprofiles|")
end
end
nice to hear :)