Citizen.CreateThread(function()
Citizen.Wait(100)
while true do
local sleep = 1000
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
for i = 1, #closestBin do
local x = GetClosestObjectOfType(playerCoords, 1.0, GetHashKey(closestBin[i]), false, false, false)
local entity = nil
if DoesEntityExist(x) then
sleep = 5
entity = x
bin = GetEntityCoords(entity)
drawText3D(bin.x, bin.y, bin.z + 1.5, 'Tryck [~g~E~s~] för att söka ~b~soptunnan~s~')
if IsControlJustReleased(0, 38) then
if not IsPedSittingInAnyVehicle(playerPed) then
if not cachedBins[entity] then
openBin(entity)
else
sendNotification('You already searched here!', 'error', 2000)
end
else
sendNotification('You can't do this in a vehicle!', 'error', 2000)
end
end
break
else
sleep = 1000
end
end
Citizen.Wait(sleep)
end
end)
ESX = nil
percent = false
searching = false
cachedBins = {}
bins = {
'prop_dumpster_01a',
'prop_dumpster_02a',
'prop_dumpster_02b'
}
Citizen.CreateThread(function()
while ESX == nil do
Citizen.Wait(5)
TriggerEvent("esx:getSharedObject", function(library)
ESX = library
end)
end
end)
Citizen.CreateThread(function()
local playerPed = PlayerPedId()
while true do
Citizen.Wait(0)
if not IsPedSittingInAnyVehicle(playerPed) then
if searching then
DisableControlAction(0, 73)
end
local playerCoords = GetEntityCoords(playerPed)
local bin, distance = ESX.Game.GetClosestObject(bins, playerCoords)
if distance ~= -1 and bin ~= -1 and distance <= 1.0 then
if percent then
binCoords = GetEntityCoords(bin)
drawText3D(binCoords.x, binCoords.y, binCoords.z + 1.5, TimeLeft .. '~g~%~s~')
else
drawText3D(binCoords.x, binCoords.y, binCoords.z + 1.5, 'Tryck [~g~E~s~] för att söka ~b~soptunnan~s~')
end
if IsControlJustReleased(0, 38) then
if not cachedBins[bin] then
openBin(bin)
else
sendNotification('Du har redan letat här!', 'error', 2000)
end
end
end
end
end
end)
Using ESX core functions alternative. I may have broken the countdown display tho. But easy to fix if broken. Actually at work so I can’t test it
SCRIPT ERROR: @es_extended/server/classes/player.lua:323: attempt to index a nil value (local 'item')
> refe[0m (e[36m@es_extended/server/classes/player.lua
> handlere[0m (e[36m@esx_sopletare/server/main.lua
Great job here is me but I would like to ask how can I change the other part to english where you press e on the keyboard or RB on the controller I can’t seem to find where to change that.