*** Share Warning ***
 

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

*** Share Warning ***

Started by NightLitch, 10 August, 2004, 19:29:28

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

NightLitch

A request Script I made to Juda, maybe more finds it usefull.

*CODE UPDATED*

--------------------------------------------------------
-- Share Warning - By: NightLitch - 2004/08/10
-- Request By: Juda
-- NOTE: NoShare Table is erased when Script is Restarted !!
-- Some Modification Done
-- Changed so it send in PM
--------------------------------------------------------
KB = 1024
MB = KB*KB
GB = KB*KB*KB
TB = KB*KB*KB*KB
Sec  = 1000
Min  = 60*Sec
Hour = 60*Min
TmrFreq = 1000
--------------------------------------------------------
--// Editable Part Start's Here \\--
--------------------------------------------------------
BotName = "-Share-Warning-"		-- Set Botname

MinShareLimit = 500	 -- Set Share Limit
MinShareUnit = MB	 -- Set Share Unit ( KB, MB, GB, TB )

NoShareTimeLimit = 24	 -- Set Time Limit in hours for checking if share is more then 0 MB etc.
ShareUpdateTimeLimit = 12	-- Set Time Limit in hours for checking if share is updated after x hours
NoShareMessage = "You're welcome to stay in this hub, BUT you need to fill your Share with "..MinShareLimit.." MB within "..NoShareTimeLimit.." Hours to stay!"
--------------------------------------------------------
--// Code Starts Here \\--
--------------------------------------------------------
NoShare = {}
tTab = {n=0}

function Main()
	frmHub:RegBot(BotName)
	SetTimer(TmrFreq)
	StartTimer()
	RegTimer(NoShareCheck, 1*Sec)
	RegTimer(ShareUpdatedCheck, 1*Sec)
end

function ShareUpdatedCheck()
	for Nickname, Table in NoShare do
			User = GetItemByName(Nickname)
			if User then
				local _,_,h,m,s = strfind(Table[2], "(%d+):(%d+):(%d+)")
				h = h + ShareUpdateTimeLimit
				if h..":"..m..":"..s == date("%T") then
					local _,_,CurrentShare = strfind(User.sMyInfoString, "(%d+)%$%|$")
					if tonumber(CurrentShare) <= tonumber(Table[1]) then
						SendPmToNick(Nickname, BotName, "You haven't raised your share within "..ShareUpdateTimeLimit.." Hours and your share is still "..format("%.2f",Table[1]/1024/1024).." MB !!")
						SendPmToNick(Nickname, BotName, "You are Disconnected!!")
						User:Disconnect()
						NoShare[Nickname] = nil
					end
			end
		end
	end
end

function NoShareCheck()
	for Nickname, Share in NoShare do
		if tonumber(Share) == 0 then
			User = GetItemByName(Nickname)
			if User then
				local _,_,h,m,s = strfind(Table[2], "(%d+):(%d+):(%d+)")
				h = h + NoShareTimeLimit
				if h..":"..m..":"..s == date("%T") then
					SendPmToNick(Nickname, BotName, "You have been online for "..NoShareTimeLimit.." Hours and your share is still "..format("%.2f",Share/1024/1024).." MB !!")
					SendPmToNick(Nickname, BotName, "You are Disconnected!!")
					User:Disconnect()
					NoShare[Nickname] = nil
				end
			end
		end
	end
end

function UserDisconnect(sUser)
	NoShare[sUser.sName] = nil
end

function DataArrival(sUser,sData)
	if strsub(sData, 1,7) == "$MyINFO" then
		local s,e,sShare = strfind(sData, "(%d+)%$%|$")
		NoShare[sUser.sName] = {sShare,date("%T")}
		if tonumber(sShare) == 0 then
			SendPmToNick(sUser.sName, BotName, "\r\n\t -------==[ NOTICE !! ]===================================================-------")
			SendPmToNick(sUser.sName, BotName, "\r\n\t "..NoShareMessage)
			SendPmToNick(sUser.sName, BotName, "\r\n\t -------===============================================================-------\r\n\r\n")
		end
	end
end

function OnTimer()
	for i=1, getn(tTab) do
		tTab[i].count = tTab[i].count + 1
		if tTab[i].count > tTab[i].trig then
			tTab[i].count=1
			tTab[i]:func()
		end
	end
end

function RegTimer(f, Interval)
	local tmpTrig = Interval / TmrFreq
	assert(Interval >= TmrFreq , "RegTimer(): Please Adjust TmrFreq")
	local Timer = {n=0}
	Timer.func=f
	Timer.trig=tmpTrig
	Timer.count=1
	tinsert(tTab, Timer)
end

Enjoy / NightLitch
//NL

SMF spam blocked by CleanTalk