56 lines
1.9 KiB
Lua
56 lines
1.9 KiB
Lua
local QBCore = exports['qb-core']:GetCoreObject()
|
|
|
|
-- Get permissions --
|
|
|
|
QBCore.Functions.CreateCallback('qb-anticheat:server:GetPermissions', function(source, cb)
|
|
local group = QBCore.Functions.GetPermission(source)
|
|
cb(group)
|
|
end)
|
|
|
|
-- Execute ban --
|
|
|
|
RegisterNetEvent('qb-anticheat:server:banPlayer', function(reason)
|
|
local src = source
|
|
TriggerEvent("qb-log:server:CreateLog", "anticheat", "Anti-Cheat", "white", "You were banned "..reason, false)
|
|
MySQL.Async.insert('INSERT INTO bans (name, license, discord, ip, reason, expire, bannedby) VALUES (?, ?, ?, ?, ?, ?, ?)', {
|
|
GetPlayerName(src),
|
|
QBCore.Functions.GetIdentifier(src, 'license'),
|
|
QBCore.Functions.GetIdentifier(src, 'discord'),
|
|
QBCore.Functions.GetIdentifier(src, 'ip'),
|
|
reason,
|
|
2145913200,
|
|
'Anti-Cheat'
|
|
})
|
|
DropPlayer(src, "You have been banned for cheating. Check our Discord for more information: " .. QBCore.Config.Server.discord)
|
|
end)
|
|
|
|
-- Fake events --
|
|
function NonRegisteredEventCalled(CalledEvent, source)
|
|
TriggerClientEvent("qb-anticheat:client:NonRegisteredEventCalled", source, "Cheating", CalledEvent)
|
|
end
|
|
|
|
for x, v in pairs(Config.BlacklistedEvents) do
|
|
RegisterServerEvent(v)
|
|
AddEventHandler(v, function(source)
|
|
NonRegisteredEventCalled(v, source)
|
|
end)
|
|
end
|
|
|
|
-- RegisterServerEvent('banking:withdraw')
|
|
-- AddEventHandler('banking:withdraw', function(source)
|
|
-- NonRegisteredEventCalled('bank:withdraw', source)
|
|
-- end)
|
|
|
|
QBCore.Functions.CreateCallback('qb-anticheat:server:HasWeaponInInventory', function(source, cb, WeaponInfo)
|
|
local src = source
|
|
local Player = QBCore.Functions.GetPlayer(src)
|
|
local PlayerInventory = Player.PlayerData.items
|
|
local retval = false
|
|
|
|
for k, v in pairs(PlayerInventory) do
|
|
if v.name == WeaponInfo["name"] then
|
|
retval = true
|
|
end
|
|
end
|
|
cb(retval)
|
|
end) |