Damage doesn't register client-sided (OneSync Inf)

Client

Using canary? no

Server

Operating system: win10
Artifact version: 2802

Incident

Summary: Only some of the damage triggering the client game event gameEventTriggered - CEventNetworkEntityDamage
Expected behavior: Every damage that the attacker makes should trigger the event for everyone that the attacker and the victim’s scope.
Actual behavior: Damage triggers the event only some times and only when the victim doesn’t have armor.
Steps to reproduce:

  1. execute this script client-sided:
AddEventHandler('gameEventTriggered', function (name, args)
  print('game event ' .. name .. ' (' .. json.encode(args) .. ')')
end)
  1. shoot someone a few times and check the console if every shot is being printed with CEventNetworkEntityDamage.

Server/Client? Idk

Any additional info:

2 Likes

Does this happen without 1s? Does the player on the other side get damaged at all?

This is R* code entirely, not sure if it’s considered as a valid bug or as a request to add a custom damage event. :confused:

1 Like

This used to work, I had a whole system counting on this and it worked well, I just updated the server to the last version and this happened, also my client updated today, so I don’t know if it’s a server or a client issue, I can only say this used to work 100%

Now it’s working only if the victim doesn’t have armor and if you wait ~2 seconds between every bullet you shoot. same for ramming and every other way to make damage.

I know there’s an event of damage in the server-side (weaponDamageEvent), but it’s not triggering in some cases, like when you shoot on an empty vehicle or just falling from heights, so I prefer using the client-side event.

If FiveM can make an event that also works when a ped gets damage from height & on empty vehicle & know how much damage you dealt, so I won’t care if this is won’t be fixed.

2 Likes

Ah, I guess in this case it triggers locally when the client becomes aware of damage done to any entity, so perhaps an update rate concern.

1 Like

The client doesn’t aware of damage done when the victim has armor? btw, the event is being triggered for every shot in the victim side, so it’s probably a rate concern like you said.
About rate, is it possible to change it by myself, or I have to wait for an official update? because I came across to some more issues related to the rate

2 Likes

the event is being triggered for every shot in the victim side

A way Solution for this moment :

--Client
DecorRegister("lasthp",3) 
DecorRegisterLock()

CreateThread(function()
    while true do 
        Wait(0)
        if not DecorExistOn(PlayerPedId(),"lasthp") then 
            DecorSetInt(PlayerPedId(),"lasthp",GetEntityHealth(PlayerPedId(), false))
        end 
    end 
end )

AddEventHandler('gameEventTriggered',function(name,args)
   GameEventTriggered(name,args)
end)

function GameEventTriggered(eventName, data)
    if eventName == "CEventNetworkEntityDamage" then
        victim = tonumber(data[1])
        attacker = tonumber(data[2])
        victimDied = tonumber(data[4]) == 1 and true or false 
        weaponHash = tonumber(data[5])
        isMeleeDamage = tonumber(data[10]) ~= 0 and true or false 
        vehicleDamageTypeFlag = tonumber(data[11]) 
        local FoundLastDamagedBone, LastDamagedBone = GetPedLastDamageBone(victim)
        local bonehash = nil 
        if FoundLastDamagedBone then
            bonehash = tonumber(LastDamagedBone)
        end
        
        if victim == PlayerPedId() then 
            CreateThread(function()

                while not DecorExistOn(PlayerPedId(),"lasthp") do 
                    Wait(0)
                end 
                if DecorExistOn(PlayerPedId(),"lasthp") then 
                    local nowhp = victimDied and 0 or GetEntityHealth(victim)
                    local oldhp = DecorGetInt(victim,"lasthp")
                    if nowhp  < oldhp then
                        TriggerServerEvent("SyncEntityDamage",nowhp,oldhp)
                        
                    end 
                    if victimDied then 
                        DecorRemove(victim,"lasthp")
                    else
                        DecorSetInt(victim,"lasthp",nowhp)
                    end 
                end 
                
                return
            end )
            
            
        end 

        
    end
end
--Server
RegisterServerEvent("SyncEntityDamage")
AddEventHandler('SyncEntityDamage',function(nowhp,oldhp)

        TriggerClientEvent('OnEntityHealthChange',-1,source,nowhp,oldhp)

   
end )
2 Likes