if (player.getX() == x coords && player.getY() == Y coords && player.getPlane() == plane) {
//do something
}
|
how to make it so if your on a particular x and y tile + 3 tiles around the player then it does something for 5secs and then stop? or if the player runs away from the tile then also it would stop?
if (player.getX() == x coords && player.getY() == Y coords && player.getPlane() == plane) {
//do something
}
ty but hw to make it constantly do the same thing until the player is no longer in that coords? and also a time limit so for example after 5 secs being in those coords, it will stop doing something OR if a player leaves those coords then also it will stop doing something
Find the tick processing method and add the check there.
hmm here i will try to explain
I want to make it so where the player, to check if the player is at that tile and to +3 to x and y coords of the starting point of the player, and if the player is in that area coords then the server will do something, but if not then it will stop doing something and if a new player enters those coords then it will do that something. i too want it to last for a short time limit like 7secs?
in short, i want to make it check if the player is in those x, y's , then
//do something,
if the player has left the x, y's coords then stop what the server is doing
and if the player re-enters the same x'y's coords then again it will
//do something
But the x and y checks should be stopped after 7sec, so that after 7secs if a player goes to that coords,, it won't do anything
Well, you could create some kind of a variable like an int or something, lets say "public int number = 0;"
Then, in the tick processing method, add the region check, and if number (the variable) has a value over 0, it will be decreased by 1 each tick, and if the value is over 0, the actions will be processed.
However, if the player is in the area, but the value of the variable "number" is 0, it will be set to (for example) 10. This means the actions would be processed for 10 ticks. You could also add a check to make sure,
that if the person is not standing in the area, the variable would be set to 0.
You should also create some kind of a check to make sure if the variable was just decreased from 1 to 0, so it wont go straight up to 10 again and keep doing stuff all over again.
nvm just noticed tht it requires me to make it final and i cant make my current variable final... ty for help tho
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |