Killnear

Discussion in 'Plugin Requests' started by kirbsrob, May 28, 2016.

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

    kirbsrob

    I would like a plugin that when typing /kn kill will kill the closest player to a configured point like x:0.0, y:0.0 and z:0.0





    Configurations:

    world-name-here:
    __coordinates:
    ____x:
    0
    ____y: 63
    ____z: 0
    __enable-y-axis: true
    __# This toggles whether or not /killnear will check the player's y-axis to see if he's closest

    multiple-worlds-are-also-allowed:
    __coordinates:
    ____x: 300
    ____y: 63
    ____z: 200
    __enable-y-axis: false



    Math for enable-y-axis: true:

    x = playerX - configuredX
    y = playerY - configuredY
    z = playerZ - configuredZ

    all = x^2 + y^2 + z^2

    distance = √all






    Math for enable-y-axis: false:

    x = playerX - configuredX
    z = playerZ - configuredZ

    all = x^2 + z^2

    distance = √all








    The player with the lowest distance value gets killed.

    Bob's distance: 100 - not killed
    Carl's distance: 80 - not killed
    Jeff's distance: 40 - KILLED









    Commands:

    /kn kill - kills the player closest to a configured point
    /kn reload - reloads the config file
    /kn <world[optional]> setpoint <x> <y> <z>
    /kn <world[optional]> toggleyaxis
    /kn info <world[optional]>
    /kn help




    Permissions:

    killnear.admin.reload - reloads the killnear config file
    killnear.admin.setpoint - lets the player set the area
    killnear.admin.toggleyaxis - lets the player toggle y axis checking
    killnear.use - lets the player use /killnear
    killnear.bypass - makes it so the player doesn't get affected by /killnear
    killnear.help - brings up a help menu for killnear commands
    killnear.info - brings up information about the world's killnear configurations such as the killnear point coordinates and whether or not y-axis-checking is enabled or disabled
     
    Last edited: May 29, 2016
  2. Offline

    kirbsrob

  3. Offline

    jokie666

    What happens if 2 players have the same distance, kill them both?

    Why don't just use

    x = playerX - configuredX
    y = playerY - configuredY
    z = playerZ - configuredZ

    all = x^2 + y^2 + z^2

    distance = √all

    Short version:
    qrt[ (x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2 ]


    instead of your formule?
    it is easier to implement and I think it is more logical.
     
    Last edited: May 29, 2016
  4. Offline

    kirbsrob

    @jokie666
    Perhaps it could randomly choose which player dies?

    Also, good point about the math.
     
  5. Offline

    timtower Administrator Administrator Moderator

    @jokie666 Bukkit also has a distance method.
    And how big is the chance that 2 players are at exactly the same distance?
     
    jokie666 likes this.
  6. Offline

    kirbsrob

    @timtower
    Highly unlikely, but it's good to be extra safe and add a random kill method if two players are the exact same distance away from the set point.
     
  7. Offline

    jokie666

    @timtower I noticed the distance method of bukkit and it is fine to use it when the y axis is enabled. If the y axis is disabled I need to modify it slightly. I only put the math there to explain how it would be calculated :)

    The chance of 2 players having the same distance is small and it wouldn't break the plugin. I just got teached to think about possible errors before starting programming

    @kirbsrob here you go, it should work. I only have 1 minecraft account to test with but reply to me if there are any bugs
    https://www.dropbox.com/s/ndryqnl31urito1/KillNear.jar?dl=0
     
    Last edited: May 30, 2016
  8. Offline

    jokie666

    is it oke if I upload the plugin to bukkitdev?
     
  9. Offline

    kirbsrob

    jokie666 likes this.
Thread Status:
Not open for further replies.

Share This Page