'LinKin Posted June 14, 2014 Share Posted June 14, 2014 Hello, I'm using onPlayerChangeNick event in a script, but apart from this script, I've another one which uses the same event to check if a player has changed his nick more than 3 times in 30 secs, if he changes his nick more than 3 times within 30 secs, it cancels the event, so the nick is not changed. But, on the script I'm working on, how can I check if the event was cancelled by another script? I've this, but it doesn't work. addEventHandler("onPlayerChangeNick", root, function() if wasEventCancelled() then outputChatBox("Cancelled") end end) Thanks. Link to comment
MIKI785 Posted June 14, 2014 Share Posted June 14, 2014 Try this: addEventHandler("onPlayerChangeNick", root, function() if wasEventCancelled() then outputChatBox("Cancelled") end end, true, "low") The last argument sets the handler's priority to low so this piece of code should get called after the other one where you cancelled the event. Link to comment
'LinKin Posted June 14, 2014 Author Share Posted June 14, 2014 Doesn't work either. I also tried to set its priority to low-1 but still the same. Link to comment
MIKI785 Posted June 14, 2014 Share Posted June 14, 2014 Well then the simplest solution is to combine the scripts together so you don't have to use wasEventCancelled. Link to comment
'LinKin Posted June 15, 2014 Author Share Posted June 15, 2014 Yes, but that kinda sucks because it doesn't make the script be independent. Another solution would be to check if the player's nick actually changed. Maybe by using a timer. Just wondering why wasEventCancelled apparently doesn't work. Link to comment
pa3ck Posted June 15, 2014 Share Posted June 15, 2014 Maybe you could check oldNick against the current name of the player? Link to comment
'LinKin Posted June 15, 2014 Author Share Posted June 15, 2014 Do you mean the oldNick and newNick parameters that are passed from onPlayerChangeNick event? They would still be different. So it doesn't work! Link to comment
'LinKin Posted June 15, 2014 Author Share Posted June 15, 2014 I was just trying and I found another possible solution: addEventHandler("onPlayerChangeNick", root, function (oldNick, newNick) setTimer(function() if wasEventCancelled() then outputChatBox("Was Cancelled!") return end end, 500, 1) end) It works! But guys I've one question, how does the script know that I'm ONLY asking if the onPlayerChangeNick event was cancelled? Is it because it's inside of the same event? Link to comment
MIKI785 Posted June 15, 2014 Share Posted June 15, 2014 I think so, it works the same way as cancelEvent. Link to comment
cheez3d Posted June 15, 2014 Share Posted June 15, 2014 I was just trying and I found another possible solution:It works! But guys I've one question, how does the script know that I'm ONLY asking if the onPlayerChangeNick event was cancelled? Is it because it's inside of the same event? This function checks if the last completed event was cancelled. 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