Damage, headshots, recoil, aiming and the weapon HUD
Settle access first, then prices, then damage. Roleplay needs fights long enough to play out; PvP needs them fast and consistent. Recoil, aiming, the crosshair and the ammo counter decide how the result feels.
CreateThread(function()
SetWeaponDamageModifier(`WEAPON_PISTOL`, 0.8)
SetWeaponDamageModifier(`WEAPON_CARBINERIFLE`, 0.7)
SetPlayerMeleeWeaponDamageModifier(PlayerId(), 0.5)
end)
AddEventHandler('playerSpawned', function()
SetPedSuffersCriticalHits(PlayerPedId(), false) -- no instant headshot kills
end)| Lever | Roleplay | PvP / redzone |
|---|---|---|
| Access | Licences, crafting, black market, police by grade | Loadout kits on entry |
| Headshots | Not instant (SetPedSuffersCriticalHits false) | Consistent, often instant |
| Damage | Lower, longer fights | Fixed per weapon class |
| Ammo and durability | A running cost | Free or generous |
| Melee | Reduced; no pistol-whipping | Often disabled |
- Permanent per-weapon values are
DamageandHeadShotDamageModifierPlayerin weapons.meta. - Throwables such as grenades, molotovs and sticky bombs are stackable items, so restrict them in shops.
- Change a single value, then read the kill logs before you change the next.
Complaints that combat feels bad usually trace back to five things: recoil, first-person aiming, the crosshair, combat rolls and quick swaps.
local KICK = { [`WEAPON_PISTOL`] = 0.3, [`WEAPON_CARBINERIFLE`] = 0.5 }
CreateThread(function()
while true do
local ped = PlayerPedId()
local weapon = GetSelectedPedWeapon(ped)
if weapon == `WEAPON_UNARMED` then
Wait(500)
else
Wait(0)
if IsPedShooting(ped) then
local kick = KICK[weapon] or 0.3
SetGameplayCamRelativePitch(GetGameplayCamRelativePitch() + kick, 0.2)
end
if IsPlayerFreeAiming(PlayerId()) then
HideHudComponentThisFrame(14) -- reticle
DisableControlAction(0, 22, true) -- jump = combat roll while aiming
end
end
end
end)| Want | How |
|---|---|
| First person while aiming | SetFollowPedCamViewMode(4) on aim, restore after; disable control 0 (V) |
| No weapon wheel | Disable control 37, hide HUD components 19 and 20, SetWeaponsNoAutoswap(true) |
| No quick swap while shooting | Disable slot controls 157–165 and scroll 14–17, or SetPedCanSwitchWeapon(ped, false) |
| Holster animation | reaction@intimidation@1h intro/outro when drawing and holstering |
| Camera shake | ShakeGameplayCam('HAND_SHAKE', 0.2); stop with StopGameplayCamShaking(true) |
Run these loops at Wait(0) only while the player is armed. Unarmed they sleep, which keeps the idle cost at 0.00 ms in resmon.
A custom ammo counter follows the same rule. It takes a few natives and one message to the NUI, sent only when a value has changed.
local last = {}
CreateThread(function()
while true do
local ped = PlayerPedId()
local weapon = GetSelectedPedWeapon(ped)
local armed = weapon ~= `WEAPON_UNARMED`
local _, clip = GetAmmoInClip(ped, weapon)
local total = GetAmmoInPedWeapon(ped, weapon)
if armed ~= last.armed or clip ~= last.clip or total ~= last.total then
last = { armed = armed, clip = clip, total = total }
SendNUIMessage({ action = 'ammo', data = last })
end
Wait(armed and 150 or 600)
end
end)DisplayAmmoThisFrame(false)on every frame hides the game’s own counter; hiding HUD component 2 does the same.GetMaxAmmoInClip(ped, weapon, true)returns the magazine size, which is what a bar needs.- On ox_inventory, the
ox_inventory:currentWeaponevent fires when the equipped weapon changes.