Jump to content
  • 0
bWolfie

How to send a "close()" after "disablenpc()"

Question

So I have a NPC script which uses disablenpc() on a timer. Players are able to interact with the NPC while it is active. The NPC uses mes().

 

If a player is talking to the NPC while the disablenpc() is triggered, the will become stuck on the mes() screen, and will need to logout or warp away using @load or something similar to get out of it.

 

My query: When disablenpc() is triggered, how can I send close() to everyone currently talking to that NPC?

(sorry haven't updated my source for a bit, this may already exist in new versions)

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 1

When the npc is already disabled u can't send close(). U need to send it previously like using a timer.

 

Rynbef~

Edited by Rynbef

Share this post


Link to post
Share on other sites
  • -1
*close2()

This command will create a 'close' button in the message window for the
invoking character. WARNING: If no window is currently on screen, the
script execution will halt indefinitely! See 'close'. There is one
important difference, though - even though the message box will have
closed, the script execution will not stop, and commands after 'close2'
will still run, meaning an 'end' has to be used to stop the script, unless
you make it stop in some other manner.

    mes("[Woman]");
    mes("I will warp you now.");
    close2();
    warp("place", 50, 50);
    end;

Don't expect things to run smoothly if you don't make your scripts 'end'.

close2

disablenpc

end;

Share this post


Link to post
Share on other sites
  • 0

I have several scripts like this that run on timers. For example claw machines and other events. 

If you use disablenpc you cannot interact with the NPC at all, if you don't absolutely need to disable the NPC, you can just use a variable instead of disablenpc.

Set variabe to 0 when timer runs out and set it to 1 when the event gets activated, and then if variable = 0, when players click on it, it says that the event is disabled. You can then place if statents in key portions of the script using this variable to prevent people from using the npc while the event is off.

With this setup, you can use the hideonnpc script command to even hide the npc sprite.

Hope this helps, if you need more direct help send me a pm

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.