From the reference libraryRedM

autodoc_client_functions

jo_libs/modules/entity/autodoc/autodoc_client_functions.md

autodoc_client_functions

JO Functions > jo.entity.create()

Create a new entity at specified location <br>

  • if coords is a vector4, heading is not required <br>

JO Functions > jo.entity.create() > Syntax

jo.entity.create(model, coords, ...)

JO Functions > jo.entity.create() > Parameters

model : string

The model name of the entity to create

coords : vector3|vector4

The coordinates where the entity will be created

heading : number <BadgeOptional />

The heading direction for the entity if coords is vec3

networked : boolean <BadgeOptional />

Whether the entity should be networked <br> default: false

fadeDuration : integer <BadgeOptional />

Duration of the fade-in effect in ms <br> default: 0

JO Functions > jo.entity.create() > Return Value

Type : integer

The created entity ID

JO Functions > jo.entity.create() > Example

local entity = jo.entity.create('re_kidnappedvictim_females_01', vec3(1294.0, -512.3, 30.0), 90.0, true)
print(entity)


JO Functions > jo.entity.createWithMouse()

Create an entity that follows the mouse cursor for placement <br>

JO Functions > jo.entity.createWithMouse() > Syntax

jo.entity.createWithMouse(model, keepEntity, networked, mouse, heading)

JO Functions > jo.entity.createWithMouse() > Parameters

model : string

The model name of the entity to create

keepEntity : boolean <BadgeOptional />

Whether to keep the entity after placement <br> default:true

networked : boolean <BadgeOptional />

Whether the entity should be networked <br> default:false

mouse : vector2 <BadgeOptional />

Mouse coordinates normalized between 0-1 <br> default:vec2(0.5, 0.5)

heading : number <BadgeOptional />

The heading direction for the entity <br> default:0

JO Functions > jo.entity.createWithMouse() > Return Value

Type : integer,vector3,number,boolean

The created entity ID, final position, final heading, is canceled

JO Functions > jo.entity.createWithMouse() > Example

local entityId, position, heading = jo.entity.createWithMouse('p_armchair01x', true, false)
print("Created entity: " .. entityId)
print("Position: " .. tostring(position))
print("Heading: " .. heading)


JO Functions > jo.entity.delete() > Syntax

jo.entity.delete(entity)

JO Functions > jo.entity.delete() > Parameters

entity : integer

The entity ID to delete

JO Functions > jo.entity.delete() > Example

local entity = 23494
jo.entity.delete(entity)


JO Functions > jo.entity.deleteScenariosFromEntity()

Delete all scenarios from an entity <br>

JO Functions > jo.entity.deleteScenariosFromEntity() > Syntax

jo.entity.deleteScenariosFromEntity(entity, size, maxScenario, maxAttempt, waitTime)

JO Functions > jo.entity.deleteScenariosFromEntity() > Parameters

entity : integer

The entity ID to delete scenarios from

size : number <BadgeOptional />

The size of the area to search for scenarios <br> default:2.0

maxScenario : number <BadgeOptional />

The maximum number of scenarios to search for <br> default:8

maxAttempt : number <BadgeOptional />

The maximum number of attempts to delete scenarios <br> default:10

waitTime : number <BadgeOptional />

The time to wait between attempts to delete scenarios <br> default:100

JO Functions > jo.entity.deleteScenariosFromEntity() > Example

local entity = 23494
jo.entity.deleteScenariosFromEntity(entity)


JO Functions > jo.entity.fadeAndDelete()

Fade out an entity and then delete it <br>

JO Functions > jo.entity.fadeAndDelete() > Syntax

jo.entity.fadeAndDelete(entity, duration)

JO Functions > jo.entity.fadeAndDelete() > Parameters

entity : integer

The entity ID to fade and delete

duration : integer <BadgeOptional />

Duration of the fade effect in ms <br> default:1000

JO Functions > jo.entity.fadeAndDelete() > Example

local entity = 32454
local duraiton = 1000
jo.entity.fadeAndDelete(entity, duration)


JO Functions > jo.entity.fadeIn()

Fade in an entity from transparent to fully visible <br>

JO Functions > jo.entity.fadeIn() > Syntax

jo.entity.fadeIn(entity, duration)

JO Functions > jo.entity.fadeIn() > Parameters

entity : integer

The entity ID to fade in

duration : integer <BadgeOptional />

Duration of the fade effect in ms <br> default:1000

JO Functions > jo.entity.fadeIn() > Example

local entity = 12345  -- Assume this is a valid entity ID
local duration = 2000 -- 2 seconds fade in time
jo.entity.fadeIn(entity, duration)


JO Functions > jo.entity.fadeOut()

Fade out an entity from visible to transparent <br>

JO Functions > jo.entity.fadeOut() > Syntax

jo.entity.fadeOut(entity, duration)

JO Functions > jo.entity.fadeOut() > Parameters

entity : integer

The entity ID to fade out

duration : integer <BadgeOptional />

Duration of the fade effect in ms - default:1000

JO Functions > jo.entity.fadeOut() > Example

local entity = 12345  -- Assume this is a valid entity ID
local duration = 2000 -- 2 seconds fade out time
jo.entity.fadeOut(entity, duration)


JO Functions > jo.entity.getEntityInCrosshair()

Raycast from the camera through the screen center and return what was hit <br> Displays a small crosshair sprite at screen center <br> Must be called each frame to render the crosshair <br>

JO Functions > jo.entity.getEntityInCrosshair() > Syntax

jo.entity.getEntityInCrosshair(distance, flags, toIgnore)

JO Functions > jo.entity.getEntityInCrosshair() > Parameters

distance : number <BadgeOptional />

Maximum raycast distance <br> default:100

flags : integer <BadgeOptional />

Flags for the raycast <br> default:16

toIgnore : integer <BadgeOptional />

Entity to ignore in the raycast <br> default:PlayerPedId()

JO Functions > jo.entity.getEntityInCrosshair() > Return Value

Type : boolean,vector3,integer

Hit status, hit coordinates, hit entity

JO Functions > jo.entity.getEntityInCrosshair() > Example

CreateThread(function()
    while true do
        local hit, coords, entityHit = jo.entity.getEntityInCrosshair()
        Wait(0)
    end
end)

JO Functions > jo.entity.requestControl()

<br> <br> Request control of an entity and wait until it's granted <br>

JO Functions > jo.entity.requestControl() > Syntax

jo.entity.requestControl(entity)

JO Functions > jo.entity.requestControl() > Parameters

entity : integer

The entity ID to request control of

JO Functions > jo.entity.requestControl() > Example

local entity = 23494
jo.entity.requestControl(entity)

JO Functions > jo.entity.requestControl()

Request control of an entity and wait until it's granted <br>

Back to documentation