0% found this document useful (0 votes)
30 views2 pages

Message

The document outlines a Lua script for an anti-cheat system in a gaming environment. It includes functions to enumerate and check vehicles, deleting unauthorized ones and kicking or banning players if they spawn vehicles with disallowed scripts. Additionally, it handles resource stop events to ensure players are kicked if the resource is stopped.

Uploaded by

sbanhelojr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Message

The document outlines a Lua script for an anti-cheat system in a gaming environment. It includes functions to enumerate and check vehicles, deleting unauthorized ones and kicking or banning players if they spawn vehicles with disallowed scripts. Additionally, it handles resource stop events to ensure players are kicked if the resource is stopped.

Uploaded by

sbanhelojr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

```RegisterNetEvent('Lunar_Anticheat:StartCheck')

AddEventHandler('Lunar_Anticheat:StartCheck', function()
local entityEnumerator = {
__gc = function(enum)
if enum.destructor and enum.handle then
enum.destructor(enum.handle)
end
enum.destructor = nil
enum.handle = nil
end
}

local function EnumerateEntities(initFunc, moveFunc, disposeFunc)


return coroutine.wrap(function()
local iter, id = initFunc()
if not id or id == 0 then
disposeFunc(iter)
return
end

local enum = {handle = iter, destructor = disposeFunc}


setmetatable(enum, entityEnumerator)

local next = true


repeat
coroutine.yield(id)
next, id = moveFunc(iter)
until not next

enum.destructor, enum.handle = nil, nil


disposeFunc(iter)
end)
end

function EnumerateVehicles()
return EnumerateEntities(FindFirstVehicle, FindNextVehicle, EndFindVehicle)
end

function table.contains(tbl, elem)


for _, value in pairs(tbl) do
if value == elem then
return true
end
end
return false
end

local function CheckVehicles()


for vehicle in EnumerateVehicles() do
local script = GetEntityScript(vehicle)

if script and not table.contains(Config.vehicle.allowedScript, script) then


DeleteEntity(vehicle)
TriggerServerEvent('Lunar_Anticheat:KickPlayer')
TriggerServerEvent('Lunar_Anticheat:BanPlayer', 'Spawn de vehiculos')

Wait(3000)

print('coche eliminado')
end
end
end

-- Ejecuta la función de chequeo de vehículos


CheckVehicles()
end)

AddEventHandler('onResourceStop', function(resourceName)
if GetCurrentResourceName() == resourceName then
TriggerServerEvent('Lunar_Anticheat:KickPlayer')

end
end)
```

You might also like