This README provides instructions on how to use the object_gizmo
module in the FiveM framework using Lua. This module exports a useGizmo
function that enables manipulation of entity position and rotation through a NUI frame.
- Download the
object_gizmo
resource. - Extract the
object_gizmo
folder into your server'sresources
directory. - Add
start object_gizmo
to your server'sserver.cfg
file.
After installation, you can use the useGizmo
function in your scripts: exports['object_gizmo']:useGizmo(handle)
exports("useGizmo", useGizmo)
handle
: The entity to be manipulated.
This function opens a NUI frame and allows for the manipulation of the entity's position and rotation. It returns an object with the entity's handle, final position, and final rotation.
Ensure the object_gizmo
module script is running on your server.
The useGizmo
function can be used in any Lua script on the server or client side as follows:
local handle = --[[@ Your target entity handle]]
local result = exports['object_gizmo']:useGizmo(handle)
result
will contain the entity handle, final position, and final rotation.
This module includes a test command spawnobject
that demonstrates how to use the gizmo. You can use this command in-game by typing /spawnobject {object model name}
in the console. If no object model name is provided, prop_bench_01a
is used by default.
The command creates an object at the player's location and then activates the gizmo for that object.
RegisterCommand('spawnobject',function(source, args, rawCommand)
local objectName = args[1] or "prop_bench_01a"
local playerPed = PlayerPedId()
local offset = GetOffsetFromEntityInWorldCoords(playerPed, 0, 1.0, 0)
local model = joaat(objectName)
lib.requestModel(model, 5000)
local object = CreateObject(model, offset.x, offset.y, offset.z, true, false, false)
local objectPositionData = exports.object_gizmo:useGizmo(object)
print(json.encode(objectPositionData, { indent = true }))
end)
While using the gizmo, the following controls apply:
- [W]: Switch to Translate Mode
- [R]: Switch to Rotate Mode
- [LAlt]: Place on Ground
- [Esc]: Finish Editing
The current mode (Translate/Rotate) will be displayed on the screen.
The gizmo only works on entities that you have sufficient permissions to manipulate. Make sure you have the correct permissions to move or rotate the entity you are working with.