Top Leecher [New API]
 

Top Leecher [New API]

Started by Tw?sT?d-d?v, 21 October, 2007, 22:04:16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tw?sT?d-d?v

--By Dessamator
--Top Leecher

--	Added by Mozzilla? - 16 November 2006
--	Choice as to which profile gets checked
--// Converted to NEW API by Tw?sT?d-d?v?l (21/10/07)

min = 1 -- time to wait b4 reporting top leecher

bot = "TopLeecher" -- bots name

--	Set check on or off for a given profile [0 = don't check    1 = check]
cChecks = {
	[-1] = 1,	--Unregistered User
	[0] = 1,	--Master
	[1] = 0,	--Operator
	[2] = 1,	--VIP
	[3] = 1,	--Registered User
}

function OnStartup()

	tmr = TmrMan.AddTimer(60*1000*min)
end

function OnTimer(tmr)
	local hubs = 0
	for pos, user in pairs(Core.GetOnlineUsers(true)) do
		if cChecks[user.iProfile] == 1 then
			local prof = (ProfMan.GetProfile(user.iProfile) and ProfMan.GetProfile(user.iProfile).sProfileName) or "Unregistered User"
			if user.iHubs > hubs then
				temp="\r\n\r\nCongratulations "..prof.." "..user.sNick..", you are the top leecher in "..SetMan.GetString(0)..".\r\n\tAt this very moment you are in "..user.iHubs.." hubs with "..user.iSlots.." slots open!"
				hubs = user.iHubs
			end
		end
	end
	Core.SendToAll("<"..bot.."> "..temp)
	temp, hubs= nil, nil
end

]-[?LL?L?L??nG?L

I have an error with this script hun

on this line        Core.SendToAll("<"..bot.."> "..temp)

and this error   [14:24] Syntax topleecherNEW API.lua:37: attempt to concatenate global 'temp' (a nil value)

Tw?sT?d-d?v

I dont get ant errors with script running here ......
[16:59] Leecher.lua loaded.
[16:59] No syntax errors in script file Leecher.lua
[16:59] Script started.


[17:00:36] <TopLeecher> 

Congratulations Unregistered User ania123, you are the top leecher in Twisteds-Soul.
	At this very moment you are in 81 hubs with 5 slots open!
[17:01:36] <TopLeecher> 

Congratulations Unregistered User ania123, you are the top leecher in Twisteds-Soul.
	At this very moment you are in 81 hubs with 5 slots open!
[17:02:36] <TopLeecher> 

Congratulations Unregistered User ania123, you are the top leecher in Twisteds-Soul.
	At this very moment you are in 81 hubs with 5 slots open!
[17:03:36] <TopLeecher> 

Congratulations Unregistered User ania123, you are the top leecher in Twisteds-Soul.
	At this very moment you are in 81 hubs with 5 slots open!
[17:04:36] <TopLeecher> 

Congratulations Unregistered User ania123, you are the top leecher in Twisteds-Soul.
	At this very moment you are in 81 hubs with 5 slots open!
[17:05:36] <TopLeecher> 

Congratulations Unregistered User ania123, you are the top leecher in Twisteds-Soul.
	At this very moment you are in 81 hubs with 5 slots open!


Maybe some1 else can see a prob here

]-[?LL?L?L??nG?L

Thank you heeps for the help hun after all that you found out it was my client...... so beware those of you with crap clients  ;D ;D ;D

Snooze

You could add nil checks on those values your script is depending on..

/Snooze

Tw?sT?d-d?v

--// Rewritten some code Thx CenoByte for tips

--By Dessamator
--Top Leecher

--	Added by Mozzilla? - 16 November 2006
--	Choice as to which profile gets checked
--// Converted to NEW API by Tw?sT?d-d?v?l (21/10/07)
--// Rewritten some code Thx CenoByte for tips
----------------------------------------------------------------

min = 1 -- time to wait b4 reporting top leecher

bot = "TopLeecher" -- bots name

--	Set check on or off for a given profile [0 = don't check    1 = check]
cChecks = {
	[-1] = 1,	--Unregistered User
	[0] = 0,	--Master
	[1] = 0,	--Operator
	[2] = 1,	--VIP
	[3] = 1,	--Registered User
}
-----------------------------------------------------------------
function OnStartup()
	tmr = TmrMan.AddTimer(60*1000*min)
end

function OnTimer(tmr)
	local hubs,temp=0,""
	for pos, user in pairs(Core.GetOnlineUsers(true)) do
                 if cChecks[user.iProfile] == 1 then
			local prof = (ProfMan.GetProfile(user.iProfile) and ProfMan.GetProfile(user.iProfile).sProfileName) or "Unregistered User"
			if Core.GetUserValue(user,17) > hubs then
			temp="\r\n\r\nCongratulations "..prof.." "..user.sNick..", you are the top leecher in "..(SetMan.GetString(0) or "<no_hub_name>")..".\r\n\tAt this very moment you are in "..(Core.GetUserValue(user,17) or "n/a").." hubs with "..(Core.GetUserValue(user,21) or "n/a").." slots open!"
                        end
                 end
        end 
	Core.SendToAll("<"..bot.."> "..temp)
end

Pothead

Couple of comments . . ..
If you swap these two lines around, it should be "slightly" more efficient :)
local prof = (ProfMan.GetProfile(user.iProfile) and ProfMan.GetProfile(user.iProfile).sProfileName) or "Unregistered User"
			if Core.GetUserValue(user,17) > hubs then


From seeing this in action in a hub, it goes wrong, i believe always showing the last person who connects . . ..
i believe this is because "hubs" never gets set, like it did in the original, and to sort it this should be added in the middle-ish area. (after the > hubs line).
hubs = Core.GetUserValue(user,17)

:)

SMF spam blocked by CleanTalk