Jump to content

[HELP] Attempt to compare number with boolean


yusufbali

Recommended Posts

Hi Guys, I want help to you.

local root = getRootElement() 
local player = getLocalPlayer() 
local counter = 0 
local starttick 
local currenttick 
addEventHandler("onClientRender",root, 
    function() 
        if not starttick then 
            starttick = getTickCount() 
        end 
        counter = counter + 1 
        currenttick = getTickCount() 
        if currenttick - starttick >= 1000 then 
            setElementData(player,"FPS",counter) 
            counter = 0 
            starttick = false 
        end 
    end 
) 
  
  
function drawStates () 
    addEventHandler ( "onClientRender", root, pingFpsCiz ) 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, drawStates ) 
  
  
myFont4 = dxCreateFont("fps.ttf", 12 ) 
function pingFpsCiz() 
x,y = guiGetScreenSize() 
local ping = getPlayerPing(getLocalPlayer())   
dxDrawText("Ping", 1115/1366*x, 0/768*y, 590/1366*x, 26/768*y, tocolor(255, 255, 255, 255), 0.95, myFont4, "left", "center", false, false, false, true, false) 
dxDrawText("Fps", 1035/1366*x, 0/768*y, 590/1366*x, 26/768*y, tocolor(255, 255, 255, 255), 0.95, myFont4, "left", "center", false, false, false, true, false) 
if (ping <= 25) then        
dxDrawText("#00ff00"..getPlayerPing(getLocalPlayer()), 1660/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false)        
end 
if (ping >= 26) and (ping <= 40) then        
dxDrawText("#5dff00"..getPlayerPing(getLocalPlayer()), 1660/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false)        
end 
if (ping >= 41) and (ping <= 60) then        
dxDrawText("#a6f900"..getPlayerPing(getLocalPlayer()), 1660/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false)        
end 
if (ping >= 61) and (ping <= 80) then        
dxDrawText("#defc00"..getPlayerPing(getLocalPlayer()), 1660/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false)        
end 
if (ping >= 81) and (ping <= 100) then        
dxDrawText("#ffee00"..getPlayerPing(getLocalPlayer()), 1660/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false)        
end 
if (ping >= 101) and (ping <= 110) then        
dxDrawText("#fcb400"..getPlayerPing(getLocalPlayer()), 1660/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false)        
end 
if (ping >= 110) then        
dxDrawText("#fc3f00"..getPlayerPing(getLocalPlayer()), 1660/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false)        
end 
  
local fps = getElementData(getLocalPlayer(),"FPS") 
  
if (fps >= 50) then 
dxDrawText("#00ff00"..getElementData(getLocalPlayer(),"FPS"), 1500/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false)   
end 
if (fps <= 49) and (fps >= 45) then 
dxDrawText("#5dff00"..getElementData(getLocalPlayer(),"FPS"), 1500/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false)   
end 
if (fps <= 44) and (fps >= 40) then 
dxDrawText("#defc00"..getElementData(getLocalPlayer(),"FPS"), 1500/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false)   
end 
if (fps <= 39) and (fps >= 35) then 
dxDrawText("#fcb400"..getElementData(getLocalPlayer(),"FPS"), 1500/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false)   
end 
if (fps <= 34) then 
dxDrawText("#fcb400"..getElementData(getLocalPlayer(),"FPS"), 1500/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false)   
end 
end 
  

client.lua:542:Attempt to compare number with boolean

client.lua:542:Attempt to compare number with boolean [DUP x52]

This is 542:

if (fps >= 50) then 
dxDrawText("#00ff00"..getElementData(getLocalPlayer(),"FPS"), 1500/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false)   
end 

Why only this line give error and what i mistake ?

Link to comment

This is working perfectly, and btw i improved a little bit your script.

local counter = 0 
local starttick 
local currenttick 
addEventHandler("onClientRender",root, 
function() 
    if not starttick then 
        starttick = getTickCount() 
    end 
    counter = counter + 1 
    currenttick = getTickCount() 
    if currenttick - starttick >= 1000 then 
        setElementData(localPlayer,"FPS",counter) 
        counter = 0 
        starttick = false 
    end 
end) 
  
  
function drawStates () 
    addEventHandler ( "onClientRender", root, pingFpsCiz ) 
end 
addEventHandler ( "onClientResourceStart", resourceRoot, drawStates ) 
  
  
myFont4 = dxCreateFont("fps.ttf", 12 ) 
function pingFpsCiz() 
    local x, y = guiGetScreenSize() 
    local ping = getPlayerPing(localPlayer)   
    dxDrawText("Ping", 1115/1366*x, 0/768*y, 590/1366*x, 26/768*y, tocolor(255, 255, 255, 255), 0.95, myFont4, "left", "center", false, false, false, true, false) 
    dxDrawText("Fps", 1035/1366*x, 0/768*y, 590/1366*x, 26/768*y, tocolor(255, 255, 255, 255), 0.95, myFont4, "left", "center", false, false, false, true, false)     
    if ping then 
        local pingColor = ping <= 25 and "#00ff00" or (((ping >= 26) and (ping <= 40)) and "#5dff00" or (((ping >= 41) and (ping <= 60)) and "#a6f900" or (((ping >= 61) and (ping <= 80)) and "#defc00" or (((ping >= 81) and (ping <= 100)) and "#ffee00" or (((ping >= 101) and (ping <= 110)) and "#fcb400"  or (ping >= 111 and "#fc3f00")))))) 
        dxDrawText(pingColor..ping, 1660/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false) 
    end 
    local fps = getElementData(localPlayer, "FPS") 
    if fps then 
        local fpsColor = fps <= 34 and "#fcb400" or (((fps <= 39) and (fps >= 35)) and "#fcb400" or (((fps <= 44) and (fps >= 40)) and "#defc00" or (((fps <= 44) and (fps >= 40)) and "#5dff00" or (fps >= 41 and "#00ff00")))) 
        dxDrawText(fpsColor..fps, 1500/1366*x, 35/768*y, 590/1366*x, 30/768*y, tocolor(13, 241, 131, 255), 1.0, myFont4, "center", "top", false, false, false, true, false) 
    end 
end 

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