Author Topic: Doubt For HideShare by American Idiot  (Read 2244 times)

0 Members and 1 Guest are viewing this topic.

Offline 6Marilyn6Manson6

  • Scripter
  • King
  • ******
  • Posts: 869
  • Karma: +47/-35
    • http://www.marilynmanson986.altervista.org
Doubt For HideShare by American Idiot
« on: 22 March, 2007, 16:19:57 »
I have find this script:

Code: [Select]
--[[
HideShare 1.0 LUA 5.0/5.1   06/13/06

By American Idiot
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 American Idiot use:

Code: [Select]
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:

Code: [Select]
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

PtokaX forum

Doubt For HideShare by American Idiot
« on: 22 March, 2007, 16:19:57 »

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
Re: Doubt For HideShare by American Idiot
« Reply #1 on: 22 March, 2007, 21:39:44 »
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

Offline 6Marilyn6Manson6

  • Scripter
  • King
  • ******
  • Posts: 869
  • Karma: +47/-35
    • http://www.marilynmanson986.altervista.org
Re: Doubt For HideShare by American Idiot
« Reply #2 on: 23 March, 2007, 08:53:03 »
Okiz, now i'm understand. Thanks NightLitch and American Idiot :)

PtokaX forum

Re: Doubt For HideShare by American Idiot
« Reply #2 on: 23 March, 2007, 08:53:03 »