Ox_target and dragging a player

Hello,
so basically I have a handcuff resource on my server that was handled by a menu. I recently changed the handle method to ox_target and can’t really get the resource to working. In the handcuff resource i have various tasks, like putting a player in the vehicle, restraining and dragging a player. The method I am using to drag a player is
AttachEntityToEntity(playerPed, targetPed, 11816, 0.54, 0.54, 0.0, 0.0, 0.0, 0.0, false, true, false, true, 2, true)
After adding it to ox_target (as an option):

{
name = ‘drag’,
icon = ‘fa-thin fa-person-walking’,
label = ‘moven’,
distance = 0,
onSelect = function(data)
local closestPlayer = ESX.Game.GetClosestPlayer()
TriggerServerEvent(‘esx_cuff:drag’, GetPlayerServerId(closestPlayer))
end,
canInteract = function(entity)
return IsPedInAnyVehicle(PlayerPedId(-1))
end
},

I can start dragging a player, the eye appears, but when I try to stop the eye won’t target the player. Is there any solution to this?

any ideas?

1 Like

It’s because you don’t have collision with dragged Entity. The way that targets works is that they raycast and search for entities, if entity doesn’t have any collision, it just wont register any raycast hit and entity won’t be found. You just need to change collision option in attachEntityToEntity and it should work

wow, thank you, this helped! appreciate it. do you by any chance know how to target a specific player sitting in a car?

What do you want to do ? Because i don’t understand what do you mean by specific player. How do you specify this player?

What i mean is:
I have a script that allows me to cuff/uncuff/move player. One additional option is putting player in the vehicle and dragging him out of the vehicle. Putting player in the vehicle is not a problem with ox_target, the problem is when i want to drag the player out of the vehicle → i cant figure out a way to target the player not the vehicle

You need to create global vehicle lime you did with handcuffs and then what you want to do is to create 4 options for each seat in that car, and check if There is any ped in this seat and then check if this ped is a player and is cuffed. I Think There is no other way to do it.

Gonna try it today. I would have never came up with a solution like this, thank you :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.