Ch3ck3r Posted May 19, 2010 Share Posted May 19, 2010 The function wasEventCancelled seems to always return false. I found this in the bug tragger but it was resolved in dp2 already. Nevertheless, the following example code reproduces the error on my machine always. function testEvt() outputChatBox(tostring(wasEventCancelled())) if wasEventCancelled() then outputChatBox("evt was cancelled for reason :"..tostring(getCancelReason())) return nil end outputChatBox("cancelling evt") x = cancelEvent(true, "test cancelling") outputChatBox("evt cancelled: "..(x and "yes" or "no")) end function testEvt2() outputChatBox(tostring(wasEventCancelled())) if wasEventCancelled() then outputChatBox("evt was cancelled for reason :"..tostring(getCancelReason())) return nil end outputChatBox("cancelling evt") x = cancelEvent(true, "test cancelling") outputChatBox("evt cancelled: "..(x and "yes" or "no")) end addEventHandler("onPlayerChat", getRootElement(), testEvt) addEventHandler("onPlayerChat", getRootElement(), testEvt2) This is the only resource running on my server for test purpose. If a player writes something it doesn't show up ingame but in the logs. My script produces the following output: false cancelling evt evt cancelled: yes false cancelling evt evt cancelled: yes Glad for any help. Link to comment
PacMan Posted May 20, 2010 Share Posted May 20, 2010 Status wasEventCancelled changes only after all event handlers, and not during execution. Correspondingly wasEventCancelled can only be used after calling the event, using triggerEvent. 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