Page cover

👤Ox_lib

Use ox_lib caching system

BAD
local health = GetEntityHealth(PlayerPedId())
if IsPedInAnyVehicle(PlayerPedId()) then
    local vehicle = GetVehiclePedIsIn(PlayerPedId())
    local coords = GetEntityCoords(vehicle)
end
GOOD
local health = GetEntityHealth(cache.ped)
if cache.vehicle then
    local coords = GetEntityCoords(cache.vehicle)
end

Use ox_lib points

BAD
CreateThread(function ()
    while true do
        local playerPed = PlayerPedId()
        local coords = GetEntityCoords(playerPed)
        local distance = #(coords - vec3(0, 0, 0))
        if distance <= 3.0 then
            -- foobar
        end
    end
end)
GOOD
CreateThread(function ()
    lib.points.new({
        coords = vec3(0,0,0),
        distance = 3.0,
        nearby = function (self)
        end,
        onEnter = function (self)
        end,
        onExit = function(self)
        end
    })
end)

Use ox_lib callbacks

Replace natives or other things f.ex model requesting with ox_lib functions

For basic dialogs (confirmation, input or menus) use ox_lib menus, not esx menu default or stuff like that.

Use ox_lib locale system

Last updated