#weapon damage
1 messages · Page 1 of 1 (latest)
qb-ambulancejob --> config.lua
no i mean how do i change the damage the weapon does
yes but the damage is the same when i shoot the player in the head and the body
i want headshot multiplier
i dont think you understand
local weapons = {
[`WEAPON_PISTOL`] = { damage = 0.8, headshotMultiplier = 2.5, criticalHits = true },
[`WEAPON_SMG`] = { damage = 0.9, headshotMultiplier = 2.0, criticalHits = true },
}
CreateThread(function()
while true do
Wait(0)
local ped = PlayerPedId()
local weapon = GetSelectedPedWeapon(ped)
if weapons[weapon] then
local modification = weapons[weapon]
SetWeaponDamageModifier(weapon, modification.damage)
SetPedSuffersCriticalHits(ped, modification.criticalHits)
if IsPlayerFreeAiming(PlayerId()) then
local success, hitEntity = GetEntityPlayerIsFreeAimingAt(PlayerId())
if success and IsEntityAPed(hitEntity) then
local boneTarget = GetPedBoneIndex(hitEntity, 31086) -- Head bone
local _, hit, _, _, entityHit = GetShapeTestResult(StartShapeTestRay(GetEntityCoords(ped), GetEntityCoords(hitEntity), -1, ped, 0))
if hit and entityHit == hitEntity then
local headshot = HasEntityBeenDamagedByWeapon(hitEntity, weapon, 0)
if headshot then
SetWeaponDamageModifier(weapon, modification.damage * modification.headshotMultiplier)
end
end
end
end
else
SetWeaponDamageModifier(weapon, 1.0)
SetPedSuffersCriticalHits(ped, true)
end
end
end)
i just spent 5 minutes writing u this, this better be what u "meant"
Why're we raycasting? SetPedSuffersCriticalHits handles headshots?
Raycasting is typically used for more precise hit detection
if he wants to include] custom damage zones (beyond just headshots)
just wrote him a snippet
local weapons= {
[`WEAPON_PISTOL`] = { damage = 0.8, criticalHits = true },
[`WEAPON_SMG`] = { damage = 0.9, criticalHits = true },
}
CreateThread(function()
while true do
Wait(0)
local ped = PlayerPedId()
local weapon = GetSelectedPedWeapon(ped)
if weapons[weapon] then
local modification = weapons[weapon]
SetWeaponDamageModifier(weapon, modification.damage)
SetPedSuffersCriticalHits(ped, modification.criticalHits)
else
SetWeaponDamageModifier(weapon, 1.0)
SetPedSuffersCriticalHits(ped, true)
end
end
end)
theres without raycasting