Results 1 to 4 of 4

Thread: getmessages()

  1. #1
    Banned
    Join Date
    Jul 2012
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    10
    Rep Power
    0

    getmessages()

    how would i use getmessages to count how many potions i used??
    Code:
    eg Potions=Potions+1
    i found the function here
    http://www.tibiaibot.com/forum/showt...ll=1#post63914
    just trying figure out how to use it...

  2. #2
    Normal User
    Join Date
    Jun 2012
    Location
    Sweden
    Posts
    1,670
    Mentioned
    18 Post(s)
    Tagged
    1 Thread(s)
    Quoted
    8 Post(s)
    Reputation
    132
    Rep Power
    10
    This should work, atleast it's an example of how to use it.
    Code:
    local msgs = getmessages("Server Log")
    local qtd = msgs.count-1 
    local Potions = 0
    
    for i=0,qtd do 
        if msgs[qtd].text:find('Using one of .+ mana potions...') then 
            Potions = Potions+1
        end 
    end
    Last edited by soder; 09-11-2012 at 06:31 PM.

  3. #3
    Banned
    Join Date
    Jul 2012
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)
    Reputation
    10
    Rep Power
    0
    Quote Originally Posted by soder View Post
    This should work, atleast it's an example of how to use it.
    Code:
    local msgs = getmessages("Server Log")
    local qtd = msgs.count-1 
    local Potions = 0
    
    for i=0,qtd do 
        if msgs[qtd].text:find('Using one of .+ mana potions...') then 
            Potions = Potions+1
        end 
    end
    i dont know why but its not working.... is this how most people get loot/waste stuff for hud
    this is what Toadz used in his hud but i dont really get ll of it

    Code:
    if showSuppliesWasted then setfontcolor("white") addtext('-----------------------------------------', 0, y) y = y + 10 setfontcolor("yellow") addtext('       [ Supplies wasted
     ]', 15, y) y = y + 10 setfontcolor("white") addtext('-----------------------------------------', 0, y) y = y + 10 local supps = getitems(unpack(suppliesitems)) local qtds = supps.count-1 for i=0,qtds do if string.len(supps[i].name) > 17 then addtext(string.sub((supps[i].name), 1, sub).."...", x, y) else addtext(supps[i].name, x, y) end addtext("- "..supps[i].usage.." 
    ("..(math.floor(supps[i].usage*suppsvalue[i+1] / 100)/10).."k)", 120, y) totals = totals + supps[i].usage*suppsvalue[i+1] y = y + 15 end y = y + 10 addtext("Total", x, y) addtext
    ("-", 120, y) addtext(totals.." GPs", 130, y) y = y + 10 end if showLoots then setfontcolor("white") addtext('-----------------------------------------', 0, y) setfontcolor("yellow") y = y 
    + 10 addtext('         [ Items looted ]', 15, y) y = y + 10 setfontcolor("white") addtext('-----------------------------------------', 0, y) y = y + 10 local loots = getitems(unpack
    (lootitems)) local qtdl = loots.count-1 for i=0,qtdl do if loots[i].loot > 0 then lootname = loots[i].name:gsub("(%a)([%w_']*)", captalizeAll) if string.len(loots[i].name) > 17 then 
    addtext(string.sub(lootname, 1, sub).."..", x, y) else addtext(lootname, x, y) end addtext("- "..loots[i].loot.." ("..(math.floor(loots[i].loot*lootsvalue[i+1] / 100)/10).."k)", 120, y)
     totall = totall + loots[i].loot*lootsvalue[i+1] y = y + 15 end end y = y + 10 addtext("Total", x, y) addtext("-", 120, y) addtext(totall.." GPs", 130, y) y = y + 10 end if 
    showSuppliesWasted and showLoots then setfontcolor("white") addtext('-----------------------------------------', 0, y) y = y + 10 total = totall - totals if totall-totals > 0 then 
    setfontcolor("green") addtext("PROFIT:", x, y) else setfontcolor("red") addtext("WASTE:", x, y) end setfontcolor("white") addtext(total.." GPs ("..(math.floor((total/(tosec(timehunt)/
    3600))/100)/10).."k/h)", x + 50, y) y = y + 10 end

  4. #4
    Normal User
    Join Date
    Jun 2012
    Location
    Sweden
    Posts
    1,670
    Mentioned
    18 Post(s)
    Tagged
    1 Thread(s)
    Quoted
    8 Post(s)
    Reputation
    132
    Rep Power
    10
    Here's jonatas loot counter, it's alot easier to read.
    And no, they dont get the loot by getmessages(), they use getitems()(Though the function getitems()probably use getmessages()) - stored in the bot's memory I believe.
    Code:
    -- Loots
    local lootsitems = {'gold coin', 'dragon Shield', 'Wand of Inferno', 'serpent sword','dragon hammer','dragonbone staff','small diamond','green dragon scale','green dragon leather','dragons tail' }
    local lootsvalue = {1,4000,3000,900,2000,3000,300,100,100,100}
    
    -- Supplie
    local suppliesitems = {'mana potion'}
    local suppsvalue = {50}
    
    -- Start Position
    local startpos = 200
    
    
    --dont change things below
    
    local loots = getitems(unpack(lootsitems))
    local qtdl = loots.count-1
    local totall = 0
    
    local supps = getitems(unpack(suppliesitems))
    local qtds = supps.count-1
    local totals = 0
    
    local startloot = 0
    
    setfontcolor("white")
    addtext("________________________________", 0,10+startpos)
    setfontcolor("red")
    
    -- Supplies
    for i=0,qtds do
       addtext(supps[i].name, 10,30+(startloot*15)+20+startpos)
       addtext(":", 140,30+(startloot*15)+20+startpos)
       addtext(supps[i].usage*suppsvalue[i+1], 150,30+(startloot*15)+20+startpos)
       startloot = startloot + 1
       totals = totals + supps[i].usage*suppsvalue[i+1]
    end
    
    setfontcolor("red")
    addtext("Supplie", 10,30+startpos)
    addtext(":", 140,30+startpos)
    addtext(totals, 150,30+startpos)
    
    setfontcolor("white")
    addtext("________________________________", 0,45+(startloot*15)+startpos)
    
    -- Loots
    
    setfontcolor("green")
    local posloot = 50+(startloot*15)+20+startpos
    
    for i=0,qtdl do
       addtext(loots[i].name, 10,50+(startloot*15)+40+startpos)
       addtext(":", 140,50+(startloot*15)+40+startpos)
       addtext(loots[i].loot*lootsvalue[i+1], 150,50+(startloot*15)+40+startpos)
       startloot = startloot + 1
       totall = totall + loots[i].loot*lootsvalue[i+1]
    end
    
    setfontcolor("green")
    addtext("Loots", 10,posloot)
    addtext(":", 140,posloot)
    addtext(totall, 150,posloot)
    
    setfontcolor("white")
    addtext("________________________________", 0,85+(startloot*15)+startpos)
    
    if totall-totals > 0 then
    setfontcolor("blue")
    else
    setfontcolor("red")
    end
    
    addtext("Total", 10,50+(startloot*15)+20+startpos+35)
    addtext(":", 140,50+(startloot*15)+20+startpos+35)
    addtext(totall-totals, 150,50+(startloot*15)+20+startpos+35)
    
    setfontcolor("white")
    addtext("________________________________", 0,115+(startloot*15)+startpos)
    Last edited by soder; 09-11-2012 at 08:23 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •