Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vehicle Weapon Ammo #2300

Open
CaMoTraX opened this issue Dec 9, 2023 · 1 comment
Open

Vehicle Weapon Ammo #2300

CaMoTraX opened this issue Dec 9, 2023 · 1 comment
Assignees
Labels
enhancement Feature or other request that adds functionality or improved usability

Comments

@CaMoTraX
Copy link

CaMoTraX commented Dec 9, 2023

What happened?

SetVehicleWeaponCapacity and
GetVehicleWeaponCapacity

Booth not working properly. Tried using them on a spawned vehicle and nothing worked.
But when i put this code into a loop:

`
Citizen.CreateThread(function()

while true do
Wait(100)

	local ped = GetPlayerPed(-1)
	local veh = GetVehiclePedIsIn( ped, false )
	local slot, hash = GetCurrentPedVehicleWeapon( ped )

	SetVehicleWeaponCapacity(veh, slot, 100)
	print( GetVehicleWeaponCapacity( veh, slot ) )

end
end)
`

It sets the capacity to 100 ONCE, but it should refill it every 100ms. This also just work with the loop already running and then spawning the vehicle. It won't work on already spawned vehicles.
GetVehicleWeaponCapacity also return wrong values.

Getting this fixed would be awesome, due i want to limit vehicle weapons ammo.

Expected result

SetVehicleWeaponCapacity(veh, slot, 100) = Ammo of that slot 100, no matter if already spawned.

Reproduction steps

Spawn a vehicle ( dune3 ) and get in.

Exececute:
local ped = GetPlayerPed(-1)
local veh = GetVehiclePedIsIn( ped, false )
local slot, hash = GetCurrentPedVehicleWeapon( ped )

SetVehicleWeaponCapacity(veh, slot, 10)
print( GetVehicleWeaponCapacity( veh, slot ) )

It should return 10 ammo, try to shoot and get out of ammo. Check your ammo using the print. It will stay the same.

Importancy

Slight inconvenience

Area(s)

FiveM, OneSync, Natives

Specific version(s)

FiveM b2802, FXServer 6683

Additional information

No response

@CaMoTraX CaMoTraX added bug triage Needs a preliminary assessment to determine the urgency and required action labels Dec 9, 2023
@gottfriedleibniz
Copy link
Contributor

The issue here is that GetCurrentPedVehicleWeapon does not return the "weaponIndex" - it just returns true/false and the weapon hash. Neither of which can be used with GetVehicleWeaponCapacity/SetVehicleWeaponCapacity

Referencing the decompiled game scripts it seems everything is hard coded based on model, e.g., "if the model is dune3 let slot = 1". All of this data can be referenced from CVehicleWeaponHandlingData within the vehicles HandlingData, which, unfortunately cannot be accessed via native at this time.

@gottfriedleibniz gottfriedleibniz removed the triage Needs a preliminary assessment to determine the urgency and required action label Feb 13, 2024
@gottfriedleibniz gottfriedleibniz added enhancement Feature or other request that adds functionality or improved usability and removed bug labels Feb 27, 2024
@FabianTerhorst FabianTerhorst self-assigned this Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature or other request that adds functionality or improved usability
Projects
None yet
Development

No branches or pull requests

3 participants