Jump to content

Forever ban


Best-Killer

Recommended Posts

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

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

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