RegOnly Timer
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

RegOnly Timer

Started by Requiem, 05 April, 2005, 23:38:11

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Requiem

Is it possible to make a script that makes hub a reg only hub between given day times like 20:00 - 24:00?

Dessamator

#1
 -- 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!!
Ignorance is Bliss.

Herodes

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

Requiem

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?

Dessamator

   --- 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 !!!
Ignorance is Bliss.

Requiem

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

Requiem

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

jiten

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

Herodes

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

Requiem

#9
jiten; HoursOfCommerce part of the compiled script does not work. No server side script errors.

Herodes; HoursOfCommerce.lua:33: expected near `end'

jiten

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.

Requiem

I am not a dummy  :)  I changed these values and tested so :)

jiten

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

Requiem

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

jiten

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

jiten

Updated first post so that iMaxunreg is always the value that the user chooses, and not less one.
Hope that this solves ur problem.

Requiem

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

jiten

Are you sure about ur hub not going private between the specified time? I tested here and it's working.

jiten

First post update once more (tested and debugged hopefully).

Best regards.

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)

jiten

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

Requiem

Sorry, I was @ home for the weekend and couldn't response. Thanks for all you've done. Workiing really fine...

jiten

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

SMF spam blocked by CleanTalk