Jump to content

Nametag


drk

Recommended Posts

Posted
        --vehicle health 
            local vehHealth = getElementHealth(getPedOccupiedVehicle(localPlayer)) 
             if vehHealth then 
               local health = math.max(health - 250, 0)/750 
               local r = -510*(health^2) 
               local g,b = math.max(math.min(r+255*health+255,255),0), math.max(math.min(p+765*health,255),0) 
                dxDrawRectangle(screenWidth-587,screenHeight-63,screenWidth-726,screenHeight-587,math.floor(256-256*(health)),tocolor(g,b,0,getElementAlpha(vehHealth)),false) 
            end 

Why don't appear anything in the screen? :S It is anything wrong?

Posted

Where is screenWidth and screenHeight defined? You need to add dxDrawRectangle to onClientRender event.

The argument in getElementAlpha is wrong, supposed to be an element.

Posted

Ah,

    local screenWidth, screenHeight = guiGetScreenSize() 

xD and it is on onClientRender event. I will solve getElementAlpha problem xD.

Posted
function Spectate.Render() 
    local screenWidth, screenHeight = guiGetScreenSize() 
    if Spectate.Render == true then 
        --local TextWidth = dxGetTextWidth( string.gsub ( "Currently spectating:", '#%x%x%x%x%x%x', '' ), 0.55, "default-bold" ) 
        --dxDrawColorText( string.gsub ( "#60f8ffCurrently spectating:", '#%x%x%x%x%x%x', '#000000' ) , 1+screenWidth/2-TextWidth/2, 1+screenHeight-120, 1+screenWidth/2-TextWidth/2, 1+screenHeight-120, tocolor(0, 0, 0, 255), 0.55, "default-bold" ) 
        --dxDrawColorText( "#60f8ffCurrently spectating:" , screenWidth/2-TextWidth/2, screenHeight-120, screenWidth/2-TextWidth/2, screenHeight-120, tocolor(255, 255, 255, 255), 0.55, "default-bold" ) 
        if Spectate.TargetPlayer then 
            local r,g,b = 255,255,255 
            local team = getPlayerTeam(Spectate.TargetPlayer) 
            if team then 
                r,g,b = getTeamColor(team) 
            end 
            local TargetWidth = dxGetTextWidth( string.gsub ( _getPlayerName(Spectate.TargetPlayer), '#%x%x%x%x%x%x', '' ), 0.46, "bankgothic" ) 
            local TargetHeight = dxGetFontHeight( 0.55, "bankgothic" ) 
            dxDrawColorText( string.gsub ( _getPlayerName(Spectate.TargetPlayer), '#%x%x%x%x%x%x', '#000000' ) , 1+screenWidth/3.8-TargetWidth/6.25, 1+screenHeight-99+TargetHeight, 1+screenWidth/2-TargetWidth/2, 1+screenHeight-120+TargetHeight, tocolor(0, 0, 0, 255), 0.55, "bankgothic" ) 
            dxDrawColorText( _getPlayerName(Spectate.TargetPlayer) , screenWidth/3.8-TargetWidth/6.25, screenHeight-99+TargetHeight, screenWidth/2-TargetWidth/2, screenHeight-120+TargetHeight, tocolor(r, g, b, 255), 0.55, "bankgothic" ) 
        --vehicle health 
            local vehHealth = getElementHealth(getPedOccupiedVehicle(Spectate.TargetPlayer)) 
             if vehHealth then 
               local health = math.max(health - 250, 0)/750 
               local r = -510*(health^2) 
               local g,b = math.max(math.min(r+255*health+255,255),0), math.max(math.min(p+765*health,255),0) 
                dxDrawRectangle(screenWidth-587,screenHeight-63,screenWidth-726,screenHeight-587,math.floor(200*(health)),tocolor(g,b,0,getElementAlpha(Spectate.TargetPlayer)),false) 
            end 
        else 
            local NoOneWidth = dxGetTextWidth( string.gsub ( "No one to spectate", '#%x%x%x%x%x%x', '' ), 0.55, "bankgothic" ) 
            local NoOneHeight = dxGetFontHeight( 0.55, "bankgothic" ) 
            dxDrawColorText( string.gsub ( "#FFFFFFNo one to spectate", '#%x%x%x%x%x%x', '#000000' ), 1+screenWidth/4-NoOneWidth/6, 1+screenHeight-90+NoOneHeight, 1+screenWidth/2-NoOneWidth/2, 1+screenHeight-120+NoOneHeight, tocolor(0, 0, 0, 255), 0.55, "bankgothic" ) 
            dxDrawColorText( "#FFFFFFNo one to spectate", screenWidth/4-NoOneWidth/6, screenHeight-90+NoOneHeight, screenWidth/2-NoOneWidth/2, screenHeight-120+NoOneHeight, tocolor(255, 255, 255, 255), 0.55, "bankgothic" ) 
        end 
        if Spectate.active and Spectate.savePos then 
            --local JoinWidth = dxGetTextWidth( string.gsub ( "Press 'B' to join", '#%x%x%x%x%x%x', '' ), 0.55, "default-bold" ) 
            --local JoinHeight = dxGetFontHeight( 0.55, "default-bold" ) 
            --dxDrawColorText( string.gsub ("#FFFFFFPress #ffffff'B'#FFFFFF to join", '#%x%x%x%x%x%x', '' ), 1+screenWidth/4-JoinWidth/6, 1+screenHeight-90+JoinHeight*3, 1+screenWidth/2-JoinWidth/2, 1+screenHeight-120+JoinHeight*3, tocolor(0, 0, 0, 255), 0.55, "default-bold" ) 
            --dxDrawColorText( "#FFFFFFPress #ffffff'B'#60f8ff to join", screenWidth/4-JoinWidth/6, screenHeight-90+JoinHeight*3, screenWidth/2-JoinWidth/2, screenHeight-120+JoinHeight*3, tocolor(255, 255, 255, 255), 0.55, "default-bold" ) 
        end 
    end 
