PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: Requiem on 05 April, 2005, 23:38:11

Title: RegOnly Timer
Post by: Requiem on 05 April, 2005, 23:38:11
Is it possible to make a script that makes hub a reg only hub between given day times like 20:00 - 24:00?
Title:
Post by: Dessamator on 06 April, 2005, 00:15:37


 -- Reg User Checker/banner
-- By Dessamator
 -- added time check from 20 ->24:00 (request by Requiem)
-- kick delay function by nerbos

sec = 1
min = 60*sec
iDelay = 60*sec -- Time of delay before ban the user
iBan = 5 -- Time of Ban in Minutes

arrDelay = {}
-- Activated on startup/then script is started
botname=frmHub:GetHubBotName()
function Main()
StartTimer()
frmHub:RegBot(botname)
end

-- called as often as the timer interval is set to
function OnTimer()
time()
if H=="20" or H=="21" or H=="22" or H=="23" or   H=="24" then
local now,nick,time = os.clock()
for nick, time in arrDelay do
if (now >= time+iDelay) then
if (GetItemByName(nick) ~= nil) then
GetItemByName(nick):SendPM(botname, "Regged Users only")
GetItemByName(nick):TimeBan(iBan)
end
arrDelay[nick] = nil
end
end
end
end
function UserDisconnected(curUser)
arrDelay[curUser.sName] = nil
end

-- new user connects

function NewUserConnected(User,sdata)
time()
if not( H=="20" or H=="21" or H=="22" or H=="23" or H=="24") then
if not(User.bRegistered) then
arrDelay[User.sName] = os.clock()
User:SendPM(botname, "Regged Users only, pls register using !regme or you will b kicked in "..iBan.." minutes")
end
end
end

-- Get Time --  
 
function time()  
S = os.date("%S")  
H = os.date("%H")  
M = os.date("%M")  
D = os.date("%d")  
MM = os.date("%m")  
Y = os.date("%y")  
return H  
end  
-----------------------------------><----------------
Done!!
Title:
Post by: Herodes on 06 April, 2005, 00:36:25
try this .. untested.. --- HoursOfCommerce by Herodes v1
--- --- --- --- --- --- --- ---
--- makes your hub private between the specified hours...
--- --- --- --- --- --- --- ---

tHrs={ ["start"] = 10,["end"] = 17};
noticetext= "This is a private hub from

tTxts = {

-- the following table contains the information that every disallowed user will see..
-- add more freely but make sure that you are keeping the following format..( notice the comma at the end)
-- format: ["botsname"] = "message to send",

["Sorry"] = "this is a private hub from 10:00 to 17:00 try an hour outside of those,... when you'll be allowed in freely..",
["RegistrationInfo"] = "you may register an acount on [URL]http://thishub.no-ip.org/registerme.html[/URL]",
["Apologies"] = "Sorry for the inconvinience..",

}

function UserConnected (user)
if not user.bRegistered then
local hr=tonumber(os.date("%H"));
if hr > tHrs.start and hr < tHrs.end then
for i,v in tTxts do
user:SendData( i, v )
end
user:Disconnect();
end
end
end
Title:
Post by: Requiem on 06 April, 2005, 10:57:22
Dessamator

Thank you for your quick response but this is not the script I requested; Herodes understood me :)

Herodes

Giving error:

RegOnly.lua:7: unfinished string near `"This is a private hub from'

When I put a " there, now error msg is like this

RegOnly.lua:24: expected near `end'

By the way, is it possible to add a function to PM users that hub will go private and if they won't reg, they'll be redirected to another hub in a hour?
Title:
Post by: Dessamator on 06 April, 2005, 12:49:13
   --- HoursOfCommerce by Herodes v1
--- --- --- --- --- --- --- ---
--- makes your hub private between the specified hours...
--- --- --- --- --- --- --- ---

tHrs={ ["start"] = 10,["end"] = 17};
noticetext= "This is a private hub from "

tTxts = {

-- the following table contains the information that every disallowed user will see..
-- add more freely but make sure that you are keeping the following format..( notice the comma at the end)
-- format: ["botsname"] = "message to send",

["Sorry"] = "this is a private hub from 10:00 to 17:00 try an hour outside of those,... when you'll be allowed in freely..",
["RegistrationInfo"] = "you may register an acount on [URL]http://thishub.no-ip.org/registerme.html[/URL]",
["Apologies"] = "Sorry for the inconvinience..",

}

