Checking if player has run through polygon?

Discussion in 'Plugin Development' started by boolean, May 24, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    boolean

    So I'm working on this plugin where I want players to walk/run down a path. I want to check their progress to see who's in first place, second, third, ect...

    Now I was thinking having checkpoints that admins set along the path and just run block listeners on them, but that'd be resource intensive with 50+ people on a server all doing it...

    What's the best option?
     
  2. Offline

    chasechocolate

    Lol, "boolean" :p anyways, I think that the best (and less resource intensive) way to do it would be to use checkpoints. I mean, if you have a good enough server/computer to host 50 players, it probably won't increase in lag that much.
     
    boolean likes this.
  3. Offline

    Tzeentchful

    boolean
    The best way would to be to hook into the NMS code that handles block collision and use that to detect when they run over/though a particular block. There is a tutorial on how to do it here.
     
  4. Offline

    boolean


    While I like that idea, I feel like it's not the best way because as someone stated in a reply, they change the methods, so that would mean constant updating of methods and finding them.

    Still looking for another way of doing this :)
     
  5. Offline

    Tzeentchful

    boolean
    Well you could use the PlayerMoveEvent and check to see if they are moving into a certain area.
    Not the most efficient option but it would be the easiest.
     
  6. Offline

    boolean


    Seeing as how only certain players would be running the track at a time, I can just only run the playermoveevent on players racing? right?
     
  7. Offline

    Tzeentchful

    boolean
    Yea. Just store their names in a list and on the move event just check if their name is in the list or not.
    Another way I though of is to have nether portal block the players have to run though and then simply listen for PlayerPortalEvent and check to see what portal they ran through.
     
  8. Offline

    boolean


    This wouldn't work, I was thinking of having like 20 checkpoints along a course, then a finish line, so it wouldn't make sense you know?
     
  9. Offline

    icomputertinker

    Something like this could be built using redstone... Just sayin'...
     
  10. Offline

    boolean


    Alright... but that's not what I want... at all.. haha
     
  11. Offline

    JoTyler

    Im also trying to do this on my PigRacers plugin for the finish line.
     
  12. Offline

    ZeusAllMighty11

    I did this a pretty cheap way:

    1) On the edges, place trip wires
    2) Detect BlockRedstoneEvent
    3) If the source is tripwire, get the player who closest to (or inside) it, then do stuffs
     
  13. Offline

    boolean


    The only reason this wouldn't work is due to the fact that I need multiple checkpoints. So say there are 20 checkpoints along the track, how would you know which one the player is at? You know?

    I think I am going to simply use a onPlayerMove listener that only listens to players currently racing.
     
Thread Status:
Not open for further replies.

Share This Page