Hello,
My script attaches vehicles and / or peds to vehicles.
How can I check if a vehicle or a ped is attached to a vehicle (when I know the vehicle)?
I’ve already tried GetEntityAttachedTo(vehicle)
, IsEntityAttached(vehicle)
, IsEntityAttachedToAnyPed(vehicle)
/ IsEntityAttachedToAnyVehicle(vehicle)
.
Can’t you just use GetEntityAttachedTo( and then run GetEntityType() on it?
If GetEntityType(vehicle)
returns the type (wich is vehicle (2)), it doesn’t help me, checking if there is something attached to the entity saved as vehicle
, right?
It returns 2 if a vehicle is attached, 1 for a ped
So you can just do
local type = GetEntityType(vehicle)
if type == 2 then
-- vehicle attached
elseif type == 1 then
-- ped attached
end
Or am I misunderstanding your goal?
Does it return the attached entity?
vehicle
is a car, wich has a ped or a vehicle attached to it. I need to find out, if there is something (type does not matter) attached to it.
You can just do GetEntityAttachedTo(vehicle)
than and check if the entity exists probably
DoesEntityExist(GetEntityAttachedTo(GetVehiclePedIsIn(GetPlayerPed(-1), 0)))
The player is sitting in an vehicle wich has another vehicle attached to it. It returns false
.
Any other method? Or have I made a mistake?
Ok I did some testing, seems like GetEntityAttachedTo()
only works on the attached entity
1 Like