Entity Client
A library with useful functions to manage entity client side
JO Functions
jo.entity.create()
Create a new entity at specified location
- if coords is a vector4, heading is not required
Syntax
jo.entity.create(model, coords, ...)
Parameters
model
: string
The model name of the entity to create
coords
: vector3|vector4
The coordinates where the entity will be created
heading
: number Optional
The heading direction for the entity if coords is vec3
networked
: boolean Optional
Whether the entity should be networked
default:false
fadeDuration
: integer Optional
Duration of the fade-in effect in ms
default:0
Return Value
Type : integer
The created entity ID
Example
local entity = jo.entity.create('re_kidnappedvictim_females_01', vec3(1294.0, -512.3, 30.0), 90.0, true)
print(entity)
jo.entity.createWithMouse()
Create an entity that follows the mouse cursor for placement
Syntax
jo.entity.createWithMouse(model, keepEntity, networked)
Parameters
model
: string
The model name of the entity to create
keepEntity
: boolean Optional
Whether to keep the entity after placement
default:true
networked
: boolean Optional
Whether the entity should be networked
default:false
Return Value
Type : integer,vector3,number
The created entity ID, final position, final heading
Example
local entityId, position, heading = jo.entity.createWithMouse('p_armchair01x', true, false)
print("Created entity: " .. entityId)
print("Position: " .. tostring(position))
print("Heading: " .. heading)
jo.entity.delete()
Delete an entity if it exists
Syntax
jo.entity.delete(entity)
Parameters
entity
: integer
The entity ID to delete
Example
local entity = 23494
jo.entity.delete(entity)
jo.entity.fadeAndDelete()
Fade out an entity and then delete it
Syntax
jo.entity.fadeAndDelete(entity, duration)
Parameters
entity
: integer
The entity ID to fade and delete
duration
: integer Optional
Duration of the fade effect in ms
default:1000
Example
local entity = 32454
local duraiton = 1000
jo.entity.fadeAndDelete(entity, duration)
jo.entity.fadeIn()
Fade in an entity from transparent to fully visible
Syntax
jo.entity.fadeIn(entity, duration)
Parameters
entity
: integer
The entity ID to fade in
duration
: integer Optional
Duration of the fade effect in ms
default:1000
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.entity.fadeOut()
Fade out an entity from visible to transparent
Syntax
jo.entity.fadeOut(entity, duration)
Parameters
entity
: integer
The entity ID to fade out
duration
: integer Optional
Duration of the fade effect in ms - default:1000
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.entity.getEntityInCrosshair()
Raycast from the camera through the screen center and return what was hit
Displays a small crosshair sprite at screen center
Must be called each frame to render the crosshair
Syntax
jo.entity.getEntityInCrosshair(distance, flags, toIgnore)
Parameters
distance
: number Optional
Maximum raycast distance
default:100
flags
: integer Optional
Flags for the raycast
default:16
toIgnore
: integer Optional
Entity to ignore in the raycast
default:PlayerPedId()
Return Value
Type : boolean,vector3,integer
Hit status, hit coordinates, hit entity
Example
CreateThread(function()
while true do
local hit, coords, entityHit = jo.entity.getEntityInCrosshair()
Wait(0)
end
end)
jo.entity.requestControl()
Request control of an entity and wait until it's granted
Syntax
jo.entity.requestControl(entity)
Parameters
entity
: integer
The entity ID to request control of
Example
local entity = 23494
jo.entity.requestControl(entity)