Ok, so a week or so ago i posted on here about a problem i had with my interaction flicking on the side.
Well people suggested i should make it like this:
When in distance
if not intShown then
intShown = true
TriggerEvent("okokTextUI:Open", "[E] "..displayText, closestColor, "left")
end
When outside of distance
if intShown then
intShown = false
TriggerEvent("okokTextUI:Close")
end
But it is still flickering.
My full code for the doorlocks (relvevant part):
Citizen.CreateThread(function()
local intShown = false
while true do
local isLocked = false
local doorDistance = 1000
local closestColor = "None"
Citizen.Wait(5)
local playerCoords, awayFromDoors = GetEntityCoords(PlayerPedId()), true
for i = 1, #PS.Doors do
local current = PS.Doors[i]
isLocked = current.locked
doorDistance = #(current.objCoords - playerCoords)
local distance
distance = #(playerCoords - current.objCoords)
if current.distance then
maxDistance = current.distance
end
if distance < 10 then
awayFromDoors = false
if current.doors then
for a = 1, #current.doors do
local currentDoor = current.doors[a]
FreezeEntityPosition(currentDoor.object, current.locked)
if current.locked and currentDoor.objYaw and GetEntityRotation(currentDoor.object).z ~= currentDoor.objYaw then
SetEntityRotation(currentDoor.object, 0.0, 0.0, currentDoor.objYaw, 2, true)
end
end
else
FreezeEntityPosition(current.object, current.locked)
if current.locked and current.objYaw and GetEntityRotation(current.object).z ~= current.objYaw then
SetEntityRotation(current.object, 0.0, 0.0, current.objYaw, 2, true)
end
end
end
if distance <= 1.0 then
awayFromDoors = false
if current.size then
size = current.size
end
if current.locked then
displayText = "Locked"
closestColor = "darkred"
elseif not current.locked then
displayText = "Unlocked"
closestColor = "darkgreen"
end
if not intShown then
intShown = true
TriggerEvent("okokTextUI:Open", "[E] "..displayText, closestColor, "left")
end
if current.objCoords == nil then
current.objCoords = current.textCoords
end
if IsControlJustReleased(0, 38) then
setDoorLocking(current, i)
end
elseif distance > 1.0 then
if intShown then
intShown = false
TriggerEvent("okokTextUI:Close")
end
end
end
if awayFromDoors then
Citizen.Wait(1000)
end
end
end)
What i’ve already tried:
Adding distance check and elseif’s inside the current if statement checking distance. Didn’t work.
Any help would be appreciated!