How to Tell When A PLayer Kills A Ped

Trying to figure out how to tell when a payer kills a ped. GetNearbyPeds should be the way to go, but doesn’t work, __data has a problem and breaks the function.

I am at the point of using the ped the player is targeting using Citizen.InvokeNative(“GET_PLAYER_TARGET_ENTITY”, playerPed, entity, Citizen.ReturnResultAnyway()). That function returns a hash for the ped, problem is, how do i turn that hash into a Ped item? Or does the Ped being returned by GetRandomPedAtCoord,for example, just a hash?

Having troubles trying to figure out how to tell when a player kills a ped. Any help or guidance is much appreciated.

Current code:
– Get the player, used all over the script
local playerPed = GetPlayerPed(-1)

– make sure the player is targeting something
if IsPlayerFreeAiming(playerPed) and IsPlayerTargettingAnything(playerPed) then
– get the entity being tageted
entity = 0
if Citizen.InvokeNative(“GET_PLAYER_TARGET_ENTITY”, playerPed, entity, Citizen.ReturnResultAnyway()) then
– got the entity, how to convert to a ped?

        -- add ped to ped table to keep an eye out for death
        table.insert(peds, ped)
    end
end
1 Like
local targetFound, targetPed = Citizen.InvokeNative(0x13EDE1A5DBF797C9, PlayerId(), Citizen.ReturnResultAnyway())

I hope that clarifies on how the native should be used.

That is nothing like what natives.lua shows to do. Thanks for the correction. Will try in the next few days, see if that works.

How to know if I killed these ped models

local pedModels =
{
“zombie”,
“U_M_Y_Zombie_01”,
}