Jump to content

attempt to compare number with nil.


Aristates

Recommended Posts

Where The Problems ? debug say's ; :6 attempt to compare number with nil.

addEvent("AristatesOnServer", true) 
        addEventHandler("AristatesOnServer", getRootElement(), 
        function() 
                local Aristates = getPlayerAccount(source) 
                if Aristates then 
                    if tonumber(getAccountData(Aristates,"cash")) >= 50000 then 
                        setAccountData(Aristates,"cash",(tonumber(getAccountData(Aristates,"cash")) or 0)-50000) 
                    else 
                        outputChatBox ( "Yetersiz Para", source, 255, 255, 255, true ) 
                    end 
                end 
            end 
        ) 

Link to comment

if it is nil then player account data "cash" is nil.

if you want to dont give error until he gets actual money and saves it then use this code

  
addEvent("AristatesOnServer", true) 
        addEventHandler("AristatesOnServer", getRootElement(), 
        function() 
                local Aristates = getPlayerAccount(source) 
                if Aristates then 
if tonumber(getAccountData(Aristates,"cash")) == nil then return end 
                    if tonumber(getAccountData(Aristates,"cash")) >= 50000 then 
                        setAccountData(Aristates,"cash",(tonumber(getAccountData(Aristates,"cash")) or 0)-50000) 
                    else 
                        outputChatBox ( "Yetersiz Para", source, 255, 255, 255, true ) 
                    end 
                end 
            end 
        ) 

Link to comment
  • 1 month later...
Where The Problems ? debug say's ; :6 attempt to compare number with nil.
addEvent("AristatesOnServer", true) 
        addEventHandler("AristatesOnServer", getRootElement(), 
        function() 
                local Aristates = getPlayerAccount(source) 
                if Aristates then 
                    if tonumber(getAccountData(Aristates,"cash")) >= 50000 then 
                        setAccountData(Aristates,"cash",(tonumber(getAccountData(Aristates,"cash")) or 0)-50000) 
                    else 
                        outputChatBox ( "Yetersiz Para", source, 255, 255, 255, true ) 
                    end 
                end 
            end 
        ) 

AccountData of "cash" is nil, maybe you didnt set it correctly

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