How would i go about making a Firing Mode Script? How it would work is if you press a curtain key it will make the carbine rifle a single shot (more realistic) or a 3 round burst or just any firing mode.
Firing Modes (Single shot / Burst mode / Full auto & Safety toggle)
[Release] Single Shot Fire Mode & Safety Feature
Unless someone knows how to stop/disable a player/weapon from shooting, I don’t think this is possible.
It could possibly be done by disabling the control used to fire. Then check if the disabled control is pressed, then fire the weapon once or however many times (if there is a native to fire it).
Maybe check if the control has just been pressed then
GetAmmoInPedWeapon(ped, weaponhash) and just use that to count how many shots have fired then either disable the control or clear ped tasks and when the disabled control is released enable the control again or something.
Could try use: https://runtime.fivem.net/doc/reference.html#_0x34616828CD07F1A1 disable firing control, do a wait then re-enable it? (For semi-auto.)
All these solutions are related to disabling the fire input/control. This doesn’t work for shooting, melee attacks or any other type of attack (except aiming/vehicle attack/secondary melee attacks like R). If you disable the control, they can still shoot
Well, that is very depressing. xD
Actually I may have found something that could work, I’ll update it once I’ve tested it.
I’ve got it working now, just trying to make it a bit less of a mess and just doing some additional testing and making sure it doesn’t affect gameplay when not shooting
I know this is possible I have seen it on highspeed gaming but all guns are just single.
Here’s my attempt
Citizen.CreateThread(function() local burst = 3 local autofire = true while true do Citizen.Wait(0) if IsControlJustPressed(1, 288) and IsInputDisabled(2) then --F1 autofire = not autofire end if not autofire then local hasWeapon, currentWeapon = GetCurrentPedWeapon(PlayerPedId(), 1) if currentWeapon ~= nil then if IsPedArmed(PlayerPedId(), 7) then local ammo = GetAmmoInPedWeapon(PlayerPedId(), currentWeapon) if IsControlPressed(1, 24) and IsPedShooting(PlayerPedId()) then local halted = GetGameTimer()+1000 while IsControlPressed(1, 24) and halted do Citizen.Wait(0) if GetAmmoInPedWeapon(PlayerPedId(), currentWeapon) <= ammo - burst then ClearPedTasks(PlayerPedId()) if GetGameTimer() > halted then halted = false end end end end end end end end end)
I’ll add some more features to this and release my attempt in #development:releases when It’s finished.
Dope, Didnt think people would actually reply
Just released my version, checkout this topic here for info: Firing Modes (Single shot / Burst mode / Full auto & Safety toggle)