[Urgent] Hiding a player within a radius

Discussion in 'Plugin Development' started by kreashenz, Feb 15, 2013.

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

    kreashenz

    I need help using vectors and inAABB.. I have read through the JavaDocs, so do not post that as ' read this ' I just completely don't understand.. If anyone is willing to help, post in the comments or pm me, please. I really need this soon to release the next version of Kreas-Kits. Thanks.
     
  2. Offline

    chasechocolate

    What do you need help with? Be more specific.
     
  3. Offline

    kreashenz

    chasechocolate
    I need help with getting a player to disappear after they are out of the inAABB radius. This is done by vectors, I believe, and I do not know how to do this. Basically when they are OUT of the radius, they are invisible, and when they are IN the radius, the are visible and can be seen..
     
  4. Offline

    kreashenz

    Bump this up :p
     
  5. Offline

    SoThatsIt

    couldn't you just get the distance from the point to the player and check if it is less than the radius and if it is hsow the player.
     
  6. Offline

    kreashenz

    That's basically what I'm trying to get help for.. Its with vectors, I'm sure you can't do it any other way..
     
  7. Offline

    SoThatsIt

    Code:
    Location yourLocation;
    int distance = yourLocation.distance(player.getLocation());
     
  8. Offline

    kreashenz

    SoThatsIt that gets their player location, but doesn't actually hide the player.
     
  9. Offline

    SoThatsIt

    oh, i dont know how to hide the player... maybe theres an api for it somewhere
     
  10. Offline

    chasechocolate

    kreashenz SoThatsIt
    Code:java
    1. for(Player online : Bukkit.getOnlinePlayers()){
    2. online.hidePlayer(player);
    3. }

    This will make every player on the server not be able to see the player "player".
     
  11. Offline

    kreashenz

    chasechocolate what about making them be seen in the radius.. That would be the inAABB concept, wouldn't it ?
     
  12. Offline

    kreashenz

    Bump, this is needed VERY soon. I've been spending a while looking for this, and getting codes and trying many, many different things, and I still cant find it.. I need how to get the radius of the player.
     
  13. Offline

    molenzwiebel

    Code:java
    1.  
    2. for (Player p1 : Bukkit.getOnlinePlayers()) {
    3. for (Player p2 : Bukkit.getOnlinePlayers()) {
    4. if (p1.getLocation().distance(p2.getLocation()) > radius) {
    5. p2.hidePlayer(p1);
    6. } else {
    7. p2.showPlayer(p1);
    8. }
    9. }
    10. }
     
  14. Offline

    -_Husky_-

    Code:java
    1. List<Entity> around = p.getNearbyEntities(30,30,30);
    2. Player s = null; // for now.
    3. for(Entity ent : around) {
    4. if(ent instanceof CraftPlayer) {
    5. s = (Player) ent;
    6. }
    7. }
    8. if(s != null) {s.hidePlayer(p);}


    Code:java
    1. List<Entity> around = p.getNearbyEntities(30,30,30);

    Being the radius in all directions.
     
  15. ya could add a potion effect to the player if he is in radius (potioneffecttype.invisibility)
     
  16. Offline

    -_Husky_-

    That doesn't hide his armour / iteminhand.

    hidePlayer(Player arg) would :)
     
  17. Offline

    kreashenz

    -_Husky_- goodstuff20 Where would I put these, and which one would work better, and how would I link it to a command, ( Only 1 of the kits I would like to have it on )
     
  18. Offline

    -_Husky_-

    Mine can be pasted into the command outright. No need to do anything else, you may have to add the craftbukkit to your build path.
     
  19. Offline

    kreashenz

    -_Husky_- Doesn't work.. I don't know why, but its not hiding the player.
     
  20. Offline

    Lolmewn

    It would be useful to see what code you're using...
     
    -_Husky_- likes this.
  21. well mine is easy but as said it doesent hide armor - just type in the command where ya want player.addPotionEffect(new potionEffect(potionEffectType.INVISIBILITY, time, 1));
     
  22. Offline

    kreashenz

    Lolmewn -_Husky_- .. hush xD This is the ninja ( assassin ) kit here.
    Code:java
    1.  
    2. else if (args[0].equalsIgnoreCase("ninja")) {
    3. if (sender instanceof Player) {
    4. if (sender.hasPermission("kkit.ninja")) {
    5. Player player = (Player)sender;
    6. PlayerInventory pi = player.getInventory();
    7. pi.clear();
    8. pi.setArmorContents(null);
    9. Bukkit.getServer().getScheduler().cancelAllTasks();
    10. for (PotionEffect effect : player.getActivePotionEffects()) {
    11. player.removePotionEffect(effect.getType());
    12. }
    13. List<Entity> around = player.getNearbyEntities(13,13,13);
    14. for(Entity ent : around) {
    15. player = (Player) ent;
    16. if(player != null) {
    17. player.hidePlayer(player);}
    18. ItemStack gethelmet = new ItemStack(Material.GOLD_HELMET, 64);
    19. gethelmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    20. ItemStack getchestplate = new ItemStack(Material.GOLD_CHESTPLATE, 64);
    21. getchestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    22. ItemStack getleggings = new ItemStack(Material.GOLD_LEGGINGS, 64);
    23. getleggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    24. ItemStack getboots = new ItemStack(Material.GOLD_BOOTS, 64);
    25. getboots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
    26. getboots.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 9);
    27. ItemStack getsword = new ItemStack(Material.IRON_SWORD);
    28. getsword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
    29. ItemMeta iSword = (ItemMeta)getsword.getItemMeta();
    30. iSword.setDisplayName("Sharpened Knife");
    31. getsword.setItemMeta(iSword);
    32. pi.setHelmet(gethelmet);
    33. pi.setChestplate(getchestplate);
    34. pi.setLeggings(getleggings);
    35. pi.setBoots(getboots);
    36. pi.addItem(getsword);
    37. ItemStack getSoup = new ItemStack(Material.MUSHROOM_SOUP, 1);
    38. player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 18000, 0));
    39. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 2400000, 4));
    40. for(int i=1; i <=34; i++)
    41. pi.addItem(getSoup);
    42. sender.sendMessage(prefix + Ninja);
    43. }
    44. } else sender.sendMessage(prefix + MustBePlayer);
    45. } else sender.sendMessage(prefix + NoPerm);
    46. }


    In that code ^^^^^^ It has stacked armour, because I don't know how to set infinite durability. Lol.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  23. Offline

    -_Husky_-

    Is there a player within 13 blocks?
     
  24. Offline

    kreashenz

    -_Husky_- Yes, my radar said about 41, and he still didn't disappear.
     
  25. Offline

    -_Husky_-

    Ok, for starters.

    You're trying to hide the player from himself (in the code, thats exactly what you are doing.)

    Try using my original code, and paste it (changing the radius ofc).

    Also, my code hides them within the radius, let me append the changes.
     
  26. Offline

    kreashenz

    -_Husky_- Uhh, that is EXACTLY what I did.. It had an error under CraftPlayer, and it didn't have a fix, just said cannot resolve a variable.
     
  27. Offline

    -_Husky_-

    New code, works now.

    Import the server version of craftbukkit, I noted that up a little.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  28. Offline

    molenzwiebel

    Try using my code, note that both mine and Husky's version need to be run in a scheder to effectively work. If you decide to go with his version, please note that is will probably need the craftbukkit.jar
     
    -_Husky_- likes this.
  29. Offline

    kreashenz

    -_Husky_- So the actual server craftbukkit, is what I import now?
     
    -_Husky_- likes this.
  30. Offline

    -_Husky_-

    It will still work, but it's not optimized outside a scheduler, you are correct there. :p

    Using the code outside a scheduler on larger servers is not a great idea. As .getNearbyEntities, loops the server checking locations in coord to the checkee.
     
Thread Status:
Not open for further replies.

Share This Page