function NewUserConnected (user)
if not user.bRegistered then
local hr=tonumber(os.date("%H"));
if hr > tHrs["start"] and hr < tHrs["end"] then
for i,v in tTxts do
user:SendData( i,v )
end
user:Disconnect();
end
end
end


done !!!
Title:
Post by: Requiem on 06 April, 2005, 21:45:51
Can you please add a redirect function after disconnection to a given hub if user is not regged? I tried myself but.. Couldn't  ;(

EDIT: I did it myself. Very happy now.. I will surely spend some more time on LUA interface as soon as my final exams have passed over..
Title:
Post by: Requiem on 07 April, 2005, 02:58:14
Can someone combine these two scripts?
as
1st script if hr is between 20-00 or second if hr is between 00-20

--- HoursOfCommerce by Herodes v1
--- --- --- --- --- --- --- ---
--- makes your hub private between the specified hours...
--- --- --- --- --- --- --- ---

tHrs={ ["start"] = 20,["end"] = 24};
noticetext= "This is a private hub from "

tTxts = {

-- the following table contains the information that every disallowed user will see..
-- add more freely but make sure that you are keeping the following format..( notice the comma at the end)
-- format: ["botsname"] = "message to send",

["Uni?Guvenlik"] = "| Hubimiz saat 20:00 ile 00:00 arasinda yalnizca kayitli kullanicilarimiza hizmet vermektedir.| Kayit olmak icin lutfen bu saatlerin disinda yeniden gelip ( !faq ) komutu ile kosullari okuyunuz. | Kayitli olmadiginiz icin, simdi TurkuazSohbet Hub'ina yonlendirileceksiniz. Gorusmek uzere... | ",

}

Address = "turkuazsohbet.com:4112"

function NewUserConnected (user)
if not user.bRegistered then
local hr=tonumber(os.date("%H"));
if hr > tHrs["start"] and hr < tHrs["end"] then
for i,v in tTxts do
user:SendData( i,v )
end
user:Redirect(Address, Reason);
end
end
end


-- Limit unregged users
-- By [UK]Madman

sBot = "Uni?Guvenlik"
iMaxunreg = 200
iCurrentunreg = 0

function Main()
for key,value in frmHub:GetOnlineUsers() do
if not value.bRegistered then
iCurrentunreg = iCurrentunreg + 1
end
end
end

function NewUserConnected(tCuruser)
if not tCuruser.bRegistered then
iCurrentunreg = iCurrentunreg + 1
if iCurrentunreg >= iMaxunreg then
tCuruser:SendData(sBot,"Hub'imiza en fazla 200 kayitsiz kullanicinin girmesine izin verilmektedir. Lutfen daha sonra deneyiniz.")
tCuruser:Disconnect()
end
end
end

function UserDisconnected(tCuruser)
if not tCuruser.bRegistered then
iCurrentunreg = iCurrentunreg - 1
end
end
Title:
Post by: jiten on 07 April, 2005, 11:39:13
Try this one:

-- Compiled version of these two scripts by jiten
-- Limit unregged users (By [UK]Madman) and
-- HoursOfCommerce by Herodes v1 (makes your hub private between the specified hours...)
--- --- --- --- --- --- --- ---

iMaxunreg = 200

iCurrentunreg = 0

tHrs={ ["start"] = 20,["end"] = 24};
noticetext= "This is a private hub from "

Address = "turkuazsohbet.com:4112" -- redirect address
Reason = "No more unreg users allowed. Maximum is 200" -- redirect reason

tTxts = {

-- the following table contains the information that every disallowed user will see in that time period..
-- add more freely but make sure that you are keeping the following format..( notice the comma at the end)
-- format: ["botsname"] = "message to send",

["Uni?Guvenlik"] = "| Hubimiz saat 20:00 ile 00:00 arasinda yalnizca kayitli kullanicilarimiza hizmet vermektedir.| Kayit olmak icin lutfen bu saatlerin disinda yeniden gelip ( !faq ) komutu ile kosullari okuyunuz. | Kayitli olmadiginiz icin, simdi TurkuazSohbet Hub'ina yonlendirileceksiniz. Gorusmek uzere... | ",

}

