PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: angelsanges on 07 September, 2004, 16:00:10

Title: Non regged users...
Post by: angelsanges on 07 September, 2004, 16:00:10
it is possible a bot that checks users and cheks if they are regged in the hub...if not,the user is kicked after 15 minutes of connection to the hub?

please... ?(
Title:
Post by: bastya_elvtars on 07 September, 2004, 19:47:18
Bot="AccountChecker" --- bots name

timespan=15 -- in minutes

-------------- do not edit below

nonreg={}

dofile("nonregged.ini")

function NewUserConnected(user)
if user.iProfile==-1 then
nonreg[user.sName]=0
savenonregged()
end
end

function Main()
SetTimer(1000)
frmHub:RegBot(Bot)
StartTimer()
end

function OnTimer()
for a,b in nonreg do
if b b=b+1
savenonregged()
elseif b==timespan*60 then
user:SendPM(Bot,"You are not registered in here, and you will be now disconnected.")
user:Disconnect()
nonreg[user.sName]=nil
savenonregged()
end
end
end

function savenonregged()
writeto("nonregged.ini")
write("nonregged=\n")
for a,b in nonregged do
write("[\""..a.."\"]="..b..",\r\n")
end
write("}")
writeto()
end
Title:
Post by: angelsanges on 07 September, 2004, 21:30:45
thank you!
this will disconnect non regged users......a kick is usefull or not? its possible to kick instead of disconnect?
Title:
Post by: bastya_elvtars on 07 September, 2004, 23:40:03
Bot="AccountChecker" --- bots name



timespan=15 -- in minutes

kicktime=5 -- in minutes the timeban for a kick

-------------- do not edit below



nonreg={}



dofile("nonregged.ini")



function NewUserConnected(user)

if user.iProfile==-1 then

nonreg[user.sName]=0

savenonregged()

end

end



function Main()

SetTimer(1000)

frmHub:RegBot(Bot)

StartTimer()

end



function OnTimer()

for a,b in nonreg do

if b
b=b+1

savenonregged()

elseif b==timespan*60 then

user:SendPM(Bot,"You are not registered in here, and you will be now disconnected.")

user:TimeBan(kicktime)

nonreg[user.sName]=nil

savenonregged()

end

end

end



function savenonregged()

writeto("nonregged.ini")

write("nonregged=\n")

for a,b in nonregged do

write("[\""..a.."\"]="..b..",\r\n")

end

write("}")

writeto()

end
Title:
Post by: BottledHate on 08 September, 2004, 02:20:38
nerbos made one a lil while back.....

--## Force Self Register
--## Requested by venom
--## Made by nErBoS
--## Commands:
--## !regme - It regs yourself as a REG

sBot = "Force-Reg"

arrNotReg = {}
fNotReg = "notreg.dat"

--## Configuration ##--

uLaterPtokax = 0 -- Choose 0 if you are using a Ptokax version lower then 0.3.3.0
-- Choose 1 if you are using a Ptokax version 0.3.3.0 or above
iTime = 20 -- Time that a user have to stay in the HUB until it register himself (in minutes)

--## END ##--

function Main()
frmHub:RegBot(sBot)
LoadFromFile(fNotReg)
StartTimer()
end

function OnExit()
SaveToFile(fNotReg , arrNotReg , "arrNotReg")
end

function OnTimer()
local change,time,usr = 0
local iClock = clock()
for usr, time in arrNotReg do
if (GetItemByName(usr) == nil) then
arrNotReg[usr] = nil
change = 1
elseif (tonumber(iClock) - tonumber(time) > iTime*60) then
GetItemByName(usr):SendData(sBot, "Your "..iTime.." min has finished. You should have register yourself.")
GetItemByName(usr):SendData(sBot, "Banned...")
GetItemByName(usr):TempBan()
arrNotReg[usr] = nil
change = 1
end
end
if (change == 1) then
if (uLaterPtokax == 0) then
OnExit()
end
end
end


function NewUserConnected(user)
if (user.iProfile == -1) then
user:SendData(sBot, "You have "..iTime.." min to register yourself, or else you will be banned.")
user:SendData(sBot, "Use the command !regme .")
arrNotReg[user.sName] = clock()
end
end

function UserDisconnected(user)
if (user.iProfile == -1) then
arrNotReg[user.sName] = nil
if (uLaterPtokax == 0) then
OnExit()
end
end
end

function DataArrival(user, data)
if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
data = strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd == "!regme") then
local s,e,pass = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (pass == nil) then
user:SendPM(sBot, "Syntax Error, !regme , you must write a pass.")
elseif (user.iProfile ~= -1) then
user:SendPM(sBot, "You are already register as "..GetProfileName(user.iProfile))
else
AddRegUser(user.sName, pass, 3)
user:SendPM(sBot, "You have been register as REG. Your pass is: "..pass)
user:SendPM(sBot, "Reconnect to have effect.")
arrNotReg[user.sName] = nil
if (uLaterPtokax == 0) then
OnExit()
end
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 format("[%q]",key) or format("[%d]",key);

if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and 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)
writeto(file)
write(Serialize(table, tablename))
writeto()
end

function LoadFromFile(file)
if (readfrom(file) ~= nil) then
readfrom(file)
dostring(read("*all"))
readfrom()
end
end

--## Made by nErBoS


-BH