Jump to content

cancel onClientPlayerDamage


IIYAMA

Recommended Posts

  • Moderators
addEventHandler ( "onClientPlayerDamage", localPlayer,
function (attacker, weapon, bodypart, loss)
    if attacker and attacker ~= localPlayer and bodypart == 9 and instandHeadshotKillWeapons[weapon] and not isPedDead(localPlayer) then
        iprint(wasEventCancelled ())
        if not wasEventCancelled () then
            triggerServerEvent("onPlayerSyncHeadshot", resourceRoot, attacker, weapon, bodypart, loss)
            setElementHealth(localPlayer, 0)
            startBlockingPlayerControls()
        end
    end
end, false, "low-100")

Headshot script.

 

 

local function stopDamage ( attacker, weapon, bodypart )
   if isTimer(spawnProtectionTimer) then
	cancelEvent()
	outputDebugString("event is cancelled")
   end   
end
addEventHandler ( "onClientPlayerDamage", localPlayer, stopDamage, false, "high+100" )

Spawnprotection script.

 

I am trying to let the client cancel the player damage for spawnprotecion. But it seems like wasEventCancelled doesn't detect that the event was cancelled on the headshot script. I already changed the event order.

Do you guys have any idea?

 

 

 

Link to comment

There can be a solution around this.

You can use exports to the damage cancelling resource, and call it when it hits the head or use element data. That is a way around it, although I do not see a reason why wasEventCancelled wouldn't detect it.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...