Jump to content

wasEventCancelled


'LinKin

Recommended Posts

Posted

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.

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

Posted

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.

Lua Scripter

?ucet=miki_cz

Owner of mshost.cz MTA portal.

Posted

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.

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

Posted

Do you mean the oldNick and newNick parameters that are passed from onPlayerChangeNick event?

They would still be different. So it doesn't work!

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

Posted

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?

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

Posted
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.

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...