From d3aef549f1efce46bb84e5b0109f260be1ae90ff Mon Sep 17 00:00:00 2001 From: cj89898 Date: Wed, 1 Jul 2020 16:30:52 -0500 Subject: [PATCH] Updated Community Scripts (markdown) --- Community-Scripts.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Community-Scripts.md b/Community-Scripts.md index 1149513..21942ad 100644 --- a/Community-Scripts.md +++ b/Community-Scripts.md @@ -1121,7 +1121,7 @@ number_in_group_of_worlds: * `%javascript_listplayers_all,%` - Matches all players * `%javascript_listplayers_perm,+,%` - Matches all players with the specified permission(s) * `%javascript_listplayers_world,+,%` - Matches all players in specified world(s) -* `%javascript_listplayers_nearby,,%` - Matches all players in a nearby radius +* `%javascript_listplayers_nearby,,%` - Matches all players in a nearby radius. You can also type `,no` after the type to exclude the player. **Types:** * `list` - Returns a list of players separated by `, ` @@ -1132,7 +1132,8 @@ number_in_group_of_worlds: * `%javascript_listplayers_all,list%` - `Tanguygab, cj89898, funnycube, clip` * `%javascript_listplayers_perm,staff.admin,amount%` - `2` * `%javascript_listplayers_world,buildingworld+spawnworld,2%` - `funnycube` -* `%javascript_listplayers_nearby,5,list%` - `Tanguygab, clip` +* `%javascript_listplayers_nearby,5,list%` - `Tanguygab, cj89898, clip` +* `%javascript_listplayers_nearby,5,list,no%` - `Tanguygab, clip` *You can also use `[placeholder]` for papi placeholders in addition to the javascript `{placeholder}`* @@ -1145,7 +1146,6 @@ number_in_group_of_worlds: var args0; var args1; var args2; -var listAll = BukkitServer.getOfflinePlayers(); var listOnline = BukkitServer.getOnlinePlayers(); var listOnlineAmount = listOnline.size(); @@ -1269,8 +1269,15 @@ function onlineListNearby() { var player = listOnline[i]; var zone = args[1]*args[1]; - if (BukkitPlayer.getWorld() == player.getWorld() && BukkitPlayer.getLocation().distanceSquared(player.getLocation()) < zone) { - players.push(player.getName()); + if (args.length >= 4 && args[3] == "no") { + if (BukkitPlayer.getWorld() == player.getWorld() && BukkitPlayer.getLocation().distanceSquared(player.getLocation()) < zone && player.getName() != BukkitPlayer.getName()) { + players.push(player.getName()); + } + } + else { + if (BukkitPlayer.getWorld() == player.getWorld() && BukkitPlayer.getLocation().distanceSquared(player.getLocation()) < zone) { + players.push(player.getName()); + } } } players.sort(); @@ -1314,7 +1321,7 @@ function listPlayers() { //help if (args0 == undefined) { - return " &8>> &3&lValid List Types and Syntaxes:\n &f- &9all&7: &7%"+"javascript_listplayers_all,&9#&7%\n &f- &9perm&7: &7%"+"javascript_listplayers_perm,&9&7,&9#&7%\n &f- &9world&7: &7%"+"javascript_listplayers_world,&9&7,&9#&7%\n&7# can be &9list&7, &9amount&7, or &9a number&7."; + return " &8>> &3&lValid List Types and Syntaxes:\n &f- &9all&7: &7%"+"javascript_listplayers_all,&9#&7%\n &f- &9perm&7: &7%"+"javascript_listplayers_perm,&9&7,&9#&7%\n &f- &9world&7: &7%"+"javascript_listplayers_world,&9&7,&9#&7%\n &f- &9nearby&7: &7%"+"javascript_listplayers_nearby,&9&7,&9#&7%\n&7# can be &9list&7, &9amount&7, or &9a number&7."; } //help all @@ -1332,10 +1339,15 @@ function listPlayers() { return "&4&lError&c: &cInvalid Syntax!\n&7Valid Syntax:\n &f- &b%" + "javascript_listplayers_world,&9&b,&9#&b%\n&7# can be &9list&7, &9amount&7, or &9a number&7."; } + //help nearby + else if (args0 == "nearby" && (args1 == undefined || args2 == undefined)) { + return "&4&lError&c: &cInvalid Syntax!\n&7Valid Syntax:\n &f- &b%" + "javascript_listplayers_nearby,&9&b,&9#&b%\n&7# can be &9list&7, &9amount&7, or &9a number&7.\n'no' can be added as 4th argument to not count you in the list"; + } + //check for errors //check for type else if (args0 != "all" && args0 != "perm" && args0 != "world" && args0 != "nearby" && args0 != "{1}") { - return "&4&lError&c: &cInvalid list type\n&7Valid list types are:\n &f- &ball\n &f- &bperm\n &f- &bworld" + return "&4&lError&c: &cInvalid list type\n&7Valid list types are:\n &f- &ball\n &f- &bperm\n &f- &bworld\n &f- &bnearby" } //check for args2 lower than 0 @@ -1365,7 +1377,7 @@ function listPlayers() { } else { - return "Offline" + BukkitServer.getOfflinePlayers(); + return "Offline" } } listPlayers();