so when I go to give myself a custom weapon in my inventory which uses GiveWeaponToPed and the bForceInHand flag is true, when on foot it the weapon appears in my hand, but when in a vehicle it does not.
I did some testing for this without the inventory:
If I give myself a default gta weapon, in a vehicle, it forces in hand.
hen if I give myself a custom addon pistol it appears in the tab menu but not automatically in my hand.
is there a meta file im missing or a setting im not enabling in them?
The only thing I can think of off the top of my head, is that GiveWeaponToPed is not forcing it in hand while in a vehicle, since SetCurrentPedWeapon has the same boolean parameter and SetCurrentPedVehicleWeapon doesn’t. So it’s like you can’t force it in hand while in a vehicle, by default.
I wonder though, if it’s also because when you give a weapon to a ped, usually it only equips it right away if it is more powerful than the rest of their weapons. GTA likes to prioritise, so if you have a powerful weapon like an SMG, then give a pistol, it won’t swap. But if you have a pistol and give an SMG or something, it will. But tinker with those 2 natives, in my opinion. See what’s possible.
Update for those that want to actually fix this the SetPedCurrentWeaponVisible native is needed to be called if you are already in a vehicle.
-- Give weapon to player
if IsPedInAnyVehicle(PlayerPedId(), false) then
print("I am a fucker in a car")
SetCurrentPedVehicleWeapon(PlayerPedId(), weaponhash)
SetCurrentPedWeapon(PlayerPedId(), weaponhash, true)
SetPedCurrentWeaponVisible(PlayerPedId(), true, false)
end