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

bWolfie

I'm the man
Messages
850
Points
0
Location
Alberta, Midgard
Github
bWolfie
Emulator
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)

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

Rynbef~

 
Last edited by a moderator:
*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;

 
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

 
Back
Top