Jump to content

[Error] Attempting to compare a number with a boolean


Recommended Posts

I get an error for attempting to compare a number with a boolean on line 4.

addEventHandler("onClientRender", root, 
   function() 
        local screenx, screeny, worldx, worldy, worldz = getCursorPosition() 
        if (screenx >= 924 and screenx <= 983) and (screeny <= 375 and screeny >=360) then 
            redMessage = dxDrawText("Message", 924, 375, 977, 390, tocolor(255, 0, 0, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
        else 
            dxDrawText("Message", 924, 375, 977, 390, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
        end 
        addEventHandler("onClientGUIClick", redMessage, clickOnMessage) 
    end 
) 

Edited by Guest
Link to comment

Replace this:

if (screenx >= 924 and screenx <= 983) and (screeny <= 375 and screeny >=360) then 

With this:

if (screenx and screeny and screenx >= 924 and screenx <= 983) and (screeny <= 375 and screeny >=360) then 

And the if statement will verify that screenx and screeny has a value that isn't false (which will output the error you received). The root of this problem is as Plean said: "If the cursor isn't showing, returns false as the first value.", another option could be o check if the cursor is showing in this if statement as well.

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