PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: Dessamator on 21 May, 2005, 16:22:30

Title: User/Profile Account manager v1.1
Post by: Dessamator on 21 May, 2005, 16:22:30
--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
Title:
Post by: 6Marilyn6Manson6 on 21 May, 2005, 17:10:38
Change:
--Request By Marylin Manson(or something like it)

to:

--Request By 6Marilyn6Manson6(or something like it)

hihihi now comment is correct :P LooooooooL
Title:
Post by: Dessamator on 21 May, 2005, 17:51:09
Done !
Title:
Post by: 6Marilyn6Manson6 on 21 May, 2005, 19:13:02
Now is ok :P
Title:
Post by: TommyGun on 22 May, 2005, 02:58:25
Works perfect! Thanks
Title:
Post by: Dessamator on 22 May, 2005, 10:05:35
QuoteOriginally posted by TommyGun
Works perfect! Thanks
ur welcome !
Title: Profiles
Post by: XPMAN on 29 May, 2005, 16:09:10
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?
Title:
Post by: Dessamator on 29 May, 2005, 18:26:10
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 !
Title: hmm
Post by: XPMAN on 29 May, 2005, 20:06:32
Meanie...............  :D
Title:
Post by: Dessamator on 29 May, 2005, 21:06:35
QuoteOriginally posted by XPMAN
Meanie...............  :D
indeed,  ;)
Title:
Post by: sneaky on 07 August, 2005, 16:30:32
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 :)
Title:
Post by: Dessamator on 07 August, 2005, 17:08:19
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
Title:
Post by: sneaky on 07 August, 2005, 20:58:01
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
Title:
Post by: Dessamator on 07 August, 2005, 21:40:42
nice to hear :)