sTxts = {

-- the following table contains the information that every disallowed user will see if the hub reaches x unreg users..
-- add more freely but make sure that you are keeping the following format..( notice the comma at the end)
-- format: ["botsname"] = "message to send",

["Uni?Guvenlik"] = "| Hub'imiza en fazla 200 kayitsiz kullanicinin girmesine izin verilmektedir. Lutfen daha sonra deneyiniz. | ",

}

function Main()
for key,value in frmHub:GetOnlineUsers() do
if not value.bRegistered then
iCurrentunreg = iCurrentunreg + 1
end
end
end

function NewUserConnected (user)
if not user.bRegistered then
local hr=tonumber(os.date("%H"));
if hr > tHrs["start"] and hr < tHrs["end"] then
for i,v in tTxts do
user:SendData( i,v )
end
user:Disconnect()
else
iCurrentunreg = iCurrentunreg + 1
if iCurrentunreg > iMaxunreg then
for i,v in sTxts do
user:SendData( i,v )
end
user:Redirect(Address, Reason);
iCurrentunreg = iCurrentunreg - 1
end
end
end
end

function UserDisconnected(user)
if not user.bRegistered then
iCurrentunreg = iCurrentunreg - 1
end
end

*EDIT* Changed Redirect to Disconnect in Hours of Commerce
*EDIT 2* Changed "iCurrentunreg >= iMaxunreg" to "iCurrentunreg > iMaxunreg" in Hours of Commerce
*EDIT 3* Sorted out iCurrentunreg = iCurrentunreg - 1 problem
Title:
Post by: Herodes on 07 April, 2005, 11:58:15
Here is a mod that allows multiple schedules ...--- HoursOfCommerce by Herodes v1
--- --- --- --- --- --- --- ---
--- makes your hub private between the specified hours...
--- --- --- --- --- --- --- ---
--- thx to Dessamator for fixing my stupid bugs ;)


tHrs={ --- add the hours here
--- notice the important comma at the end..
{ ["start"] = 10 , ["end"] = 17 },
{ ["start"] = 1 , ["end"] = 4 },


};
noticetext= "This is a private hub from "

tTxts = {

-- the following table contains the information that every disallowed user will see..
-- add more freely but make sure that you are keeping the following format..( notice the comma at the end)
-- format: ["botsname"] = "message to send",

["Sorry"] = "this is a private hub from 10:00 to 17:00 try an hour outside of those,... when you'll be allowed in freely..",
["RegistrationInfo"] = "you may register an acount on [URL]http://thishub.no-ip.org/registerme.html[/URL]",
["Apologies"] = "Sorry for the inconvinience..",

}

function NewUserConnected (user)
if not user.bRegistered then
local hr=tonumber(os.date("%H"));
for i,v in tHrs do
if hr > v.start and hr < v.end then
for i,v in tTxts do
user:SendData( i,v )
end;break;
user:Disconnect();
end
end
end
Title:
Post by: Requiem on 07 April, 2005, 12:30:11
jiten; HoursOfCommerce part of the compiled script does not work. No server side script errors.

