Doubt For HideShare by Mutor
 

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

Doubt For HideShare by Mutor

Started by 6Marilyn6Manson6, 22 March, 2007, 16:19:57

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

6Marilyn6Manson6

I have find this script:

--[[
	HideShare 1.0 LUA 5.0/5.1 	  06/13/06
	
	By Mutor
	Requested by Rotekoppen

	
	Hide user shares per profile.
	Stop the script to unhide shares.
	
	Note:
	Any script that modifies MyINFO is a resource
	and bandwidth hog. This one is no different.
	
]]

Main = function()
	--Set MyINFO delay in ms [1000 = 1 second]
	SetTimer(500)
	StartTimer()
	--//--Set your profiles here.
	--[Profile_Index] = {Hide Share?(0=show 1=hide), "Profile Name"},
	HideProfiles = {
	[-1] = {0,"Unregistered User"},
	[0] = {1,"Master"},
	[1] = {1,"Operator"},
	[2] = {0,"Vip"},
	[3] = {0,"Registered User"},
	[4] = {1,"Moderator"},
	[5] = {1,"NetFounder"},
	}
	gc,no = nil,table.getn
	if _VERSION == "Lua 5.1" then
		gc,no = "collect",table.maxn
	end
end

MyINFOArrival = function(user,data)
	StartTimer()
end
GetINFOArrival,NewUserConnected,OpConnected = MyINFOArrival,MyINFOArrival,MyINFOArrival

OnTimer = function()
	for i = 1, no(GetProfiles()) do
		if HideProfiles[i-1] and HideProfiles[i-1][1] == 1 then
			for k,v in ipairs(frmHub:GetOnlineUsers(i-1)) do
				local n,d,t,c,a,e,s = v["sName"], v["sDescription"] or "", v["sTag"] or "",
				v["sConnection"] or "",tonumber(v["iMagicByte"]),v["sEmail"] or "","0"
				SendToAll("$MyINFO $ALL "..n.." "..d..t.."$ $"..c.."$"..e.."$"..s.."$")
			end
		end
	end
	StopTimer()
	collectgarbage(gc)
end

OnExit = function()
	for k,v in ipairs(frmHub:GetOnlineUsers()) do
		local user = GetItemByName(v["sName"])
		SendToAll(user.sMyInfoString)
	end
	collectgarbage(gc)
end


I don't understand OnTimer function... why Mutor use:

OnTimer = function()
	for i = 1, no(GetProfiles()) do
		if HideProfiles[i-1] and HideProfiles[i-1][1] == 1 then
			for k,v in ipairs(frmHub:GetOnlineUsers(i-1)) do
				local n,d,t,c,a,e,s = v["sName"], v["sDescription"] or "", v["sTag"] or "",
				v["sConnection"] or "",tonumber(v["iMagicByte"]),v["sEmail"] or "","0"
				SendToAll("$MyINFO $ALL "..n.." "..d..t.."$ $"..c.."$"..e.."$"..s.."$")
			end
		end
	end
	StopTimer()
	collectgarbage(gc)
end


and not:

OnTimer = function()
	if HideProfiles and HideProfiles[1] == 1 then
		for k,v in ipairs(frmHub:GetOnlineUsers) do
			local n,d,t,c,a,e,s = v["sName"], v["sDescription"] or "", v["sTag"] or "",
			v["sConnection"] or "",tonumber(v["iMagicByte"]),v["sEmail"] or "","0"
			SendToAll("$MyINFO $ALL "..n.." "..d..t.."$ $"..c.."$"..e.."$"..s.."$")
		end
	end
	StopTimer()
	collectgarbage(gc)
end


Explain to me please :D

NightLitch

Your code got some optimized there 6M6M6. It is better as you stated to put the check outside the loop rather then inside to check it over and over again...
//NL

6Marilyn6Manson6

Okiz, now i'm understand. Thanks NightLitch and Mutor :)

SMF spam blocked by CleanTalk