Help with SetPedSuffersCriticalHits

Hey, I’ve tried to enable (yes enable) headshot Oneshot on my Server, I’m using es_extendet legacy, and since the start headshot wasn’t Oneshot.

so I think there has to be some client whatever that disables it and maybe someone knows which:k

Hello, I am un-aware on what you are talking about, although here is a quick event that should make headshots one shot! :smile:

AddEventHandler('gameEventTriggered', function(name, args)
    if name ~= 'CEventNetworkEntityDamage' then return end -- If a player was not damaged, then return, we don't need it.

    local victim, ped = args[1], PlayerPedId()

    if ped == victim then
        local boneHit, whatBone = GetPedLastDamageBone(ped)

        if boneHit then
            if whatBone == 31086 then
                if not IsEntityDead(ped) then
                    SetEntityHealth(ped, 0)
                end	
            end
        end
    end
end)

Hey, thx for the quick reply but where would I have to use this? just in a client?

1 Like

correct

yea i did that and it works fine, but now even when u punch people in the head the insta die :confused:

1 Like

so, basically, i used ur script but it renders Every hit that goes to the head as a kill, I dug a bit around and everyone was talking about setpedsufferscriticalhits SetPedSuffersCriticalHits - Natives @ Cfx.re Docs

I even found code that should REMOVE it so I thought I can just true the false and I would get the result I want, but even then nothing worked, so I thought maybe some of my scripts disabled it, and to find it out I just backup my server and started again putting one for one script in.

but now even with only the standard ESX scripts, it’s still no one-shot headshot.

so does ANYONE know a solution for that?

(here’s the code I used maybe that’s what’s wrong)

Citizen.CreateThread(function()

while true do

    SetPedSuffersCriticalHits(GetPlayerPed(-1), false)

    Wait(1)

end
end)

All you need to do is get the weapon the player was killed with on the event, if it there were killed with WEAPON_UNARMED then just return the event.

(not tested, not sure if it works, but just a way you could go abt fixing the issue)

all right i got it now, long work to find out so basically u cust use the thing I hade up there:

Citizen.CreateThread(function()

while true do

SetPedSuffersCriticalHits(GetPlayerPed(-1), false)

Wait(1)

end
end)

and put it in a own ressource (not with something else) and it works fine idk why but making it its own and not using it with my anti pistol wip fixed it

heres the finished GitHub - Artjomowitch/Artjom: Just a simple script at enables setpedsufferscriticalhits (head shot one shot) client just put a __resource in it and start it in the cfg

how do i do this exactly? i try all but nothing work

you need to figure out the argument that returns the weapon used to damage a player. After that you can just make it a variable and then check if it is equal to WEAPON_UNARMED, something like this:

local weapon_used = args[2] -- Probably not the correct argument, just showing and example.
if (weapon_used == `WEAPON_UNARMED`) then return end -- Make sure to use the ` when specifying the unarmed fists.

Hello guys, I also want to set my server to “headshot oneshot” and I downloaded the “Artyom” script, but you mentioned that we need to add a __resource.lua, and I don’t know what exactly needs to be in the Lua.

did u work it out?