Skip to content

Instantly share code, notes, and snippets.

View Rubylium's full-sized avatar
:atom:
Working

Rubylium Rubylium

:atom:
Working
View GitHub Profile
JSON_BUILDER = {}
JSON_BUILDER.BasePath = "./server/generated/"
JSON_BUILDER.PathCache = {}
function JSON_BUILDER.LoadFile(name)
local data = {}
local loadFile = LoadResourceFile(GetCurrentResourceName(), JSON_BUILDER.BasePath..name)
if loadFile ~= nil then
data = json.decode(loadFile)
else
@Rubylium
Rubylium / entity.lua
Created February 18, 2021 17:10
FiveM entity selection using NUI mouse
-- usage: local hit, endCoords, surfaceNormal, entityHit, entityType, direction = ScreenToWorld(flags, toIgnore)
function ScreenToWorld(flags, toIgnore)
local camRot = GetGameplayCamRot(0)
local camPos = GetGameplayCamCoord()
local posX = GetControlNormal(0, 239)
local posY = GetControlNormal(0, 240)
local cursor = vector2(posX, posY)
local cam3DPos, forwardDir = ScreenRelToWorld(camPos, camRot, cursor)
local direction = camPos + forwardDir * raycastLength