Player get shot function?

hey guys, im working on a script that starts a few things when a player get shot… eg. ragdoll and stuff.
but it looks like im using a native that isnt suitable for that (IsShockingEventInSphere).

it looks like its reading if a PED is getting shot and not the player and as im really new to programming, im not able to change or understand how to change this.

at the moment im doing this to only check with the native around the player coords, so only the player is checked… but this doesnt work:

local playerPed 	        = GetPlayerPed(-1)
local playerCoords 	= GetEntityCoords(playerPed)

if IsShockingEventInSphere(102,playerCoords.x,playerCoords.y,playerCoords.z,1.0) then

Iif i shoot an NPC my player is reacting to it…
And if somebody shoots me, my player isnt reacting. If i use a button instead of “IsShockingEventInSphere” it works perfectly… so it really looks to me, that this native is not usable for this.

Does anybody know a proper way to check if a playerped is getting shot?

thank you!

to answer my question if somebody wants to know the same:

i have found another native that works better for this use:
HasPedBeenDamagedByWeapon

1 Like

What code this you use for this i want to use this plugin too for my server but i am getting the same issue and i dont understand your solution, so if you can send the code that u used i would appreciate it.

Use This:

if IsPedShooting(GetPlayerPed(-1))