Does anyone know how I configure the animation to move the person in the H coordinate? I can only move X,Y and Z, I would like, for example, to put the baby looking for me, rotate it.
Code
Does anyone know how I configure the animation to move the person in the H coordinate? I can only move X,Y and Z, I would like, for example, to put the baby looking for me, rotate it.
Code
local carry = {
InProgress = false,
targetSrc = -1,
type = “”,
personCarrying = {
animDict = “anim@heists@box_carry@”,
anim = “idle”,
flag = 49,
},
personCarried = {
animDict = “anim@heists@ornate_bank@hostages@hit”,–“amb@world_human_picnic@female@base”,
anim = “hit_react_die_loop_ped_e”, --“base”,
attachX = -0.40,
attachY = 0.30,
attachZ = 1.2,
attachH = 2.8,
flag = 33,
}
}
local function drawNativeNotification(text)
SetTextComponentFormat(“STRING”)
AddTextComponentString(text)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end
local function GetClosestPlayer(radius)
local players = GetActivePlayers()
local closestDistance = -1
local closestPlayer = -1
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
for _,playerId in ipairs(players) do
local targetPed = GetPlayerPed(playerId)
if targetPed ~= playerPed then
local targetCoords = GetEntityCoords(targetPed)
local distance = #(targetCoords-playerCoords)
if closestDistance == -1 or closestDistance > distance then
closestPlayer = playerId
closestDistance = distance
end
end
end
if closestDistance ~= -1 and closestDistance <= radius then
return closestPlayer
else
return nil
end
end
local function ensureAnimDict(animDict)
if not HasAnimDictLoaded(animDict) then
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do
Wait(0)
end
end
return animDict
end
RegisterCommand(“carregar2”,function(source, args)
if not carry.InProgress then
local closestPlayer = GetClosestPlayer(3)
if closestPlayer then
local targetSrc = GetPlayerServerId(closestPlayer)
if targetSrc ~= -1 then
carry.InProgress = true
carry.targetSrc = targetSrc
TriggerServerEvent(“CarryPeople:sync”,targetSrc)
ensureAnimDict(carry.personCarrying.animDict)
carry.type = “carrying”
else
drawNativeNotification(“Ninguém por perto para carregar!”)
end
else
drawNativeNotification(“Ninguém por perto para carregar!”)
end
else
carry.InProgress = false
ClearPedSecondaryTask(PlayerPedId())
DetachEntity(PlayerPedId(), true, false)
TriggerServerEvent(“CarryPeople:stop”,carry.targetSrc)
carry.targetSrc = 0
end
end,false)
RegisterNetEvent(“CarryPeople:syncTarget”)
AddEventHandler(“CarryPeople:syncTarget”, function(targetSrc)
local targetPed = GetPlayerPed(GetPlayerFromServerId(targetSrc))
carry.InProgress = true
ensureAnimDict(carry.personCarried.animDict)
AttachEntityToEntity(PlayerPedId(), targetPed, 0, carry.personCarried.attachX, carry.personCarried.attachY, carry.personCarried.attachZ,carry.personCarried.attachH, 0.5, 0.5, 180, false, false, false, false, 2, false)
carry.type = “beingcarried”
end)
RegisterNetEvent(“CarryPeople:cl_stop”)
AddEventHandler(“CarryPeople:cl_stop”, function()
carry.InProgress = false
ClearPedSecondaryTask(PlayerPedId())
DetachEntity(PlayerPedId(), true, false)
end)
Citizen.CreateThread(function()
while true do
if carry.InProgress then
if carry.type == “beingcarried” then
if not IsEntityPlayingAnim(PlayerPedId(), carry.personCarried.animDict, carry.personCarried.anim, 3) then
TaskPlayAnim(PlayerPedId(), carry.personCarried.animDict, carry.personCarried.anim, 8.0, -8.0, 100000, carry.personCarried.flag, 0, false, false, false)
end
elseif carry.type == “carrying” then
if not IsEntityPlayingAnim(PlayerPedId(), carry.personCarrying.animDict, carry.personCarrying.anim, 3) then
TaskPlayAnim(PlayerPedId(), carry.personCarrying.animDict, carry.personCarrying.anim, 8.0, -8.0, 100000, carry.personCarrying.flag, 0, false, false, false)
end
end
end
Wait(0)
end
end)