Best-Killer Posted January 6, 2017 Share Posted January 6, 2017 Forever ban = the duration need to be 0 as i think function cacheBans() local query = exports.NGsql:db_query("SELECT * FROM `bans`") for _, ent in ipairs(query) do table.insert(bans, {ent.srl, getIDAccount(ent.banner), ent.reason, ent.startdate, ent.duration, getIDName(ent.banner), getIDLastIp(ent.banned), getIDName(ent.banned)}) end end function deleteOldBans() local deletion = {} for i, ent in pairs(bans) do if (ent[5] ~= -1 and (ent[4] + ent[5]) - getRealTime().timestamp <= 0) then table.insert(deletion, ent[1]) table.remove(bans, i) end end if (#deletion >= 1) then for _, val in ipairs(deletion) do exports.NGsql:db_exec("DELETE FROM `bans` WHERE `srl` = ?", val) -- Must add some form of server log here end end end with my code if the duration 0 it's will be delete pff what is the problem guys or give me other example pls Link to comment
Captain Cody Posted January 6, 2017 Share Posted January 6, 2017 -1 That's a forever ban... Link to comment
Best-Killer Posted January 6, 2017 Author Share Posted January 6, 2017 addEventHandler("onResourceStart", resourceRoot, function () exports.NGsql:db_exec("DELETE FROM `bans` WHERE (`duration` + `startdate`) - UNIX_TIMESTAMP() <= 0") cacheBans() setTimer(deleteOldBans, 15000, 0) -- Every 15 seconds end ) check this too pffff i tried -1 and same problem Link to comment
Best-Killer Posted January 6, 2017 Author Share Posted January 6, 2017 if the duration is 0 or -1 the database will be deleted pls help pfff Link to comment
Bonsai Posted January 6, 2017 Share Posted January 6, 2017 Is that something public or leaked? Link to comment
Best-Killer Posted January 6, 2017 Author Share Posted January 6, 2017 not public and not leaked i'm making it and i'm not pro at scripting so i need help 1 Link to comment
MTA Anti-Cheat Team Dutchman101 Posted January 6, 2017 MTA Anti-Cheat Team Share Posted January 6, 2017 26 minutes ago, Bonsai said: Is that something public or leaked? Maybe it sounds familiar to you because of ''NG'' prefixes, but NG is a public gamemode (NerdGaming) refer to: https://github.com/braydondavis/Nerd-Gaming-Public Thanks for the report and worries but totally fine. Link to comment
Best-Killer Posted January 6, 2017 Author Share Posted January 6, 2017 my gamemode is nerd gaming but i'm developering it please any help me guys? pfffff function deleteOldBans() local deletion = {} for i, ent in pairs(bans) do if (ent[5] ~= -1 and (ent[4] + ent[5]) - getRealTime().timestamp <= 1) then table.insert(deletion, ent[1]) table.remove(bans, i) outputDebugString(""passed pfffff"") end end if (#deletion >= 1) then for _, val in ipairs(deletion) do exports.NGsql:db_exec("DELETE FROM `bans` WHERE `srl` = ?", val) end end end if the ent[5] (Duration) = -1 the database will be deleted pff what is the problem !!! NOTE: if (ent[5] ~= -1 and (ent[4] + ent[5]) - getRealTime().timestamp <= 1) then ...... i tried with changing it to : if (ent[5] ~= -1 and (ent[4] + ent[5]) - getRealTime().timestamp <= 0) then but still same problem please help me guys Link to comment
Bonsai Posted January 6, 2017 Share Posted January 6, 2017 If you are not sure about the if condition then simply make it two seperate ones. Also I think removing an entry from the table you are currently looping through will break something. Link to comment
Best-Killer Posted January 6, 2017 Author Share Posted January 6, 2017 56 minutes ago, Bonsai said: If you are not sure about the if condition then simply make it two seperate ones. Also I think removing an entry from the table you are currently looping through will break something. bro i didn't understand please explain more to me ? 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