Herodes; HoursOfCommerce.lua:33: expected near `end'
Title:
Post by: jiten on 07 April, 2005, 13:40:03
Quotejiten; HoursOfCommerce part of the compiled script does not work. No server side script errors.

Maybe it's because it only works between this period 8pm to 0 am.
Title:
Post by: Requiem on 07 April, 2005, 13:41:32
I am not a dummy  :)  I changed these values and tested so :)
Title:
Post by: jiten on 07 April, 2005, 14:02:29
QuoteOriginally posted by Requiem
I am not a dummy  :)  I changed these values and tested so :)

LOL

I know that, but, sometimes it happens. I can speak for myself  :D
First post updated.

Best regards,

jiten
Title:
Post by: Requiem on 07 April, 2005, 14:24:36
Try the script with iMaxunreg = 2 string and time values corrected to now. This script works fine for the first 2 users but then it says hub is full even though it is empty. I think problem is
if not user.bRegistered then
iCurrentunreg = iCurrentunreg + 1
command. When a unregged user disconnect, there is not a command to make iCurrentunreg = iCurrentunreg - 1.. Because of this hub doesnt accept users unless iCurrentunreg mem is flushed. Am I true ?
Title:
Post by: jiten on 07 April, 2005, 15:10:08
The script is working well with me.

Well, if u tried the script with iMaxunreg = 2, then, u may only have in the maximum iMaxunreg - 1 users, so only 1 unreg user.

Well, when the unreg user disconnect there's this function (the last one in the script i posted):

function UserDisconnected(user)
if not user.bRegistered then
iCurrentunreg = iCurrentunreg - 1
end
end

Cheers
Title:
Post by: jiten on 07 April, 2005, 15:25:39
Updated first post so that iMaxunreg is always the value that the user chooses, and not less one.
Hope that this solves ur problem.
Title:
Post by: Requiem on 07 April, 2005, 16:35:18
Tested and %100 working now, thanks to jiten.-- Compiled version of these two scripts by jiten
-- Limit unregged users (By [UK]Madman) and
-- HoursOfCommerce by Herodes v1 (makes your hub private between the specified hours...)
--- --- --- --- --- --- --- ---

iMaxunreg = 100
iCurrentunreg = 0

tHrs={ ["start"] = 10,["end"] = 17};
noticetext= "This is a private hub from "

Address = "redirect.me.to:411"

tTxts = {

-- the following table contains the information that every disallowed user will see in that time period..
-- add more freely but make sure that you are keeping the following format..( notice the comma at the end)
-- format: ["botsname"] = "message to send",


["Sorry"] = "this is a private hub from 10:00 to 17:00 try an hour outside of those,... when you'll be allowed in freely..",
["RegistrationInfo"] = "you may register an acount on [URL]http://thishub.no-ip.org/registerme.html[/URL]",
["Apologies"] = "Sorry for the inconvinience..",


}

sTxts = {

-- the following table contains the information that every disallowed user will see if the hub reaches x unreg users..
-- add more freely but make sure that you are keeping the following format..( notice the comma at the end)
-- format: ["botsname"] = "message to send",

["UnregBlaster"] = "Unfortunatly, there are too many unregistered users in the hub, Please try again later!",

}

function Main()
for key,value in frmHub:GetOnlineUsers() do
if not value.bRegistered then
iCurrentunreg = iCurrentunreg + 1
end
end
end

function NewUserConnected (user)
if not user.bRegistered then
iCurrentunreg = iCurrentunreg + 1
if iCurrentunreg > iMaxunreg then
for i,v in sTxts do
user:SendData( i,v )
end
user:Disconnect()
iCurrentunreg = iCurrentunreg - 1
end
local hr=tonumber(os.date("%H"));
if hr > tHrs["start"] and hr < tHrs["end"] then
for i,v in tTxts do
user:SendData( i,v )
end
user:Disconnect()
end
end
end

function UserDisconnected(user)
if not user.bRegistered then
iCurrentunreg = iCurrentunreg - 1
end
end
Title:
Post by: jiten on 07 April, 2005, 20:02:51
Are you sure about ur hub not going private between the specified time? I tested here and it's working.
Title:
Post by: jiten on 08 April, 2005, 11:15:59
First post update once more (tested and debugged hopefully).

Best regards.
Title:
Post by: Requiem on 08 April, 2005, 12:10:53
Script seems to be working ok in the synthetic tests I did.. I will report what happens with real users in the evening..

Regards
Requiem (aka GeceBekcisi)
Title:
Post by: jiten on 08 April, 2005, 16:56:02
QuoteOriginally posted by Requiem
Script seems to be working ok in the synthetic tests I did.. I will report what happens with real users in the evening..

Regards
Requiem (aka GeceBekcisi)

Ok, I'll be waiting...
Title:
Post by: Requiem on 11 April, 2005, 19:12:54
Sorry, I was @ home for the weekend and couldn't response. Thanks for all you've done. Workiing really fine...
Title:
Post by: jiten on 11 April, 2005, 19:54:38
QuoteOriginally posted by Requiem
Sorry, I was @ home for the weekend and couldn't response. Thanks for all you've done. Workiing really fine...

Goody  :]

Best regards