bmazoka Posted December 15, 2013 Share Posted December 15, 2013 (edited) . Edited December 22, 2013 by Guest Link to comment
Castillo Posted December 15, 2013 Share Posted December 15, 2013 What does "nn" and "bb" return? Link to comment
bmazoka Posted December 15, 2013 Author Share Posted December 15, 2013 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
Castillo Posted December 15, 2013 Share Posted December 15, 2013 No, I asked what does "nn" and "bb" return? what values? Link to comment
bmazoka Posted December 15, 2013 Author Share Posted December 15, 2013 (edited) . Edited December 22, 2013 by Guest Link to comment
Castillo Posted December 15, 2013 Share Posted December 15, 2013 Add this to see what these two variables are returning: outputChatBox ( "nn: ".. tostring ( nn ) ) outputChatBox ( "bb: ".. tostring ( bb ) ) Link to comment
bmazoka Posted December 15, 2013 Author Share Posted December 15, 2013 (edited) . Edited December 22, 2013 by Guest Link to comment
Castillo Posted December 15, 2013 Share Posted December 15, 2013 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
bmazoka Posted December 15, 2013 Author Share Posted December 15, 2013 (edited) . Edited December 22, 2013 by Guest Link to comment
Castillo Posted December 15, 2013 Share Posted December 15, 2013 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
bmazoka Posted December 15, 2013 Author Share Posted December 15, 2013 (edited) . Edited December 22, 2013 by Guest Link to comment
Castillo Posted December 15, 2013 Share Posted December 15, 2013 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. Link to comment
bmazoka Posted December 15, 2013 Author Share Posted December 15, 2013 (edited) . Edited December 22, 2013 by Guest Link to comment
Castillo Posted December 15, 2013 Share Posted December 15, 2013 I guess you could use timestamps to do it. Link to comment
bmazoka Posted December 16, 2013 Author Share Posted December 16, 2013 Can you show me how I would do that? Thanks for all the help. Link to comment
Castillo Posted December 16, 2013 Share Posted December 16, 2013 Does "duration" contain the seconds? or what is the value of it? Link to comment
bmazoka Posted December 16, 2013 Author Share Posted December 16, 2013 Duration is done in hours. It allows for logging while the player is offline Link to comment
Castillo Posted December 16, 2013 Share Posted December 16, 2013 Are you storing when the player was jailed? Link to comment
bmazoka Posted December 16, 2013 Author Share Posted December 16, 2013 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
bmazoka Posted December 16, 2013 Author Share Posted December 16, 2013 I can show you the entire script if need be. Just let me know Link to comment
Castillo Posted December 16, 2013 Share Posted December 16, 2013 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
bmazoka Posted December 16, 2013 Author Share Posted December 16, 2013 Attempt to perform arithmetic on local 'nn' Also the jailtime still comes up result2: table: 1B85D638 result2 jailtime: 2013-12-15 23:27:05 Link to comment
Castillo Posted December 16, 2013 Share Posted December 16, 2013 You must jail a player with the new writing method, else the data will obviously be the old one. Link to comment
bmazoka Posted December 16, 2013 Author Share Posted December 16, 2013 (edited) -snip - Edited December 16, 2013 by Guest Link to comment
bmazoka Posted December 16, 2013 Author Share Posted December 16, 2013 (edited) Snip Edited December 16, 2013 by Guest Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now