Jump to content

Attempt to Compare Nil with Number


bmazoka

Recommended Posts

setElementFrozen(value, false) 
                    mysql:query_free("UPDATE characters SET jail='0' WHERE id = " .. dbid)  
                    mysql:query_free("UPDATE characters SET jailtime=NULL WHERE id = " .. dbid) 
                    outputChatBox("You are no longer in Jail!", value, 0, 255, 0) 

Link to comment
                local result2 = mysql:query_fetch_assoc( "SELECT `jailtime` FROM `characters` WHERE `id`=" .. mysql:escape_string(dbid) ) 
                local nn = tonumber(result2[1]["jailtime"]) 
                local currenttime = getRealTime() 
                local currenttimereal = ("%04d%02d%02d%02d%02d%02d"):format(currenttime.year+1900, currenttime.month + 1, currenttime.monthday, currenttime.hour,currenttime.minute, currenttime.second) 
                local bb = tonumber(currenttimereal) 
                if (nn) then 
                    setElementFrozen(value, false) 
                    mysql:query_free("UPDATE characters SET jail='0' WHERE id = " .. dbid) 
                    mysql:query_free("UPDATE characters SET jailtime=NULL WHERE id = " .. dbid) 
                    outputChatBox("You are no longer in Jail!", value, 0, 255, 0) 

Try it.

Link to comment
local result2 = mysql:query_fetch_assoc( "SELECT `jailtime` FROM `characters` WHERE `id`=" .. mysql:escape_string(dbid) ) 
               outputChatBox ( "result2: ".. tostring ( result2 ) ) 
               outputChatBox ( "result2 jailtime: ".. tostring ( result2 [ "jailtime" ] ) ) 
                local nn = tonumber(result2["jailtime"]) 
                local currenttime = getRealTime() 
                local currenttimereal = ("%04d%02d%02d%02d%02d%02d"):format(currenttime.year+1900, currenttime.month + 1, currenttime.monthday, currenttime.hour,currenttime.minute, currenttime.second) 
                local bb = tonumber(currenttimereal) 
                if (nn) then 
                    setElementFrozen(value, false) 
                    mysql:query_free("UPDATE characters SET jail='0' WHERE id = " .. dbid) 
                    mysql:query_free("UPDATE characters SET jailtime=NULL WHERE id = " .. dbid) 
                    outputChatBox("You are no longer in Jail!", value, 0, 255, 0) 

Use that and see what it outputs.

Link to comment

It stores when the player will be released, for example /jail [iD of Player] [Number of Hours]

Should log 1 hour later from the current time if I put 1 hour as the "Number of Hours" then the script checks every 5 mins if the time to be released has passed.

At least thats what it is supposed to do..

Link to comment

Use this for writing:

exports.logs:dbLog(thePlayer, 4, targetPlayer, "JAIL " .. duration) 
local r = getRealTime() 
local jailTime = ( r.timestamp + duration * 60 * 60 ) 
mysql:query_free("UPDATE characters SET jailtime='" ..jailTime.. "' WHERE id = " .. dbid) 

And this for loading:

local result2 = mysql:query_fetch_assoc( "SELECT `jailtime` FROM `characters` WHERE `id`=" .. mysql:escape_string(dbid) ) 
local nn = tonumber(result2["jailtime"]) 
local currenttime = getRealTime().timestamp 
local timeLeft = ( currenttime - nn ) 
if ( timeLeft <= 0 ) then 
    setElementFrozen(value, false) 
    mysql:query_free("UPDATE characters SET jail='0' WHERE id = " .. dbid) 
    mysql:query_free("UPDATE characters SET jailtime=NULL WHERE id = " .. dbid) 
    outputChatBox("You are no longer in Jail!", value, 0, 255, 0) 

Lemme know if it works.

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