end 
addEventHandler("onClientRender", g_Root, Spectate.Render) 

I get this error: "Cannot perform arithmetic on global 'health' ( a nil value )"

Posted
function Spectate.Render() 
    local screenWidth, screenHeight = guiGetScreenSize() 
    if Spectate.Render == true then 
        --local TextWidth = dxGetTextWidth( string.gsub ( "Currently spectating:", '#%x%x%x%x%x%x', '' ), 0.55, "default-bold" ) 
        --dxDrawColorText( string.gsub ( "#60f8ffCurrently spectating:", '#%x%x%x%x%x%x', '#000000' ) , 1+screenWidth/2-TextWidth/2, 1+screenHeight-120, 1+screenWidth/2-TextWidth/2, 1+screenHeight-120, tocolor(0, 0, 0, 255), 0.55, "default-bold" ) 
        --dxDrawColorText( "#60f8ffCurrently spectating:" , screenWidth/2-TextWidth/2, screenHeight-120, screenWidth/2-TextWidth/2, screenHeight-120, tocolor(255, 255, 255, 255), 0.55, "default-bold" ) 
        if Spectate.TargetPlayer then 
            local r,g,b = 255,255,255 
            local team = getPlayerTeam(Spectate.TargetPlayer) 
            if team then 
                r,g,b = getTeamColor(team) 
            end 
            local TargetWidth = dxGetTextWidth( string.gsub ( _getPlayerName(Spectate.TargetPlayer), '#%x%x%x%x%x%x', '' ), 0.46, "bankgothic" ) 
            local TargetHeight = dxGetFontHeight( 0.55, "bankgothic" ) 
            dxDrawColorText( string.gsub ( _getPlayerName(Spectate.TargetPlayer), '#%x%x%x%x%x%x', '#000000' ) , 1+screenWidth/3.8-TargetWidth/6.25, 1+screenHeight-99+TargetHeight, 1+screenWidth/2-TargetWidth/2, 1+screenHeight-120+TargetHeight, tocolor(0, 0, 0, 255), 0.55, "bankgothic" ) 
            dxDrawColorText( _getPlayerName(Spectate.TargetPlayer) , screenWidth/3.8-TargetWidth/6.25, screenHeight-99+TargetHeight, screenWidth/2-TargetWidth/2, screenHeight-120+TargetHeight, tocolor(r, g, b, 255), 0.55, "bankgothic" ) 
        --vehicle health 
            local health = getElementHealth(getPedOccupiedVehicle(Spectate.TargetPlayer)) 
             if health then 
               local health = math.max(health - 250, 0)/750 
               local r = -510*(health^2) 
               local g,b = math.max(math.min(r+255*health+255,255),0), math.max(math.min(p+765*health,255),0) 
                dxDrawRectangle(screenWidth-587,screenHeight-63,screenWidth-726,screenHeight-587,math.floor(200*(health)),tocolor(g,b,0,getElementAlpha(Spectate.TargetPlayer)),false) 
            end 
        else 
            local NoOneWidth = dxGetTextWidth( string.gsub ( "No one to spectate", '#%x%x%x%x%x%x', '' ), 0.55, "bankgothic" ) 
            local NoOneHeight = dxGetFontHeight( 0.55, "bankgothic" ) 
            dxDrawColorText( string.gsub ( "#FFFFFFNo one to spectate", '#%x%x%x%x%x%x', '#000000' ), 1+screenWidth/4-NoOneWidth/6, 1+screenHeight-90+NoOneHeight, 1+screenWidth/2-NoOneWidth/2, 1+screenHeight-120+NoOneHeight, tocolor(0, 0, 0, 255), 0.55, "bankgothic" ) 
            dxDrawColorText( "#FFFFFFNo one to spectate", screenWidth/4-NoOneWidth/6, screenHeight-90+NoOneHeight, screenWidth/2-NoOneWidth/2, screenHeight-120+NoOneHeight, tocolor(255, 255, 255, 255), 0.55, "bankgothic" ) 
        end 
        if Spectate.active and Spectate.savePos then 
            --local JoinWidth = dxGetTextWidth( string.gsub ( "Press 'B' to join", '#%x%x%x%x%x%x', '' ), 0.55, "default-bold" ) 
            --local JoinHeight = dxGetFontHeight( 0.55, "default-bold" ) 
            --dxDrawColorText( string.gsub ("#FFFFFFPress #ffffff'B'#FFFFFF to join", '#%x%x%x%x%x%x', '' ), 1+screenWidth/4-JoinWidth/6, 1+screenHeight-90+JoinHeight*3, 1+screenWidth/2-JoinWidth/2, 1+screenHeight-120+JoinHeight*3, tocolor(0, 0, 0, 255), 0.55, "default-bold" ) 
            --dxDrawColorText( "#FFFFFFPress #ffffff'B'#60f8ff to join", screenWidth/4-JoinWidth/6, screenHeight-90+JoinHeight*3, screenWidth/2-JoinWidth/2, screenHeight-120+JoinHeight*3, tocolor(255, 255, 255, 255), 0.55, "default-bold" ) 
        end 
    end 
end 
addEventHandler("onClientRender", g_Root, Spectate.Render) 

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...