Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

How to put timer that auto warp out map?

Newbie Spellweaver
Joined
Nov 26, 2015
Messages
61
Reaction score
0
Anyone know what is the commands of timer? For example, i wanted to create a NPC that warp into the map and after 10seconds it will auto warp out me from the map. i have no idea how can anyone gimme the commands?
 
Junior Spellweaver
Joined
Mar 25, 2013
Messages
138
Reaction score
4
okay so that mean after that we put the time in second. and warp map command?

Yes.
You would do something like
if player is in map (mapID)
TimerManager.getInstance().schedule(MovePlayer, 10000);

where moveplayer is your function to move them out of the map via changemap

10000 = 10 seconds (mili)
 
Upvote 0
Newbie Spellweaver
Joined
Nov 26, 2015
Messages
61
Reaction score
0
Yes.
You would do something like
if player is in map (mapID)
TimerManager.getInstance().schedule(MovePlayer, 10000);

where moveplayer is your function to move them out of the map via changemap

10000 = 10 seconds (mili)

i see thanks! if i wanted to add it in like in a command how can i do? do i still need a map edit? for example if im going to make like go to somewhere else maybe like a boot camp and after 60min will auto warp out so what do i need to do? in the command? i dont think the 'player is in map' is needed right
 
Upvote 0
Junior Spellweaver
Joined
Sep 16, 2017
Messages
156
Reaction score
36
If you're going to make it a GM command, you're not gonna need a map edit (assuming with "map edit" you mean adding the NPC that was supposed to carry such function; ofcourse, if the map is a custom map, you're still gonna need it implemented for everyone).

About the "is player in map?" check; you could make the MovePlayer function warp "every player who is in the map", instead of having to check each player's presence.
Note that this also depends on how the bootcamp is supposed to work; for example, I'm assuming that a player who disconnects before the 60 minutes are up, would be warped to a safe location outside, so please make sure to verify this.

So, as an extremely generic idea, what you could do is like

if character is using the bootcamp command {
warp player [or players? depends on the bootcamp nature] to bootcamp map
[code eventual stuff that's needed in bootcamp]
schedule the MovePlayer function 60*60*1000 milliseconds from now [one hour of bootcamp time]
}

[STRIKE]In the same file, then, you will code the MovePlayer function, that will get all the players in the map and warp them one by one to the new location.[/STRIKE]

I coded too much Javascript. TimerManager.getInstance().schedule requires a Runnable as first parameter, so all you'd have to do is code a quick anonymous class by calling the Runnable interface, making sure to override its run() method:
PHP:
TimerManager.getInstance().schedule(new Runnable() {
                @Override
                public void run() {
                    // code to activate when the 60 minutes have passed goes here
                }
            }, 60*60*1000);
Note: in this function, you can also access local variables, provided they were declared as final. So, if you need any variable data you already gathered out of the scheduling function, you can make use of this.
 
Last edited:
Upvote 0
Newbie Spellweaver
Joined
Nov 26, 2015
Messages
61
Reaction score
0
If you're going to make it a GM command, you're not gonna need a map edit (assuming with "map edit" you mean adding the NPC that was supposed to carry such function; ofcourse, if the map is a custom map, you're still gonna need it implemented for everyone).

About the "is player in map?" check; you could make the MovePlayer function warp "every player who is in the map", instead of having to check each player's presence.
Note that this also depends on how the bootcamp is supposed to work; for example, I'm assuming that a player who disconnects before the 60 minutes are up, would be warped to a safe location outside, so please make sure to verify this.

So, as an extremely generic idea, what you could do is like

if character is using the bootcamp command {
warp player [or players? depends on the bootcamp nature] to bootcamp map
[code eventual stuff that's needed in bootcamp]
schedule the MovePlayer function 60*60*1000 milliseconds from now [one hour of bootcamp time]
}

[STRIKE]In the same file, then, you will code the MovePlayer function, that will get all the players in the map and warp them one by one to the new location.[/STRIKE]

I coded too much Javascript. TimerManager.getInstance().schedule requires a Runnable as first parameter, so all you'd have to do is code a quick anonymous class by calling the Runnable interface, making sure to override its run() method:
PHP:
TimerManager.getInstance().schedule(new Runnable() {
                @Override
                public void run() {
                    // code to activate when the 60 minutes have passed goes here
                }
            }, 60*60*1000);
Note: in this function, you can also access local variables, provided they were declared as final. So, if you need any variable data you already gathered out of the scheduling function, you can make use of this.
I see thanks for the detail info tho! i used the function u told me for the commands it seems like it keep rewarp me to the map after that time.

Anyone for example is im making a map like maybe an auto event every player will get warp to the map. and there is 1min time for them to join. after that 1min all player in the map will warp to the event map. so Maybe on 1.00 the event started and 1.01 closed and warp to eventmap. how can i make the map time is exactly same like what player see when they went into the map.
 
Upvote 0
Back
Top