Need Server help/dev for banning

Hello, wondering if anyone can help me. In my server when i do /ban its not even a command. Even though i have a database setup with essentials and i can assign admins
but /ban just shows up as text in chat

please respond of join discord. i am chris.
discord.gg/2DUvfgS

I don’t think essential has a /ban command. You would have to create it yourself.

I believe that there is a rcon command that you can use to ban someone, just connect to the server using rcon (if on windows, just use the console) and type tempbanclient <id> [reason]

tempbanclient in rcon only bans until restart. I need someone to help me make a command admins can use to ban people permanently even after restart, and that can be edited to unban them.

Here is a ban script i use, Add this to your sv_admin.lua (ES_ADMIN)

TriggerEvent('es:addGroupCommand', 'ban', "admin", function(source, args, user)
		if(GetPlayerName(tonumber(args[2])) ~= nil)then
			-- User permission check
			local player = tonumber(args[2])
			TriggerEvent("es:getPlayerFromId", player, function(target)
					if(tonumber(target.permission_level) > tonumber(user.permission_level))then
						TriggerClientEvent("chatMessage", source, "SYSTEM", {255, 0, 0}, "You're not allowed to target this person!")
						return
					end
				local time = args[3]

				local message = ""

				if string.find(time, "m") then
					time = string.gsub(time, "m", "")
					time = os.time() + (tonumber(time) * 60)
					message = time .. " minute(s)"
				elseif string.find(time, "h") then
					time = string.gsub(time, "h", "")
					message = time .. " hour(s)"
					time = os.time() + (tonumber(time) * 60 * 60)
				else
					time = os.time() + tonumber(time)
					message = time .. " second(s)"
				end

				if not tonumber(time) > 0 then
					time = os.time() + 999999999999
					message = 'very long'
				end

				local reason = args
				table.remove(reason, 1)
				table.remove(reason, 1)
				table.remove(reason, 1)

				reason = "Banned: " .. table.concat(reason, " ")

				if(reason == "Banned: ")then
					reason = reason .. "You have been banned for: ^1" .. message .. "^0."
					DropPlayer(player, "You have been banned for: " .. message)
				else
					DropPlayer(player, "Banned: " .. reason)
				end

				TriggerClientEvent('chatMessage', -1, "SYSTEM", {255, 0, 0}, "Player ^2" .. GetPlayerName(player) .. "^0 has been banned(^2" .. reason .. "^0)")

				local tstamp = os.date("*t", time)
				local tstamp2 = os.date("*t", os.time())

				MySQL:executeQuery("INSERT INTO bans (`banned`, `reason`, `expires`, `banner`, `timestamp`) VALUES ('@username', '@reason', '@expires', '@banner', '@now')",
				{['@username'] = target.identifier, ['@reason'] = reason, ['@expires'] = os.date(tstamp.year .. "-" .. tstamp.month .. "-" .. tstamp.day .. " " .. tstamp.hour .. ":" .. tstamp.min .. ":" .. tstamp.sec), ['@banner'] = user.identifier, ['@now'] = os.date(tstamp2.year .. "-" .. tstamp2.month .. "-" .. tstamp2.day .. " " .. tstamp2.hour .. ":" .. tstamp2.min .. ":" .. tstamp2.sec)})
			end)
		else
			TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Incorrect player ID!")
		end
end, function(source, args, user)
	TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficienct permissions!")
end)

function stringsplit(self, delimiter)
  local a = self:Split(delimiter)
  local t = {}

  for i = 0, #a - 1 do
     table.insert(t, a[i])
  end

  return t
end

Run as a query in your DataBase

CREATE TABLE `bans` (
	`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`banned` VARCHAR(50) NOT NULL DEFAULT '0',
	`banner` VARCHAR(50) NOT NULL,
	`reason` VARCHAR(150) NOT NULL DEFAULT '0',
	`expires` DATETIME NOT NULL,
	`timestamp` DATETIME NOT NULL,
	PRIMARY KEY (`id`) USING BTREE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
ROW_FORMAT=DYNAMIC
AUTO_INCREMENT=121
;

This sometimes failes thou, So if anybody could correct that, it would be amazing!

What do you type in the chat to add a ban ?

what does Run as a query in your DataBase mean. could you join discord and assist. discord.gg/2DUvfgS

This ban system works with the command “/ban ID SECS”

It logs the ban into the database.

Do note this is used with mySQL not CouchDB

Hey man, it works where i ban i actuall get kicked with a message so the ban command works, it just does not go to my database and i would really like your help as if i can do this my server would be complete

in your ES_Admin is your password etc set correctly

yes as my users save. each time someone joins it ads their steam id to user tab in my database so that is connecting

actually where do i input my password in es_admin?

at the top of sv_admin

where

not sure what you mean

do it like this

local permission = {
	kick = 1,
    normal = 0,
	ban = 4
}

-- Loading MySQL Class
require "resources/essentialmode/lib/MySQL"

-- MySQL:open("IP", "databasname", "user", "password")
MySQL:open("127.0.0.1", "gta5_gamemode_essential", "root", "1202")

what exactly do i edit, just the top line or both

copy and paste mine instead :slight_smile:and change the database credentials to your settings

Dude thanks, this worked perfectly.

can you help me with one last thing, when i do /ban 1 60 instead of saying youve been banned for 60 seconds the message says 142342342 secs. Says same number every time but in db it is only one min. Just i dont like the message saying that.

Then do /ban ID REASON