Author Topic: Top Leecher [New API]  (Read 3991 times)

0 Members and 1 Guest are viewing this topic.

Offline Tw?sT?d-d?v

  • Lord
  • ***
  • Posts: 436
  • Karma: +79/-2
    • EURO-OP
Top Leecher [New API]
« on: 21 October, 2007, 22:04:16 »
Code: [Select]
--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

PtokaX forum

Top Leecher [New API]
« on: 21 October, 2007, 22:04:16 »

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

  • Junior Member
  • **
  • Posts: 24
  • Karma: +8/-0
Re: Top Leecher [New API]
« Reply #1 on: 19 February, 2008, 15:25:17 »
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)

Offline Tw?sT?d-d?v

  • Lord
  • ***
  • Posts: 436
  • Karma: +79/-2
    • EURO-OP
Re: Top Leecher [New API]
« Reply #2 on: 19 February, 2008, 18:05:57 »
I dont get ant errors with script running here ......
Code: [Select]
[16:59] Leecher.lua loaded.
[16:59] No syntax errors in script file Leecher.lua
[16:59] Script started.

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

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

  • Junior Member
  • **
  • Posts: 24
  • Karma: +8/-0
Re: Top Leecher [New API]
« Reply #3 on: 19 February, 2008, 23:00:32 »
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

Offline Snooze

  • Scripter
  • Viking
  • ******
  • Posts: 606
  • Karma: +54/-3
    • DiXBoT Website
Re: Top Leecher [New API]
« Reply #4 on: 20 February, 2008, 17:28:26 »
You could add nil checks on those values your script is depending on..

/Snooze

Offline Tw?sT?d-d?v

  • Lord
  • ***
  • Posts: 436
  • Karma: +79/-2
    • EURO-OP
Re: Top Leecher [New API]
« Reply #5 on: 20 February, 2008, 20:16:51 »
--// Rewritten some code Thx CenoByte for tips

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

Offline Pothead

  • Lord
  • ***
  • Posts: 455
  • Karma: +25/-4
Re: Top Leecher [New API]
« Reply #6 on: 23 June, 2008, 13:32:08 »
Couple of comments . . ..
If you swap these two lines around, it should be "slightly" more efficient :)
Code: [Select]
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).
Code: [Select]
hubs = Core.GetUserValue(user,17)
:)

PtokaX forum

Re: Top Leecher [New API]
« Reply #6 on: 23 June, 2008, 13:32:08 »