PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: venom on 17 August, 2004, 03:12:27

Title: are there any time limit scripts
Post by: venom on 17 August, 2004, 03:12:27
im lookin for a script for like if some1 doesnt register in 20mins they get a temp ban are there any scripts???????????????
Title:
Post by: Flux on 17 August, 2004, 03:19:53
That is interesting but why don't u use a script that does not allow guests to download anything only reg users can download...
Title:
Post by: nErBoS on 17 August, 2004, 14:45:52
Hi,

Hope it helps...

--## 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

Best regards, nErBoS