# lvs-gizmo

### Gizmo

`exports.lvs_gizmo:useGizmo()` opens an interactive gizmo UI for editing an entity's position and rotation.

#### Parameters

* `entityData` (table|string|number):
  * If string/number: treated as entity handle
  * If table: should contain at least `handle` (entity handle), optionally:
    * `label` (string): display name for the entity (defaults to 'Unknown')
    * `hash` (number): model hash (defaults to GetEntityModel(handle))
    * `model` (string): model name (defaults to 'Unknown')
    * `image` (any): optional image data for UI

#### Returns

* `boolean|table`:
  * `false` if gizmo cannot be opened (NUI already focused) or entity is invalid
  * On success, returns a table with:
    * `placed` (boolean): true if edit was confirmed and object placed, false if cancelled
    * `position` (vector3): final position coordinates (only when placed=true)
    * `rotation` (vector3): final rotation coordinates (only when placed=true)
    * `initialCords` (table): contains initial position and rotation: -> `position` (vector3): initial position before edit -> `rotation` (vector3): initial rotation before edit

#### Usage Example

```lua
local model = 'prop_mp_cone_02'
local obj = CreateObject(model, pos.x, pos.y, pos.z, false, false, false)
local result = exports.lvs_gizmo:useGizmo({
    handle = obj,
    label = 'Cone',
    hash = GetEntityModel(obj),
    model = model,
})

if result then
    if result.placed then
        print("Object placed at:", result.position)
        print("Initial position was:", result.initialCords.position)
    else
        print("Edit cancelled")
    end
end
```

#### Behavior

1. Prevents multiple simultaneous gizmo sessions (returns false if NUI already focused)
2. Validates entity existence before proceeding
3. Captures initial entity state (position, rotation)
4. Opens NUI gizmo interface for interactive editing
5. Blocks most player controls during gizmo operation (except camera when right-click held)
6. Synchronizes game camera with UI during operation
7. On completion:
   * If confirmed ("placed"): returns updated position/rotation plus initial values
   * If cancelled: returns false for placed flag but still provides initial values for restoration
   * Always clears NUI focus and resets gizmo entity reference


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fivem.lvsoft.com.ar/qb-esx/lvs-gizmo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
