🤢 K_Diseases | Diseases/Illnesses/Sick/Medicine

Please contact me via DM on here or on the discord :slight_smile:

Mine does not work wish i knew i had to be a Dev to run this script

please help

Here’s a client side script that detects if you’re near an npc which help jumpstart diseases. Just replace the export to the disease you want players to get when around an npc and adjust radius to your liking.

local isNearbyPed = false 

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(2000) -- Adjust the interval when to check if player is near npc
        
        local playerPed = PlayerPedId()
        local playerCoords = GetEntityCoords(playerPed)
        
        local nearbyPeds = GetNearbyPeds(playerCoords, 2.0) -- Adjust the radius to your liking
        
        for _, ped in ipairs(nearbyPeds) do
            if ped ~= playerPed then
                isNearbyPed = true
	           
                   exports['k_diseases']:CatchDisease("Covid", 1, true) --- Insert disease export here

                break 
            else
                isNearbyPed = false
            end
        end
    end
end)

function GetNearbyPeds(coords, radius)
    local nearbyPeds = {}
    local handle, ped = FindFirstPed()
    local success

    repeat
        local pos = GetEntityCoords(ped)
        local distance = #(coords - pos)
        if distance <= radius then
            table.insert(nearbyPeds, ped)
        end
        success, ped = FindNextPed(handle)
    until not success

    EndFindPed(handle)
    return nearbyPeds
end
1 Like