function CheckOwnership()
Citizen.CreateThread(function()
while true do
for i = 1, #almez, 1 do
for x = 1, #almez[i].doors, 1 do
local ped = PlayerPedId()
local playercoords = GetEntityCoords(ped)
local dst = GetDistanceBetweenCoords(playercoords, almez[i].info.coords, 0)
if dst <= 35.5 then
if almez[i].doors[x].obj == nil or not DoesEntityExist(almez[i].doors[x].obj) then
almez[i].doors[x].obj = GetClosestObjectOfType(almez[i].doors[x].coords, 1.2, almez[i].doors[x].doorhash, 0, 0, 0)
FreezeEntityPosition(almez[i].doors[x].obj, almez[i].doors[x].locked)
else
FreezeEntityPosition(almez[i].doors[x].obj, almez[i].doors[x].locked)
if almez[i].doors[x].locked then
SetEntityHeading(almez[i].doors[x].obj, almez[i].doors[x].h)
end
end
end
end
end
Citizen.Wait(1000)
end
end)
end