Jump to content

Attempt to Compare Nil with Number


bmazoka

Recommended Posts

Posted

What does "nn" and "bb" return?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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) 

Posted

No, I asked what does "nn" and "bb" return? what values?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Add this to see what these two variables are returning:

outputChatBox ( "nn: ".. tostring ( nn ) ) 
outputChatBox ( "bb: ".. tostring ( bb ) ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Well, there's your problem "2013-12-14 19:03:14" is not a number, is an string, if you use tonumber, it'll return nil.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I guess you could use timestamps to do it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Does "duration" contain the seconds? or what is the value of it?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Are you storing when the player was jailed?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

Posted

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Attempt to perform arithmetic on local 'nn'

Also the jailtime still comes up

result2: table: 1B85D638

result2 jailtime: 2013-12-15 23:27:05

Posted

You must jail a player with the new writing method, else the data will obviously be the old one.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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