Results 1 to 4 of 4

Thread: Hud Loot Counter not working

  1. #1
    iBot User PabloGura's Avatar
    Join Date
    Jun 2012
    Posts
    164
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    11 Post(s)
    Reputation
    11
    Rep Power
    5

    Hud Loot Counter not working

    hi mates, i have a problem with my loot counter..
    he is not count supplys that I am using, GMP and SD.. i hunting banuta with ED



    start
    \/
    Code:
    -- This area should be in the start section!
    lsh_show_all = false
    lsh_width = 240
    lsh_max_name_length = 14
    lsh_font = {    
        color = {255, 255, 255, 230}, 
        default_font = true,
         
        -- you can ignore those if you using default.
        name = "Tahoma", 
        size = 10, 
        style = nil
    }
     
    lsh_colors = {
        borders = {1, 1, 1},
        headers = {
            gradient = true,
            rgbamode = {36, 68, 105, 200},
            gradmode = {
                {36, 68, 105, 100},
                {39, 73, 114, 100},
                {21, 39, 60, 100}
            }
        },
        ittitle = {
            gradient = true,
            rgbamode = {0, 0, 0, 120},
            gradmode = {
                {75, 75, 75, 100},
                {45, 45, 45, 100},
                {19, 19, 19, 100}
            }
        },
        itvalue = {
            gradient = true,
            rgbamode = {145, 95, 0, 170},
            gradmode = {
                {145, 95, 0, 100},
                {158, 104, 0, 100},
                {84, 55, 0, 100}
            }
        },
        cstatus = {
            gradient = true,
            rgbamode = {on = {65, 96, 12, 200}, off = {90, 12, 15, 200}},
            gradmode = {
                on = {
                    {65, 96, 12, 100},
                    {67, 99, 13, 100},
                    {36, 52, 6, 100}
                },
                off = {
                    {90, 12, 15, 100},
                    {98, 13, 17, 100},
                    {52, 6, 9, 100}
                }
            }
        }
    }
     
    lsh_sections = {
        {title = "Items Looted", enabled = true},
        {title = "Supplies Used", enabled = true}
    }
     
    -- internal usage do not edit
    -- 0 and 15 are default values for spawn position
    lsh_pos = {x = clientwin.right - 455, y = clientwin.y + 15}
    lsh_moving = {s = false, sx = 0, sy = 0}
    -- end start section!

    script
    \/

    Code:
    -- hud script!
    lsh_y_modifier = 0
     
    AMMO_COUNT, AMMO_COUNT_BP = AMMO_COUNT or 0, AMMO_COUNT_BP or 0
    local DISTANCE_WEAPONS, AMMUNITION, AMMO_NAME, AMMO_TYPE_COUNT, ADD_TO_HUD = {"assassin star", "enchanted spear", "hunting spear", "mean paladin spear", "royal spear", "small stone", "snowball", "spear", "throwing knife", "throwing star", "viper star"}, {"arrow", "burst arrow", "crystalline arrow", "earth arrow", "envenomed arrow", "flaming arrow", "flash arrow", "onyx arrow", "poison arrow", "shiver arrow", "sniper arrow", "tarsal arrow", "infernal bolt", "drill bolt", "power bolt", "prismatic bolt", "vortex bolt", "piercing bolt", "bolt"}, nil, 0, 0
     
     
    sethudopacity(82)
     
    if (weapon ~= 0) and (table.find(DISTANCE_WEAPONS, itemname(weapon):lower())) then
        AMMO_NAME, AMMO_TYPE_COUNT = itemname(weapon) or nil, weaponamount or 0
    elseif (ammo ~= 0) and (table.find(AMMUNITION, itemname(ammo):lower())) then
        AMMO_NAME, AMMO_TYPE_COUNT = itemname(ammo) or nil, ammoamount or 0
    end
     
    if (AMMO_NAME ~= nil) then
        local CURRENT_AMMO_COUNT = itemcount(AMMO_NAME)
         
        if (AMMO_TYPE_COUNT < AMMO_COUNT) then
            ADD_TO_HUD = math.max(0, AMMO_COUNT-AMMO_TYPE_COUNT)
        elseif (AMMO_TYPE_COUNT > AMMO_COUNT) and (CURRENT_AMMO_COUNT < AMMO_COUNT_BP) then
            ADD_TO_HUD = math.max(0, (AMMO_COUNT+(AMMO_COUNT_BP-CURRENT_AMMO_COUNT))-100)
        end
         
        addhudsupplie(AMMO_NAME, ADD_TO_HUD)
        AMMO_COUNT, AMMO_COUNT_BP = AMMO_TYPE_COUNT, CURRENT_AMMO_COUNT
    end
     
    function __resetCounterHud()
        resethud()
    end
     
    function __enable_lsh(__name)
        for _, section in ipairs(lsh_sections) do
            if (section.title == __name) then
                section.enabled = not section.enabled
                return true
            end
        end
        return false
    end
     
    function string.truncate(self, limit)
        return (self:len() > limit) and (self:sub(1, limit - 3) .. "...") or self
    end
     
    function string.xxx(self)
     local r = {}
     for _, v in ipairs(self:explode(' ')) do
      table.insert(r, v:capitalize())
     end  
     return table.concat(r, ' ')
    end
     
    function get_k_string(value)
        return math.floor(value / 100) / 10 .. "K"
    end
     
    function rgba_to_bgra(r, g, b, a)
        return b, g, r, a
    end
     
    function build_params(a)
        return 0.0, rgbcolor(rgba_to_bgra(unpack(a[1]))), 0.23, rgbcolor(rgba_to_bgra(unpack(a[2]))), 0.76, rgbcolor(rgba_to_bgra(unpack(a[3])))
    end
     
    -- hud script!
    function lsh_enableMovement()
        lsh_moving.s = true
        lsh_moving.sx = cursorinfo().cx
        lsh_moving.sy = cursorinfo().cy
    end
     
    function lsh_disableMovement()
        if lsh_moving.s then
            lsh_moving.s = false
            lsh_pos.x = lsh_pos.x + cursorinfo().cx - lsh_moving.sx
            lsh_pos.y = lsh_pos.y + cursorinfo().cy - lsh_moving.sy
        end
    end
     
    -- tricky but works
    local cbid = 1
    onClick_callbacks_lsh = {}
     
    lsh_y_modifier = lsh_y_modifier + 10
    if not lsh_font.default_font then
        setfontstyle(lsh_font.name, lsh_font.size, lsh_font.style)
    end
     
    setpen(unpack(lsh_colors.borders))
    if lsh_colors.ittitle.gradient then
        addgradcolors(build_params(lsh_colors.ittitle.gradmode))
        setfillstyle('gradient', 'linear', 1, 0, 0, 0, 50)
    else
        setfillcolor(unpack(lsh_colors.ittitle.rgbamode))
    end
     
    local movable = addrect(lsh_pos.x, lsh_pos.y + lsh_y_modifier, lsh_width - 65, 20)  -- 65 reset button width
     
    onClick_callbacks_lsh[cbid] = function()
        return lsh_enableMovement()
    end
    addevent(movable, MOUSE_LEFT_DOWN, "onClick_callbacks_lsh[" .. cbid .. "]()")
    cbid = cbid + 1
     
    onClick_callbacks_lsh[cbid] = function()
        return lsh_disableMovement()
    end
    addevent(movable, MOUSE_LEFT_UP, "onClick_callbacks_lsh[" .. cbid .. "]()")
    cbid = cbid + 1
     
    setfontcolor(unpack(lsh_font.color))
    addtextstroke("Loot Counter HUD v1.0.0+", lsh_pos.x + 7, lsh_pos.y + lsh_y_modifier + 15)          
         
    setpen(unpack(lsh_colors.borders))
    if lsh_colors.cstatus.gradient then
        addgradcolors(build_params(lsh_colors.cstatus.gradmode.on))
        setfillstyle('gradient', 'linear', 1, 0, 0, 0, 50)
    else
        setfillcolor(unpack(lsh_colors.cstatus.rgbamode.on))
    end
     
    local rButton = addrect(lsh_pos.x + lsh_width - 65, lsh_pos.y + lsh_y_modifier, 65, 20)
    addevent(rButton, MOUSE_LEFT_DOWN, "__resetCounterHud()")
     
    setfontcolor(unpack(lsh_font.color))
    addtextstroke("Reset", lsh_pos.x + 15 + lsh_width - 65, lsh_pos.y + lsh_y_modifier + 15)       
    lsh_y_modifier = lsh_y_modifier + 20
     
    local totals = {loot = 0, supplies = 0}
     
    for index, section in ipairs(lsh_sections) do
        setpen(unpack(lsh_colors.borders))
        if lsh_colors.headers.gradient then
            addgradcolors(build_params(lsh_colors.headers.gradmode))
            setfillstyle('gradient', 'linear', 1, 0, 0, 0, 50)
        else
            setfillcolor(unpack(lsh_colors.headers.rgbamode))
        end
        addrect(lsh_pos.x, lsh_pos.y + lsh_y_modifier, lsh_width, 20)
         
        setfontcolor(unpack(lsh_font.color))
        addtextstroke(section.title, lsh_pos.x + 7, lsh_pos.y + lsh_y_modifier + 15)
         
        setpen(unpack(lsh_colors.borders))
        if lsh_colors.cstatus.gradient then
            addgradcolors(build_params(section.enabled and lsh_colors.cstatus.gradmode.on or lsh_colors.cstatus.gradmode.off))
            setfillstyle('gradient', 'linear', 1, 0, 0, 0, 50)
        else
            setfillcolor(unpack(section.enabled and lsh_colors.cstatus.rgbamode.on or lsh_colors.cstatus.rgbamode.off))
        end
     
        local minimizeRect = addrect(lsh_pos.x + lsh_width - 20, lsh_pos.y + lsh_y_modifier, 20, 20)
        onClick_callbacks_lsh[cbid] = function()
            return __enable_lsh(section.title)
        end
        addevent(minimizeRect, MOUSE_LEFT_DOWN, "onClick_callbacks_lsh[" .. cbid .. "]()")
        cbid = cbid + 1
         
        setfontcolor(unpack(lsh_font.color))
        addtextstroke("-", lsh_pos.x + 7 + lsh_width - 20, lsh_pos.y + lsh_y_modifier + 15)
     
        lsh_y_modifier = lsh_y_modifier + 20
         
        -- Lets work based on index incase users want to change titles.
        if (index == 1) then
            local list = getlootitems()
            local size = list.count - 1
             
            for i = 0, size do
                local item = list[i]
                if lsh_show_all or (item.loottake > 0) then
                    if section.enabled then
                        setpen(unpack(lsh_colors.borders))
                        if lsh_colors.ittitle.gradient then
                            addgradcolors(build_params(lsh_colors.ittitle.gradmode))
                            setfillstyle('gradient', 'linear', 1, 0, 0, 0, 50)
                        else
                            setfillcolor(unpack(lsh_colors.ittitle.rgbamode))
                        end
                 
                        addrect(lsh_pos.x, lsh_pos.y + lsh_y_modifier, lsh_width / 2, 20)
                        additem(item.name, lsh_pos.x + 2, lsh_pos.y + lsh_y_modifier, 50)
                        setfontcolor(unpack(lsh_font.color))
                        addtextstroke(item.name:truncate(lsh_max_name_length):xxx(), lsh_pos.x + 7 + 14, lsh_pos.y + lsh_y_modifier + 15)          
                         
                        setpen(unpack(lsh_colors.borders))
                        if lsh_colors.itvalue.gradient then
                            addgradcolors(build_params(lsh_colors.itvalue.gradmode))
                            setfillstyle('gradient', 'linear', 1, 0, 0, 0, 50)
                        else
                            setfillcolor(unpack(lsh_colors.itvalue.rgbamode))
                        end
                        addrect(lsh_pos.x + lsh_width / 2, lsh_pos.y + lsh_y_modifier, lsh_width / 2, 20)
                    end
                     
                    local value = itemvalue(item.name) * item.loottake
                    totals.loot = totals.loot + value
                     
                    if section.enabled then
                        setfontcolor(unpack(lsh_font.color))           
                        addtextstroke(comma_value(item.loottake) .. " (" .. get_k_string(value) .. ")", lsh_pos.x + 7 + lsh_width / 2, lsh_pos.y + lsh_y_modifier + 15)                
                        lsh_y_modifier = lsh_y_modifier + 20
                    end
                end
            end
             
            setpen(unpack(lsh_colors.borders))
            if lsh_colors.ittitle.gradient then
                addgradcolors(build_params(lsh_colors.ittitle.gradmode))
                setfillstyle('gradient', 'linear', 1, 0, 0, 0, 50)
            else
                setfillcolor(unpack(lsh_colors.ittitle.rgbamode))
            end
            addrect(lsh_pos.x, lsh_pos.y + lsh_y_modifier, lsh_width, 20)
             
            setfontcolor(unpack(lsh_font.color))
            addtextstroke("Total: " .. comma_value(totals.loot) .. " GPs", lsh_pos.x + 7, lsh_pos.y + lsh_y_modifier + 15) 
            lsh_y_modifier = lsh_y_modifier + 20
        elseif (index == 2) then
            local list = getsupplieitems()
            local size = list.count - 1
             
            for i = 0, size do
                local item = list[i]
                if lsh_show_all or (item.usagemessage > 0) then
                    if section.enabled then
                        setpen(unpack(lsh_colors.borders))
                        if lsh_colors.ittitle.gradient then
                            addgradcolors(build_params(lsh_colors.ittitle.gradmode))
                            setfillstyle('gradient', 'linear', 1, 0, 0, 0, 50)
                        else
                            setfillcolor(unpack(lsh_colors.ittitle.rgbamode))
                        end
                        addrect(lsh_pos.x, lsh_pos.y + lsh_y_modifier, lsh_width / 2, 20)
                         
                        additem(item.name, lsh_pos.x + 2, lsh_pos.y + lsh_y_modifier, 50)
                        setfontcolor(unpack(lsh_font.color))
                        addtextstroke(item.name:truncate(lsh_max_name_length):xxx(), lsh_pos.x + 7 + 14, lsh_pos.y + lsh_y_modifier + 15)      
                 
                        setpen(unpack(lsh_colors.borders))
                        if lsh_colors.itvalue.gradient then
                            addgradcolors(build_params(lsh_colors.itvalue.gradmode))
                            setfillstyle('gradient', 'linear', 1, 0, 0, 0, 50)
                        else
                            setfillcolor(unpack(lsh_colors.itvalue.rgbamode))
                        end
                        addrect(lsh_pos.x + lsh_width / 2, lsh_pos.y + lsh_y_modifier, lsh_width / 2, 20)
                    end
                     
                    local value = itemcost(item.name) * item.usagemessage
                    totals.supplies = totals.supplies + value
                     
                    if section.enabled then
                        setfontcolor(unpack(lsh_font.color))           
                        addtextstroke(comma_value(item.usagemessage) .. " (" .. get_k_string(value) .. ")", lsh_pos.x + 7 + lsh_width / 2, lsh_pos.y + lsh_y_modifier + 15)                
                        lsh_y_modifier = lsh_y_modifier + 20
                    end
                end
            end
             
            setpen(unpack(lsh_colors.borders))
            if lsh_colors.ittitle.gradient then
                addgradcolors(build_params(lsh_colors.ittitle.gradmode))
                setfillstyle('gradient', 'linear', 1, 0, 0, 0, 50)
            else
                setfillcolor(unpack(lsh_colors.ittitle.rgbamode))
            end
            addrect(lsh_pos.x, lsh_pos.y + lsh_y_modifier, lsh_width, 20)
             
            setfontcolor(unpack(lsh_font.color))
            addtextstroke("Total: " .. comma_value(totals.supplies) .. " GPs", lsh_pos.x + 7, lsh_pos.y + lsh_y_modifier + 15) 
            lsh_y_modifier = lsh_y_modifier + 20
        end
    end
     
    local profit = totals.loot - totals.supplies
    local p_hour = math.abs(math.floor((profit * 3600) / (timems / 1000) / 100) / 10) .. ' k/h)'
    if (profit >= 0) then
        setpen(unpack(lsh_colors.borders))
        if lsh_colors.cstatus.gradient then
            addgradcolors(build_params(lsh_colors.cstatus.gradmode.on))
            setfillstyle('gradient', 'linear', 1, 0, 0, 0, 50)
        else
            setfillcolor(unpack(lsh_colors.cstatus.rgbamode.on))
        end
     
        addrect(lsh_pos.x, lsh_pos.y + lsh_y_modifier, lsh_width, 20)
        setfontcolor(unpack(lsh_font.color))
        addtextstroke("Profit: " .. comma_value(profit) .. " GPs (" .. p_hour, lsh_pos.x + 7, lsh_pos.y + lsh_y_modifier + 15) 
    else
        setpen(unpack(lsh_colors.borders))
        if lsh_colors.cstatus.gradient then
            addgradcolors(build_params(lsh_colors.cstatus.gradmode.off))
            setfillstyle('gradient', 'linear', 1, 0, 0, 0, 50)
        else
            setfillcolor(unpack(lsh_colors.cstatus.rgbamode.off))
        end
     
        addrect(lsh_pos.x, lsh_pos.y + lsh_y_modifier, lsh_width, 20)
         
        setfontcolor(unpack(lsh_font.color))
        addtextstroke("Waste: -" .. comma_value(math.abs(profit)) .. " GPs (" .. p_hour, lsh_pos.x + 7, lsh_pos.y + lsh_y_modifier + 15)   
    end

  2. #2
    Moderator Drakke's Avatar
    Join Date
    Jun 2012
    Location
    Sweden
    Posts
    1,898
    Mentioned
    216 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    390 Post(s)
    Reputation
    366
    Rep Power
    10
    @PabloGura

    Do you have supplies listed in supplie section?

  3. #3
    iBot User PabloGura's Avatar
    Join Date
    Jun 2012
    Posts
    164
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    11 Post(s)
    Reputation
    11
    Rep Power
    5
    oohh, drake thank you, I stood back to use the little time and did not know this news .. working now

  4. #4
    iBot User PabloGura's Avatar
    Join Date
    Jun 2012
    Posts
    164
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    11 Post(s)
    Reputation
    11
    Rep Power
    5
    @Drakke
    i have more one doubt..

    this HUDS for recent PM and recent loot..

    dont work too..
    Code:
    --[[ 
        Name: Recent PM HUD
        Version: v2.0.0
        Status: Works
        TODO: 
    ]]--
    
    
    --How many lines of text:
    local totalLines = 5
    
    --Do not edit below:
    local spaceLines = 13
    local lines = 0
    local msgs = getmessages("Local Chat")
    local qtd = msgs.count-1
    
    
    for i=0,qtd 
    do
        if msgs[qtd-i].type == 6
        then
            setfontcolor("cyan")
            addtext(msgs[qtd-i].text, worldwin.left+5,worldwin.bottom-150+(lines*spaceLines))
            lines=lines+1
            if lines == totalLines 
            then
                break
            end
        end
    end

    Code:
    --[[ 
        Name: Recent Loot HUD
        Version: v2.0.0
        Status: Works
        TODO: 
    ]]--
    
    
    -- you can add more items here
    local warnitems = {'Life Ring', 'Mercenary Sword', 'Medusa Shield', 'Terra Mantle', 'Terra Legs', 'Titan Axe', 'Knight Armor', 'Noble Axe', 'Royal Helmet', 'Crown Armor', 'Tower Shield', 'Warrior Helmet', 'Spellbook of Mind Control', 'Swamplair Armor', 'Terra Amulet', 'Sacred Tree Amulet', "Stone Skin Amulet", "Ring of Healing", "Hydra Egg", "Boots of Haste", "Knight Legs", "Platinum Amulet", "Lightning Headband", "Bonebeast Trophy"}
    
    -- max lines to display at once 
    local maxindex = 10 
    
    -- spacing between lines
    local spacing = 15
    
    
    local index = 0 
    local msgs = getmessages("Server Log")
    local qtd = msgs.count-1
    for i=0,qtd do
       if msgs[qtd-i].type == 19 and msgs[qtd-i].text:find('Loot of ') then
          
          local colorm = false
          local l = 0
          for l=1, table.getn(warnitems) do
             if msgs[qtd-i].text:find(string.lower(warnitems[l])) then
                colorm = true
                break
             end
          end
          if colorm then
             setfontcolor('orange')
          else
             setfontcolor(rgbcolor(255, 255, 255))
          end
    
          addtext(msgs[qtd-i].text, worldwin.left+5,worldwin.bottom-(maxindex*spacing)+20+(index*spacing))
    
          index=index+1
          if index == maxindex then
            break
          end
       end
    end

Posting Permissions

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