I want to share my trial. It’s working but not stable for Face to Face.
First one i divide target and source code.
------------------------------ SOURCE ----------------------
RegisterNetEvent("GiveAnims") --> this event is for play anim when the player accept.
AddEventHandler("GiveAnims", function()
local ped2 = PlayerPedId()
local heading = GetEntityHeading(GetPedInFront())
--local ped = PlayerPedId()
local playerCoords = GetEntityCoords(ped)
local giveAnim = "mp_ped_interaction" --> Here is your animLib that u want use.
RequestAnimDict(giveAnim)
while not HasAnimDictLoaded(giveAnim) do
Citizen.Wait(100)
end
--SetEntityHeading(ped2, heading - 180.1)
--SetEntityCoords(ped2, playerCoords["x"], playerCoords["y"], playerCoords["z"] - 1.00)
--Citizen.Wait(2500)
TaskPlayAnim(ped2, giveAnim, "kisses_guy_a", 8.0, 8.0, -1, 50, 0, false, false, false)
FreezeEntityPosition(PlayerPedId(), true)
Citizen.Wait(2500)
ClearPedTasks(ped2)
FreezeEntityPosition(PlayerPedId(), false)
end)
--------------------------------- TARGET ------------------------------------
RegisterNetEvent("GiveAnims2") --> this event is for play anim when the player accept.
AddEventHandler("GiveAnims2", function()
local heading = GetEntityHeading(GetPedInFront())
local ped = PlayerPedId()
local ped2 = GetPedInFront()
local pedPlayer = GetPlayerFromPed(ped2)
--local ped2 = GetClosestPlayer()
local playerCoords = GetEntityCoords(ped2)
local playerCoords2 = GetEntityCoords(ped)
local giveAnim = "mp_ped_interaction" --> Here is your animLib that u want use.
RequestAnimDict(giveAnim)
while not HasAnimDictLoaded(giveAnim) do
Citizen.Wait(100)
end
SetEntityHeading(ped, heading - 180.1)
TaskGoStraightToCoord(PlayerPedId(), playerCoords["x"], playerCoords["y"], playerCoords["z"], 1.0, 5000, 0, 0.0)
--Citizen.Wait(2000)
--SetEntityCoords(ped, playerCoords2["x"], playerCoords2["y"], playerCoords["z"] - 1.00)
--FreezeEntityPosition(PlayerPedId(), true)
TaskPlayAnim(ped, giveAnim, "kisses_guy_a", 8.0, 8.0, -1, 50, 0, false, false, false)
Citizen.Wait(2500)
ClearPedTasks(ped)
--FreezeEntityPosition(PlayerPedId(), false)
end)
you can get the coordinates of the other player with local ped2 = GetPedInFront()
But you must add this code;
function GetPedInFront()
local player = PlayerId()
local plyPed = GetPlayerPed(player)
local plyPos = GetEntityCoords(plyPed, false)
local plyOffset = GetOffsetFromEntityInWorldCoords(plyPed, 0.0, 1.3, 0.0)
local rayHandle = StartShapeTestCapsule(plyPos.x, plyPos.y, plyPos.z, plyOffset.x, plyOffset.y, plyOffset.z, 10.0, 12, plyPed, 7)
local _, _, _, _, ped2 = GetShapeTestResult(rayHandle)
return ped2
end
function GetPlayerFromPed(ped2)
for a = 0, 255 do
if GetPlayerPed(a) == ped2 then
return a
end
end
return -1
end
And nonsense trials bla bla bla. I’m fcking untalented developer.