Moderators IIYAMA Posted May 19, 2017 Moderators Share Posted May 19, 2017 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
pa3ck Posted May 19, 2017 Share Posted May 19, 2017 Do you also get the outputChatBox("event is cancelled") before the iprint(wasEventCancelled()) in the chat? Link to comment
Moderators IIYAMA Posted May 19, 2017 Author Moderators Share Posted May 19, 2017 yes Link to comment
Anubhav Posted May 20, 2017 Share Posted May 20, 2017 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
Moderators IIYAMA Posted May 21, 2017 Author Moderators Share Posted May 21, 2017 I am using elementdata now with sync off. Using an export function might also be a good idea. Yea strange that wasEventCancelled didn't work. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now