If I put this script on the server, I get stuck here and fivem stops responding


Client:
ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(10)
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
if IsControlJustPressed(1, 121) then
TriggerServerEvent("lua:kick")
end
end
end)
Server:
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
RegisterServerEvent("lua:kick")
AddEventHandler("lua:kick", function()
local xPlayer = ESX.GetPlayerFromId(source)
print(('Console message):format(xPlayer.identifier))
DropPlayer(source, "Kick message")
end)
Try this
I can join on my Server now, but if i press INSERT, it wont kick me from the server.
replace “insert” in your code with “121”
So it should look like this:
if IsControlJustPressed(1, 121) then
TriggerServerEvent(‘antidev:kick’)
end
Making an “anti cheat” this way, for lack of better words is stupid but, to each his own.
Typed this on mobile so might have to edit yourself
Citizen.CreateThread(function()
while true do
local active = NetworkIsSessionActive()
if active == 1 or active == true and IsControlJustPressed(1, 121) then
TriggerServerEvent(‘antidev:kick’)
end
end
Citizen.Wait(1)
end
end)
Your game would crash because you are running that code without a break, hence the addition of the Citizen.Wait(1)
You do realize this is not at all an anticheat method, don’t you?
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.