GithubHelp home page GithubHelp logo

tienthanh2929 / object_gizmo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from demigod916/object_gizmo

0.0 0.0 0.0 880 KB

License: GNU General Public License v3.0

Lua 31.40% TypeScript 64.38% CSS 0.31% HTML 3.91%

object_gizmo's Introduction

Object Gizmo Module - object_gizmo

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.

Installation

  1. Download the object_gizmo resource.
  2. Extract the object_gizmo folder into your server's resources directory.
  3. Add start object_gizmo to your server's server.cfg file.

After installation, you can use the useGizmo function in your scripts: exports['object_gizmo']:useGizmo(handle)

Export

exports("useGizmo", useGizmo)

Functions

useGizmo(handle)

  • 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.

Usage

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.

Test Command

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)

Controls

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.

Note

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.

object_gizmo's People

Contributors

demigod916 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.