Help needed with one line (GetVehiclePedIsUsing)

Hey, I am creating my first home made script (wich i will definatly share here once complete :slight_smile: ) . However I’ve hit a bit of a problem.

I am trying to make sure the player is using a certain car. The code I am using for this is the next:

if GetVehiclePedIsUsing(GetPlayerPed(-1)) == ‘stretch’ then
dosomething()
end

I have tried numerous variations on this but can’t seem to get it to activate.
I am thinking theres an issue between the way the value comes back and what I am checking.
Not sure tho.

If someone could shed some light on this or give me an alternative to check for a specific car that would be great.

Tnx.

local boat = GetVehiclePedIsIn(LocalPed(), false)

gives you a hash I believe, so you probably need to do GetHash()

ah yes, this is how I did it…

if IsVehicleModel(boat, GetHashKey("predator")) then

change boat with whatever local you are putting the vehicle in and “predator” with model

GetVehiclePedIsIn return the ID of the entity my friend, not the hash of the model

Like @Lobix300 already mentioned, GetVehiclePedIsIn returns the EntityID, not the model or hash.
Use this instead:

IsVehicleModel(GetVehiclePedIsIn(GetPlayerPed(-1), true), GetHashKey("STRETCH"))
1 Like

Thank you very much. I have tested this and it works.

I am glad I could help you