RegToStay
 

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

RegToStay

Started by [HE]Newbie, 21 March, 2006, 16:33:28

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

[HE]Newbie

-- [ Can someon1 convert this to LUA5, Thnx ] --
-- By [UK]Madman
-- References - Lua Language Board

var = {["bot"] = "RegToStayBot", ["time"] = 1, ["command"] = "?notreg"} --time is in mins before redirect
times = {}
hubs =? { "Holland-Extreme1.no-ip.info:411", "nlgezel.hopto.org:411"} -- list of possible hubs

function Main()
frmHub:RegBot(var.bot)
SetTimer(60000*(tonumber(var.time)/4))
StartTimer()
end

function NewUserConnected(Curuser)
	if Curuser.iProfile == -1 then
	times[Curuser.sName] = var.time
	Curuser:SendData (var.bot, "You have to register to stay in this hub, you currently have: "..var.time.." mins to register!")
	end
end

function UserDisconnected (Curuser)
times[Curuser.sName] = Nil
end

function OnTimer()
	for key, value in times do
	value = value - (var.time/4)
	times[key] = value

		if value == 0 then tokick = GetItemByName(key)
			times[tokick] = nil
			tokick:SendData (var.bot, "You did not register, so are now being redirected!")
			tohub = random(getn(hubs))
			tokick:SendData("$ForceMove "..hubs[tohub])

	elseif value == (var.time - tonumber(var.time)/2) then towarn = GetItemByName(key)
	towarn:SendData (var.bot, "You have not registered, you will be redirected in: "..value.." mins unless you register!")
	end
end
end


function DataArrival(Curuser,data)
data = strsub(data, 1, strlen(data)-1)
	if strsub(data, 1, 1) == "<" then 
	s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if cmd == var.command and Curuser.bOperator then
		Curuser:SendPM (var.bot, "The following users are currently not regged:")
			for key, value in times do 
			Curuser:SendPM (var.bot, key.." Has approx "..value.." mins till being redirected!")
			end
		return 1
		end
	end
end


There will be 1 day, that i learn

nlgezel.hopto.org:411

Markitos

#1
--[[
 By [UK]Madman
References - Lua Language Board
Markitos: Now works with all prefixes - 30/03/06
-- Lua5/Lua 5.1 support - 30/03/06
]]--

var = {
["bot"] = "RegToStayBot", 
["time"] = 1, --time is in mins before redirect
["command"] = "notreg",
}
times = {}
hubs =  { "Holland-Extreme1.no-ip.info:411", "nlgezel.hopto.org:411"} -- list of possible hubs

function Main()
frmHub:RegBot(var.bot)
SetTimer(60000*(tonumber(var.time)/4))
StartTimer()
end

function NewUserConnected(Curuser)
	if Curuser.iProfile == -1 then
		times[Curuser.sName] = var.time
		Curuser:SendData (var.bot, "You have to register to stay in this hub, you currently have: "..var.time.." mins to register!")
	end
end

function UserDisconnected (Curuser)
times[Curuser.sName] = Nil
end

function OnTimer()
	for key, value in pairs(times) do
	value = value - (var.time/4)
	times[key] = value
		if value == 0 then tokick = GetItemByName(key)
			times[tokick] = nil
			tokick:SendData (var.bot, "You did not register, so are now being redirected!")
			tohub = random(table.getn(hubs))
			tokick:SendData("$ForceMove "..hubs[tohub])
				elseif value == (var.time - tonumber(var.time)/2) then towarn = GetItemByName(key)
					towarn:SendData (var.bot, "You have not registered, you will be redirected in: "..value.." mins unless you register!")
				end
		end
end


function ChatArrival(Curuser,data)
	data = string.sub(data, 1, string.len(data)-1)
	s,e,cmd = string.find(data, "%b<>%s+[%!%+%#%?](%S+)")
		if cmd == var.command and Curuser.bOperator then
		Curuser:SendPM (var.bot, "The following users are currently not regged:")
			for key, value in pairs(times) do
			Curuser:SendPM (var.bot, key.." Has approx "..value.." mins till being redirected!")
			end
		return 1
	end
end

Markitos

Quote from: Mutor on 30 March, 2006, 16:52:05
For what its worth simple scripts like this can easily be made 5.0/5.1
compatible with the same effort as is required to convert 4.x to 5.0.

Consider using the optimized table loops [ipairs for arrays, pairs for tables]
that are available in 5.0 and required for 5.1. In this way, the script may be used
in both LUA versions. There are a few other things to consider for 5.1 but loops
are the biggest consideration.

Food for thought
edited...

SMF spam blocked by CleanTalk