Files
locatorbar.sk
Code
1 162
locatorbar.sk
# Standalone Locator Bar (SkBee Required)
# Shows nearby player locations in action bar
# Version: 1.0
options:
prefix: &6[LocatorBar]&r
max-distance: 100
update-interval: 10 # ticks (10 = 0.5 seconds)
# Distance color thresholds
close-range: 20
medium-range: 50
# Colors
close-color: &c
medium-color: &e
far-color: &a
direction-color: &7
# Global toggle variable
on script load:
if {locatorbar.enabled} is not set:
set {locatorbar.enabled} to false
send "{@prefix} Script loaded! Status: %{locatorbar.enabled}%" to console
# Main loop - runs when enabled
every {@update-interval} ticks:
if {locatorbar.enabled} is true:
loop all players:
set {_viewer} to loop-player
set {_message} to ""
set {_count} to 0
# Find all nearby players
loop all players:
set {_target} to loop-player-2
# Skip self and check same world
if {_viewer} is not {_target}:
if world of {_viewer} is world of {_target}:
set {_dist} to distance between {_viewer} and {_target}
if {_dist} <= {@max-distance}:
# Calculate direction
set {_direction} to getDirection({_viewer}, {_target})
# Round distance
set {_dist} to round({_dist})
# Color based on distance
if {_dist} <= {@close-range}:
set {_color} to "{@close-color}"
else if {_dist} <= {@medium-range}:
set {_color} to "{@medium-color}"
else:
set {_color} to "{@far-color}"
# Build entry
set {_entry} to "{@direction-color}%{_direction}% %{_color}%%name of {_target}% &7(%{_dist}%m&7)"
# Add to message
if {_count} is 0:
set {_message} to {_entry}
else:
set {_message} to "%{_message}% &8| %{_entry}%"
add 1 to {_count}
# Limit to prevent overflow (supports 14+ players easily)
if {_count} >= 15:
exit loop
# Send action bar
if {_message} is not "":
send action bar {_message} to {_viewer}
# Function to calculate 8-point direction
function getDirection(p: player, t: player) :: text:
# Get yaw difference
set {_pYaw} to yaw of {_p}
set {_pLoc} to location of {_p}
set {_tLoc} to location of {_t}
# Calculate angle to target
set {_dx} to x-coordinate of {_tLoc} - x-coordinate of {_pLoc}
set {_dz} to z-coordinate of {_tLoc} - z-coordinate of {_pLoc}
# Calculate bearing (0-360)
set {_angle} to atan2({_dx}, {_dz})
set {_angle} to {_angle} * 180 / pi
# Adjust for player's yaw
set {_relative} to {_angle} - {_pYaw}
# Normalize to 0-360
while {_relative} < 0:
add 360 to {_relative}
while {_relative} >= 360:
remove 360 from {_relative}
# Convert to 8-point compass
if {_relative} >= 337.5:
return "⬆ N"
else if {_relative} >= 292.5:
return "⬉ NW"
else if {_relative} >= 247.5:
return "⬅ W"
else if {_relative} >= 202.5:
return "⬋ SW"
else if {_relative} >= 157.5:
return "⬇ S"
else if {_relative} >= 112.5:
return "⬊ SE"
else if {_relative} >= 67.5:
return "âž¡ E"
else if {_relative} >= 22.5:
return "⬈ NE"
else:
return "⬆ N"
# Admin command to toggle globally
command /locator [<text>]:
permission: locatorbar.admin
permission message: {@prefix} &cYou don't have permission!
trigger:
if arg-1 is not set:
if {locatorbar.enabled} is true:
set {locatorbar.enabled} to false
broadcast "{@prefix} &cLocator Bar DISABLED"
else:
set {locatorbar.enabled} to true
broadcast "{@prefix} &aLocator Bar ENABLED"
else if arg-1 is "on" or "enable":
set {locatorbar.enabled} to true
broadcast "{@prefix} &aLocator Bar ENABLED"
else if arg-1 is "off" or "disable":
set {locatorbar.enabled} to false
broadcast "{@prefix} &cLocator Bar DISABLED"
# Clear all action bars
loop all players:
send action bar "" to loop-player
else if arg-1 is "status":
send "{@prefix} Status: %{locatorbar.enabled}%" to player
else:
send "{@prefix} &eUsage:" to player
send "&7/locator &f- Toggle on/off" to player
send "&7/locator on/off &f- Set state" to player
send "&7/locator status &f- Check status" to player
# Helper command for testing
command /locatortest:
permission: locatorbar.admin
trigger:
send "{@prefix} &eDebug Info:" to player
send "&7Enabled: %{locatorbar.enabled}%" to player
send "&7Players online: %number of all players%" to player
send "&7Your world: %world of player%" to player