Hello,
I would like to change the damage caused by a melee attack from a player to a player but I can’t find the native. Can you help me ?
Thanks all
local MeeleWeapons = {
["WEAPON_BAT"] = 0.1,
["WEAPON_KNIFE"] = 0.1
}
Citizen.CreateThread(function()
while true do
Citizen.Wait(5)
for weapon, modifier in pairs(MeeleWeapons) do
if GetSelectedPedWeapon(PlayerPedId()) == GetHashKey(weapon) then
SetPlayerMeleeWeaponDamageModifier(PlayerId(), v)
end
end
end
end)
This could work, try changing or adding more weapons in the array i added.
Thank you i’ll try it. I’m talking about “Unarmed” weapon. I want modify Punch Damage
type Weapon_UNARMED and try putting like 0.1
I tried it but nothing http://prntscr.com/lzhslq
I have change
SetPlayerMeleeWeaponDamageModifier(PlayerId(), v)
to
SetPlayerMeleeWeaponDamageModifier(PlayerPedId(), v)
And it still working for meleeweapon like knife or Bat but not for WEAPON_UNARMED
What is v
?
I think v
Callback “0.1
” behind "WEAPON_BAT"
Hmm. Odd.
--I think 1.27 is 1 hit.
local MeeleWeapons = {
["WEAPON_NIGHTSTICK"] = 0.1,
["WEAPON_BAT"] = 0.000001
}
Citizen.CreateThread(function()
while true do
Citizen.Wait(5)
for weapon, modifier in pairs(MeeleWeapons) do
if GetSelectedPedWeapon(PlayerPedId()) == GetHashKey(weapon) then
SetPlayerMeleeWeaponDamageModifier(PlayerId(), v)
end
end
end
end)
Did anyone every validate a working script. i tried @qalle’s code, but i wasn’t able to get it to work for any weapon
Success find working script ?
Try this, untested.
local WeaponDamage = {
{name = "WEAPON_NIGHTSTICK", damage = 0.1},
{name = "WEAPON_BAT", damage = 0.000001},
{name = "WEAPON_PISTOL", damage = 0.0}
}
Citizen.CreateThread(function()
while true do
Wait(0)
local ply = PlayerPedId()
local _, currWep = GetCurrentPedWeapon(ply, true)
for i = 1, #WeaponDamage, 1 do
local damageWep = GetHashKey(WeaponDamage[i].name)
if currWep == damageWep then
SetPlayerMeleeWeaponDamageModifier(ply, WeaponDamage[i].damage)
end
end
end
end)
I’ll try once i get home tonight. thanks for the update though!
This did not fix it should this be server or client file?
figured it out, had to change
GetCurrentPedWeapon()
to
GetSelectedPedWeapon()
BUT i’m still having the same problem. I want to reduce the damage of being pistol whipped, or melee by firearm
EDIT:
after further testing, this did not fix the issue, people are still dying from getting hit with a weapon in one hit…
Looked into this a bit and doesn’t look like you can reduce the damage. Pistol whip is handled by the CActionDefinitions(see: data/action/definitions.meta) and I don’t think you can stream that file. The damage itself is DAR_kill_self_head
from data/action/damages.meta which has the DRA_IGNORE_ARMOR DRA_IGNORE_STAT_MODIFIERS
attributes meaning the damage isn’t affected by the weapon or melee multipliers.
If you want to you could disable pistol whipping. I haven’t tested but removing the AllowCloseQuarterKills weapon flag from each weapon in weapons.meta should disable pistol whipping.
EDIT:
Looks like the ACTION_TABLE_DEFINITIONS data mounter is likely for data/action/definitions.meta.
I will definitely update the pistol whip thing, but the code above still doesn’t seem to work for me even for melee weapon, like I still get one shot from a bat
Melee weapons also have a close quarter kill melee action and on top of that they can critical hit when you hit someone in the head. So you will want to remove the AllowCloseQuarterKills flag and adjust the headshot damage multiplier for melee weapons in weapons.meta.
I explained the critical hit damage in another thread.
Here you go guys, much simpler!
Citizen.CreateThread(function()
while true do
N_0x4757f00bc6323cfe(GetHashKey("WEAPON_UNARMED"), 0.5)
Wait(0)
end
end)
(0.5 is the damage modifier 0.00 - 1.00)