Hi,
I want to make function wich call function StartBleeding() when player get shot from a firegun.
I tried this code but after hitting the function star spamming the notification and StartBleeding() function
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if (HasPedBeenDamagedByWeapon(GetPlayerPed(-1), 0, 2)) then
StartBleeding()
exports.pNotify:SendNotification({type = 'success', text ='You started bleeding!', layout = "topRight", timeout = 3500})
end
end
end)
When I was testing those natives did not work as we need them to, so another option would be to use the low-level game event called CEventNetworkEntityDamage, it could be set up and use like so:
AddEventHandler('gameEventTriggered', function(event, args)
if event == "CEventNetworkEntityDamage" then
if PlayerPedId() ~= args[1] then
return
end
if GetWeapontypeSlot(args[7]) == 0 or args[12] == 1 then
return
end
if not bleeding then
StartBleeding()
exports.pNotify:SendNotification({type = 'success', text ='You started bleeding!', layout = "topRight", timeout = 3500})
end
end
end)
Here are some notes on the args in case you need them: