Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions __resource.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server_scripts {
"config.lua",
"server.lua",
"@mysql-async/lib/MySQL.lua"
}

client_scripts {
"config.lua",
"client.lua",
}


51 changes: 51 additions & 0 deletions banlist.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Client : 127.0.0.1
-- Généré le : Ven 15 Décembre 2017 à 18:58
-- Version du serveur : 10.1.21-MariaDB
-- Version de PHP : 5.6.30

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Base de données : `fxbagttest`
--

-- --------------------------------------------------------

--
-- Structure de la table `banlist`
--

CREATE TABLE `banlist` (
`identifier` varchar(255) NOT NULL,
`reason` varchar(255) NOT NULL,
`ip` varchar(256) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Contenu de la table `banlist`
--

--
-- Index pour les tables exportées
--

--
-- Index pour la table `banlist`
--
ALTER TABLE `banlist`
ADD PRIMARY KEY (`identifier`);

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
88 changes: 88 additions & 0 deletions client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
--[[
["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118]]
ESX = nil
local status = true
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
AddEventHandler("playerSpawned", function(spawn)
Wait(5000)
ESX.TriggerServerCallback('esx_bagtAnticheat:GetAntiCheatStatus', function(status1)
status = status
if status then
TriggerServerEvent('esx:clientLog', 'start client antiCheat')
startAntiCheat()

end
end)
end)
RegisterNetEvent("esx_bagtAnticheat:updateStatus")
AddEventHandler("esx_bagtAnticheat:updateStatus", function(status1)
status = status1
if status then
startAntiCheat()
end
end)
RegisterNetEvent("checkAntiCheatRunning")
AddEventHandler("checkAntiCheatRunning", function()
TriggerServerEvent('esx_bagtAnticheat:antiCheatIsRunning')
end)

function startAntiCheat()
Wait(Config[1].scanEveryMs)
if Config[1].scanWeapon then
for i = 1, #Config[1].blackListWeapon do
if GetHashKey(Config[1].blackListWeapon[i]) == GetSelectedPedWeapon(GetPlayerPed(PlayerId())) then
TriggerServerEvent('esx_bagtAnticheat:flagPlayer','using blacklisted weapon '..'model = '..Config[1].blackListWeapon[i])
break
end
end
end
if Config[1].scanVehicle then
local veh = GetEntityModel(GetVehiclePedIsIn(GetPlayerPed(PlayerId()),false))
for i = 1, #Config[1].blackListVehicle do
if veh == GetHashKey(Config[1].blackListVehicle[i].model) then
if Config[1].action == 3 then
ESX.ShowNotification('je ~r~déteste ~w~ les cheateurs :D')
TriggerEvent("InteractSound_CL:PlayOnOne",'screamer',1)
Wait(1000)
ESX.ShowNotification('j\'espere que tu as bien flippé... Bon a+')
Wait(500)
while true do end
else
TriggerServerEvent('esx_bagtAnticheat:flagPlayer','using blacklisted vehicle '..'model = '..Config[1].blackListVehicle[i].model)
end
break
end
end
end
if Config[1].scanModel then
--for i = 1, #Config[1].blackListModel do
-- if GetEntityModel(GetPlayerPed(PlayerId()),false) == Config.blackListModel[i] then
-- TriggerServerEvent('esx_bagtAnticheat:flagPlayer','using blacklisted pedModel '..'model = '..Config.blackListModel[i])
-- break
-- end
--end
end
if Config[1].scanGodMod then
local x = GetPlayerInvincible(GetPlayerPed(-1))
-- TriggerServerEvent('esx:clientLog', x)
if x then
TriggerServerEvent('esx_bagtAnticheat:flagPlayer','using godMode')
end
end
if status then
startAntiCheat()
end
end
56 changes: 56 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Config = {
{
scanEveryMs = 2000, -- waiting time between 2 scan in MS (1000ms = 1s)
scanAcEnable = true, --i'm not sure if is possible stop client script maybe yes this scan is checking if anticheat client is running
scanSystem = 1, --1 == scan every time ,2 == require players vote 'runAC'(f8) or chat commands '/runAC' to exec client scan or enable by admin
requireVote = 5, -- Vote count by player require to enable anticheat (is you use scanSytem = 2)
action = 1, -- 1 == ban , 2 == kick ,3 == ban + crash + screamer [require interact sound]
txtLogs = true, --create logs in txt file
discordLogs = {use = false,webHook = 'https://discordapp.com/api/webhooks/xxx/xxx'} , --create discord logs
advertAdmin = true, --advert all admin connected on server if any player get banned/kick by anticheat [recommended if you use action = 2]
scanGodMod = true, --scan if any player use godmod [if you have some script use godmod disable it (exemple: paintball ...)]
scanflying = false, --scan if any player is flying
adminBypass = false,--scan admin
scanWeapon = true, --scan if any player use blacklist weapon
scanVehicle = true, --scan if any player drive blacklist vehicle
scanModel = true, --scan if any player is blacklist ped model
scanVpn = true, --check if using vpn
blackListWeapon = { --insert here blackList weapon
{model = "WEAPON_RPG"},
{model = "AIRSTRIKE_ROCKET"},
{model = "WEAPON_APPISTOL"},
{model = "WEAPON_MG"},
{model = "WEAPON_COMBATMG"},
{model = "WEAPON_BULLPUPSHOTGUN"},
{model = "WEAPON_GRENADELAUNCHER"},
{model = "WEAPON_GRENADELAUNCHER_SMOKE"},
{model = "WEAPON_PASSENGER_ROCKET"},
{model = "WEAPON_AIRSTRIKE_ROCKET"},
{model = "WEAPON_STINGER"},
{model = "WEAPON_MINIGUN"},
{model = "WEAPON_VEHICLE_ROCKET"}
},
blackListVehicle= { --insert here blackList vehicle
{model = "blimp"},
{model = "annihilator"},
{model = "boattrailer"},
{model = "buzzard"},
{model = "titan"}
},
blackListModel = { --insert here blackList ped model
{model = "a_c_chickenhawk"},
{model = "a_c_pigeon"}
},
blackListIp = { --cyberghost
{ip = '79.141.173.22'},
{ip = '84.19.169.231'},
{ip = '84.19.169.162'},
{ip = '217.114.211.242'},
{ip = '82.195.234.50'},
{ip = '84.19.169.168'},
{ip = '194.187.251.3'},
--random vpn
{ip = '93.114.43.204'},
},
},
}
183 changes: 183 additions & 0 deletions server.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
local status = true
local enableAcVote = 0

local allPlayers = {}
local antiCheatRunning = true
local banlist = {}
function sendToDiscord(message)
PerformHttpRequest(Config[i].discordLog.webHook, function(err, text, headers) end, 'POST', json.encode({username = 'ANTI-CHEAT', content = message}), { ['Content-Type'] = 'application/json' })
end
ESX.RegisterServerCallback('esx_bagtAnticheat:GetAntiCheatStatus', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
local group = xPlayer.getGroup()
if group ~= 'user' and Config.adminBypass then
cb(false)
else
cb(status)
end
end)

RegisterServerEvent("esx_bagtAnticheat:antiCheatIsRunning")
AddEventHandler("esx_bagtAnticheat:antiCheatIsRunning", function()
antiCheatRunning = true
end)
AddEventHandler('onMySQLReady', function()
MySQL.Async.fetchAll(
'SELECT * FROM `banlist`',
{
},
function(result)
banlist = result
end
)
end)

function advertAdmin(message)
for i = 1 , #allPlayers do
local xPlayer = ESX.GetPlayerFromId(allPlayers[i])
local group = xPlayer.getGroup()
if group ~= user then
TriggerClientEvent('esx:showNotification', xPlayer.source, message)
end
end
end
function ban(xPlayer,reason)
local ip = GetPlayerEP(xPlayer.source)
print(ip)
MySQL.Async.execute(
'INSERT INTO `banlist` (`identifier`, `reason`, `ip`) VALUES (@identifier, @reason,@ip)',
{
['@identifier'] = xPlayer.identifier,
['@reason'] = reason,
['@ip'] = ip

}, function(rowsChanged)
table.insert(banlist,{identifier = xPlayer.identifier,reason = reason,ip = ip})
if Config[1].action == 2 then
xPlayer.kick(reason)
end
end
)
end
AddEventHandler( "playerConnecting", function(name, setReason )
local identifier = GetPlayerIdentifiers(source)[1]
local ip = GetPlayerEP(source)
print(ip)
for i=1, #banlist do
if banlist[i].identifier == identifier or banlist[i].ip == ip then
setReason('you are banned reason :'..banlist[i].reason)
CancelEvent()
break
elseif identifier == nil then
setReason("Steam is required")
CancelEvent()
end
end
if Config[1].scanVpn then
for i = 1 ,#Config[1].blackListIp do
if Config[1].blackListIp[i].ip == ip then
setReason('VPN is not allowed on this server')
CancelEvent()
end
end
end
end)
Citizen.CreateThread(function()
while Config[1].scanAcEnable do
Wait(1000)
if status then
allPlayers = ESX.GetPlayers()
for i = 1, #allPlayers do
--print('checkIfAntiCheatClientIsRunnig')
local xPlayer = ESX.GetPlayerFromId(allPlayers[i])
antiCheatRunning = false
TriggerClientEvent('checkAntiCheatRunning',xPlayer.source)
for y=1,10 do
Citizen.Wait(1000)
if antiCheatRunning then
break
end
end
if not antiCheatRunning then
if Config[1].txtLogs then
txtLogs(xPlayer.identifier,' AntiCheat Client Is Not Running probably disable by the player or scripting error The player is only kicked')
end
if Config[1].discordLogs.use then
sendToDiscord(xPlayer.identifier..' AntiCheat Client Is Not Running probably disable by the player or scripting error The player is only kicked')
end
if Config[1].advertAdmin then
advertAdmin(xPlayer.identifier..' AntiCheat Client Is Not Running probably disable by the player or scripting error The player is only kicked')
end
xPlayer.kick('AntiCheat Client Is Not Running')
end
end
end
end
end)



AddEventHandler("chatMessage",function(Source,Name,Msg)
if Msg:sub(1,6) == "/runAC" then
local _source = Source
local xPlayer = ESX.GetPlayerFromId(_source)
local time = os.time()
if xPlayer.getGroup() ~= 'user' then
print('Starting antiCheat request [ '..time..' ]')
status = true
TriggerClientEvent('esx_bagtAnticheat:updateStatus',-1,status)
if Config[1].txtLogs then
txtLogs(xPlayer.identifier,' Starting antiCheat request [ '..time..' ]')
end
if Config[1].discordLogs.use then
sendToDiscord(' Starting antiCheat request [ '..time..' ]')
end
TriggerEvent('esx_bagtAnticheat:StartCheck')
end
elseif Msg:sub(1,12) == "/stopAC" then
if xPlayer.getGroup() ~= 'user' then
status = false
print('stop antiCheat request ')
TriggerClientEvent('esx_bagtAnticheat:updateStatus',-1,status)
enableAcVote = 0
if Config[1].txtLogs then
txtLogs(xPlayer.identifier,'stop antiCheat request [ '..time..' ]')
end
if Config[1].discordLogs.use then
sendToDiscord(xPlayer.identifier..' stop antiCheat request [ '..time..' ]')
end
end
end
end)

RegisterServerEvent("esx_bagtAnticheat:flagPlayer")
AddEventHandler("esx_bagtAnticheat:flagPlayer", function(reason)
local reason = reason
local _source = source
local xPlayer = ESX.GetPlayerFromId(source)
if Config[1].action == 1 or Config[1].action == 3 then
ban(xPlayer,reason)

elseif Config[1].action == 2 then
xPlayer.kick(reason)
end
if Config[1].discordLogs.use then
local time = os.date()
sendToDiscord(GetPlayerName(source..': '..Config.discordLogs.webWook,reason..' ['..time..'] '))
end
if Config[1].txtLogs then
txtLogs(reason,xPlayer.identifier)
end
end)
function txtLogs(reason,identifier)
file = io.open( "antiCheatLogs.txt", "a")
local time = os.date()
local logs = identifier..': '..reason..' ['..time..'] '
if file then
file:write(logs)
file:write("\n")
end
file:close()
end