vicisdev Posted January 10, 2022 Share Posted January 10, 2022 (edited) I was expecting this to work, but custom events seem not cancellable. Is this how custom events should work? local number = 0 addEvent("customEvent") addEventHandler("onPlayerJoin", root, function() local player = source bindKey(player, "e", "down", function() number = number + 1 triggerEvent("customEvent", player) end) end) addEventHandler("customEvent", root, function() outputDebugString(number) if number % 2 == 0 then cancelEvent() end end) addEventHandler("customEvent", root, function() if wasEventCancelled() then outputDebugString("Cancelled") else outputDebugString("Called") end end, true, "low") To provide a little bit of context I was trying to implement a way for developers to cancel my custom events default behaviors using cancelEvent. Edited January 10, 2022 by vicisdev Link to comment
Scripting Moderators thisdp Posted January 10, 2022 Scripting Moderators Share Posted January 10, 2022 See the example on https://wiki.multitheftauto.com/wiki/WasEventCancelled wasEventCancelled is used after triggerEvent. 1 Link to comment
vicisdev Posted January 10, 2022 Author Share Posted January 10, 2022 17 hours ago, thisdp said: See the example on https://wiki.multitheftauto.com/wiki/WasEventCancelled wasEventCancelled is used after triggerEvent. I hate asking for help because of that. It was obvious. Thank you Link to comment
The_GTA Posted January 10, 2022 Share Posted January 10, 2022 1 hour ago, vicisdev said: I hate asking for help because of that. It was obvious. Thank you Please don't worry. It does only appear obvious because you have become smarter now. 1 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