Jump to content

attempt to perform arithmetic on local 'timeleft' (boolean value)


almafa123

Recommended Posts

Hello


function timerUnjailPlayer(jailedPlayer)
    local timeLeft = getElementData(jailedPlayer,"jail->Jailtime")
    timeLeft = timeLeft - 1

    if tonumber(timeLeft) <= 0 then
        dbPoll ( dbQuery( connection, "UPDATE accounts SET jailedtime='0', jailed='0' WHERE id='?'", getElementData(jailedPlayer, "acc.accountID")), -1 )
        setElementData(jailedPlayer, "jail->Jailtime", 0)
        setElementData(jailedPlayer, "jail->Timer", nil)
        setElementData(jailedPlayer, "jail->Time", 0)
        
        setElementPosition(jailedPlayer, 1519.7177734375, -1697.8154296875, 13.546875)
        setPedRotation(jailedPlayer, 269.92446899414)
        setElementDimension(jailedPlayer, 0)
        setElementInterior(jailedPlayer, 0)
        setCameraInterior(jailedPlayer, 0)
        toggleControl(jailedPlayer,'next_weapon',true)
        toggleControl(jailedPlayer,'previous_weapon',true)
        toggleControl(jailedPlayer,'fire',true)
        toggleControl(jailedPlayer,'aim_weapon',true)
        outputChatBox("#87D37CKiszabadítottak a börtönbõl! Legközelebb ésszel viselkedj!", jailedPlayer, 0, 0, 0,true)
    else    
        setElementData(jailedPlayer,"jail->Jailtime",timeLeft)    
        dbPoll ( dbQuery( connection, "UPDATE accounts SET jailedtime=? WHERE id='?'",tonumber(timeLeft), getElementData(jailedPlayer, "acc.accountID")), -1 )
    end
end    

Warning: /admin/codeserver.lua:822: Bad argument @ 'getelementdata' [Expected element at argument 1]

Error: /admin/codeserver.lua:823: attempt to perform arithmetic on local 'timeLeft' (a boolean value)

Please help me.

Thanx.

Link to comment

This seems like the function timerUnjailPlayer receives a nil instead of the player on parameter jailedPlayer (hence error at line 822) and that results in no element data being collected, creating an arithmetic error on line 823 when trying to compare no data to a number.

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