Jump to content

Simple question


manve1

Recommended Posts

FancyProgress = {} 
FancyProgress.__index = FancyProgress 
  
function FancyProgress.create(minval, maxval, bgName, x, y, width, height, barName, barOffsetX, barOffsetY, barWidth, barHeight) 
    local screenWidth, screenHeight = guiGetScreenSize() 
    if screenWidth < 1280 and screenHeight < 1024 then 
        x = resAdjust(x) 
        y = resAdjust(y) 
        width = resAdjust(width) 
        height = resAdjust(height) 
        barOffsetX = resAdjust(barOffsetX) 
        barOffsetY = resAdjust(barOffsetY) 
        barWidth = resAdjust(barWidth) 
        barHeight = resAdjust(barHeight) 
    end 
    if x < 0 then 
        x = screenWidth - width + x 
    end 
    if y < 0 then 
        y = screenHeight - height + y 
    end 
    return setmetatable( 
        { 
            background = guiCreateStaticImage(x, y, width, height, bgName, false, nil), 
            bar = guiCreateStaticImage(x + barOffsetX, y + barOffsetY, barWidth, barHeight, barName, false, nil), 
            width = barWidth, 
            height = barHeight, 
            min = minval, 
            max = maxval, 
            range = maxval - minval, 
            progress = maxval 
        }, 
        FancyProgress 
    ) 
end 
  
function FancyProgress:setProgress(progress) 
    if not progress then progress = 0 end 
    if progress < self.min then 
        progress = self.min 
    elseif progress > self.max then 
        progress = self.max 
    end 
    if progress ~= self.progress then 
        guiSetSize(self.bar, math.floor((progress-self.min)*self.width/self.range), self.height, false) 
        self.progress = progress 
    end 
end 
  
function FancyProgress:show() 
    guiSetVisible(self.background, true) 
    guiSetVisible(self.bar, true) 
end 
  
function FancyProgress:hide() 
    guiSetVisible(self.background, false) 
    guiSetVisible(self.bar, false) 
end 
  
function FancyProgress:destroy() 
    destroyElement(self.background) 
    self.background = nil 
    destroyElement(self.bar) 
    self.bar = nil 
end 
  
p_HealthBar = FancyProgress.create( 
    0, 100, 
    "hud.health.png", -1268.25, 736.35, 2, 60,     "hud/p.png", 
    0.9, 8, 0.1, 15.4 
) 
  
function getTeamHealth(team) 
    if team then 
        HP = 0 
        for i, player in ipairs(getPlayersInTeam(team)) do 
            HP = HP + getElementHealth(player) 
        end 
        return HP 
    end 
end 
setTimer( getTeamHealth, 100, 0 ) 
  
setTimer( 
function( ) 
p_HealthBar:setProgress( getTeamHealth ) 
end, 100, 0 
) 

ERROR: line.39 @ attempt to compare function with a number

Mind helping me out with this?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...