> For the complete documentation index, see [llms.txt](https://gabjeksuper.gitbook.io/fiveguard-configuration/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gabjeksuper.gitbook.io/fiveguard-configuration/block-expolits/block-crash-methods/before-reading/new-crash-method.md).

# New Crash Method

Add this function to prevent one of the latest crash method&#x20;

```
local _playerPos  = {}
local _crasher    = {}
local _lastPrint  = {}

local WAIT_TIME = 250
local CRASH_TIME = 15000

CreateThread(function()
    while true do
        local now = GetGameTimer()
        local players = GetPlayers()

        for i = 1, #players do
            local srcId = tonumber(players[i])
            local ped = GetPlayerPed(srcId)

            if ped ~= 0 and DoesEntityExist(ped) then
                local coords = GetEntityCoords(ped)
                _playerPos[srcId] = coords

                local taskType = GetPedSpecificTaskType(ped, 0)
                if taskType == 56 then
                    local _, weaponHash = GetCurrentPedWeapon(ped, true)

                    if weaponHash == -1569615261 then
                        _crasher[srcId] = {
                            t = now,
                            coord = coords,
                        }
                    end
                end
            else
                _playerPos[srcId] = nil
            end
        end

        Wait(WAIT_TIME)
    end
end)

AddEventHandler("playerDropped", function(reason)
    local srcId = source
    local victimCoords = _playerPos[srcId]

    local isCrash = reason and (
        reason:find("east%-november%-coffee", 1, false) or
        reason:find("1048F4A", 1, true) or
        reason:find("Exiting because of a fault", 1, true)
    )

    if not isCrash or not victimCoords then
        _playerPos[srcId] = nil
        _crasher[srcId]   = nil
        return
    end

    local now = GetGameTimer()
    local bestId, bestDist, bestCoord = nil, math.huge, nil

    for hackId, info in pairs(_crasher) do
        if hackId ~= srcId then
            local playerCoord = _playerPos[hackId]

            if playerCoord and (now - info.t) < CRASH_TIME then
                local dist = #(victimCoords - playerCoord)

                if dist < bestDist then
                    bestDist = dist
                    bestId = hackId
                    bestCoord = playerCoord
                end
            else
                _crasher[hackId] = nil
            end
        end
    end

    if bestId then
        if not _lastPrint[bestId] or (now - _lastPrint[bestId]) > 3000 then
            _lastPrint[bestId] = now

            -- ban here : source : bestId
        end
    end

    _playerPos[srcId] = nil
    _crasher[srcId]   = nil
end)
```
