Opinionated utilities for FiveM development environment.
Note: This script is under development and not fully functional, star and watch the repo for updates.
Download Link
Makes a resource depend on another server-only resource without breaking client loading.
Example fxmanifest.lua:
- api_resource
server_only 'yes'- logic_resource
server_dependency 'api_resource'The require function that is used in this section is defined in ox_lib.
If you don't want to use it then load the target file manually in your resource fxmanifest.lua.
require '@utils.imports.promise'local function operation(p1, callback, p2)
--- ...
callback(true, 123, 'text')
end
local results = promise:new()
operation('whatever', results:resolveCallback(), 'whatever2')
local bool, int, str = results:awaitCallback()
print(bool, int, str) --- true 123 textrequire '@utils.imports.exports'provideExport('resource', 'method', function(...)
-- ...
end)require '@utils.imports.convar'local debugging = GetConvarBoolean('resource:debug', false)require '@utils.imports.network'RegisterNetEvent('TurnOffVehicleRadio', function(vehicleNetId)
local attempts, attemptDelay = 2, 5000
local vehicle = WaitEntityWithNetworkIdToExistLocally(vehicleNetId, attempts, attemptDelay)
if not vehicle then
TriggerEvent('WaitedForVehicleToLoadForTooLong', vehicleNetId)
return
end
NetworkWaitUntilHaveControlOfNetworkId(vehicleNetId)
SetVehRadioStation(vehicle, "OFF")
end)require '@utils.imports.patterns'require '@utils.imports.colors'local color = Color('#4287f5', 0.39)
print('opacity:', color.opacity) -- 0.39
print('decimal:', color.decimal) -- 4360181
print('hex:', color.hex) -- #4287f5
local rgb = color.rgb
print('rgb:', rgb.r, rgb.b, rgb.g) -- 66 245 135
local rgba = color.rgba
print('rgba:', rgba.r, rgba.b, rgba.g, rgba.a) -- 66 245 135 100local color = Color('rgba(252, 3, 182, 51)')
print('opacity:', color.opacity) -- 0.2
print('decimal:', color.decimal) -- 16516022
print('hex:', color.hex) -- #fc03b6
local rgb = color.rgb
print('rgb:', rgb.r, rgb.b, rgb.g) -- 252 182 3
local rgba = color.rgba
print('rgba:', rgba.r, rgba.b, rgba.g, rgba.a) -- 252 182 3 51Install Sumneko Lua Language Server on Visual Studio Code.