[Help] OnPlayerMoveEvent

Discussion in 'Plugin Development' started by CubixCoders, Aug 17, 2012.

  1. Offline

    CubixCoders

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I just wanted to know how to "Capture a flag" in my plugin. What i want it to do is when they run below their teams flag, and if they have the enemies flag.. then it sends them a message like "You scored!" and to clear their inventory.. This is the last thing i need to work on for my plugin but i cant get it to work! Please help!
  2. Online

    Jogy34

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    you could record the locations of their 'base' and then crosscheck those with the block location of the player in a PlayerMoveEvent. Using a PlayerMoveEvent can be risky because it can be called hundreds of times a second. You would want to limit how much code it goes through with like checking if the player has a flag before anything else or something to really limit what is calculated in each run through.
  3. Offline

    CubixCoders

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I saved the location of the flag in the config then used
    Code:java
    1.  
    2. if(player.getLocation.equals(new Location(player.getWorld(), plugin.getConfig().getInt("Location.Flag.X"),
    3. plugin.getConfig().getInt("Location.Flag.Y") - 1,
    4. plugin.getConfig().getInt("Location.Flag.Z"){
    5. //rest of my code here
    6. }
    7.  

    This post has been edited 1 time. It was last edited by CubixCoders Aug 17, 2012.
  4. Offline

    travja

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    You'd need to check if the player's location is the same as the flags x,z coords.
  5. Offline

    CubixCoders

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    still isnt working..
  6. Online

    evilmidget38 BukkitDev Staff

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    You should check if they're within a certain amount, getting the numbers to line up perfectly would be unlikely.
  7. Offline

    travja

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    That's true...
  8. Online

    Jogy34

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    If you want to check if a player stepped on a certain block then you can just get the block under them and check the location of that block with the location of the block that you want them to step on
  9. Offline

    CubixCoders

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    How would i do that?
  10. Online

    Jogy34

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Something like this:
    Code:
    Location pLoc = plater.getLocation().getBlock().getLocation().subtract(0, 1, 0);
    Location bLoc = LocationOfNeededBlock;
     
    if(pLoc == bLoc)
    {
        //remove flag and do whatever else you have to
    }

Share This Page