Here's an enhanced version with clickable names using a dialog menu system, showing location and distance:
// RLV Relay Detector HUD v2.0
// Enhanced with clickable names, location display, and distance tracking
// Constants
integer RLV_RELAY_CHANNEL = -1812221819;
float SCAN_RANGE = 20.0;
float SCAN_INTERVAL = 3.0;
float PING_TIMEOUT = 2.0;
integer DIALOG_CHANNEL;
integer DIALOG_TIMEOUT = 30;
// Variables
list detected_relays = []; // [uuid, name, location, uuid, name, location, ...]
list pending_pings = []; // [uuid, timestamp, uuid, timestamp, ...]
integer listen_handle;
integer dialog_handle;
integer display_on = TRUE;
key selected_avatar;
// Display colors
vector COLOR_HEADER = <0.0, 1.0, 0.0>;
vector COLOR_DETECTED = <1.0, 1.0, 1.0>;
vector COLOR_NONE = <0.5, 0.5, 0.5>;
// Functions
string get_location_name(vector pos)
{
// Get parcel name at position
list details = llGetParcelDetails(pos, [PARCEL_DETAILS_NAME]);
string parcel = llList2String(details, 0);
if (parcel == "") parcel = "Unknown Location";
// Truncate if too long
if (llStringLength(parcel) > 20)
parcel = llGetSubString(parcel, 0, 17) + "...";
return parcel;
}
update_display()
{
if (!display_on)
{
llSetText("", <1,1,1>, 0.0);
return;
}
string display = "=== RLV Relay Detector ===\n";
display += "Range: " + (string)((integer)SCAN_RANGE) + "m | ";
integer count = llGetListLength(detected_relays) / 3;
display += "Found: " + (string)count + "\n";
if (count == 0)
{
display += "No RLV relays detected\n";
display += "TOUCH for options";
llSetText(display, COLOR_NONE, 1.0);
}
else
{
display += "─────────────────────\n";
display += "TOUCH to see avatar list\n";
display += "─────────────────────\n";
integer i;
integer shown = 0;
for (i = 0; i < llGetListLength(detected_relays) && shown < 5; i += 3)
{
string name = llList2String(detected_relays, i + 1);
string location = llList2String(detected_relays, i + 2);
// Get distance
key uuid = llList2Key(detected_relays, i);
vector avatar_pos = llList2Vector(llGetObjectDetails(uuid, [OBJECT_POS]), 0);
float distance = llVecDist(llGetPos(), avatar_pos);
display += "• " + name + " (" + (string)((integer)distance) + "m)\n";
shown++;
}
if (count > 5)
{
display += "... +" + (string)(count - 5) + " more (touch for full list)";
}
llSetText(display, COLOR_DETECTED, 1.0);
}
}
show_avatar_menu()
{
integer count = llGetListLength(detected_relays) / 3;
if (count == 0)
{
llDialog(llGetOwner(), "No avatars with RLV relays detected.\n\nOptions:",
["Refresh", "Range +", "Range -", "Close"], DIALOG_CHANNEL);
return;
}
list buttons = [];
string message = "Select avatar to see details:\n\n";
integer i;
integer num = 1;
for (i = 0; i < llGetListLength(detected_relays) && num <= 9; i += 3)
{
string name = llList2String(detected_relays, i + 1);
key uuid = llList2Key(detected_relays, i);
// Get distance
vector avatar_pos = llList2Vector(llGetObjectDetails(uuid, [OBJECT_POS]), 0);
float distance = llVecDist(llGetPos(), avatar_pos);
buttons += [(string)num];
message += (string)num + ". " + name + " (" + (string)((integer)distance) + "m)\n";
num++;
}
// Add navigation buttons
buttons += ["Options", "Refresh", "Close"];
llDialog(llGetOwner(), message, buttons, DIALOG_CHANNEL);
}
show_avatar_details(integer index)
{
if (index < 0 || index * 3 >= llGetListLength(detected_relays)) return;
key uuid = llList2Key(detected_relays, index * 3);
string name = llList2String(detected_relays, index * 3 + 1);
string location = llList2String(detected_relays, index * 3 + 2);
selected_avatar = uuid;
// Get current details
list details = llGetObjectDetails(uuid, [OBJECT_POS, OBJECT_VELOCITY]);
vector pos = llList2Vector(details, 0);
vector vel = llList2Vector(details, 1);
float distance = llVecDist(llGetPos(), pos);
float speed = llVecMag(vel);
string message = "AVATAR: " + name + "\n";
message += "UUID: " + (string)uuid + "\n\n";
message += "Location: " + location + "\n";
message += "Position: " + (string)((integer)pos.x) + ", " + (string)((integer)pos.y) + ", " + (string)((integer)pos.z) + "\n";
message += "Distance: " + (string)((integer)distance) + " meters\n";
message += "Speed: " + (string)((integer)(speed * 3.6)) + " km/h\n\n";
message += "RLV Relay: ACTIVE";
llDialog(llGetOwner(), message, ["IM Avatar", "Teleport", "< Back", "Close"], DIALOG_CHANNEL);
}
show_options_menu()
{
string message = "RLV Relay Detector Options\n\n";
message += "Current Range: " + (string)((integer)SCAN_RANGE) + " meters\n";
message += "Detected: " + (string)(llGetListLength(detected_relays) / 3) + " avatars\n\n";
list buttons = ["Range +", "Range -", "Clear List", "< Back", "About", "Close"];
llDialog(llGetOwner(), message, buttons, DIALOG_CHANNEL);
}
clean_pending_pings()
{
float current_time = llGetTime();
list new_pending = [];
integer i;
for (i = 0; i < llGetListLength(pending_pings); i += 2)
{
key uuid = llList2Key(pending_pings, i);
float ping_time = llList2Float(pending_pings, i + 1);
if (current_time - ping_time < PING_TIMEOUT)
{
new_pending += [uuid, ping_time];
}
}
pending_pings = new_pending;
}
send_relay_ping(key avatar)
{
integer idx = llListFindList(pending_pings, [avatar]);
if (idx != -1) return;
string relay_msg = "ping," + (string)llGetKey() + ",ping,ping";
llRegionSayTo(avatar, RLV_RELAY_CHANNEL, relay_msg);
pending_pings += [avatar, llGetTime()];
}
default
{
state_entry()
{
DIALOG_CHANNEL = -1 * (integer)("0x" + llGetSubString((string)llGetKey(), -7, -1));
if (llGetAttached() == 0)
{
llOwnerSay("Please attach this as a HUD for proper operation.");
}
listen_handle = llListen(RLV_RELAY_CHANNEL, "", NULL_KEY, "");
update_display();
llSetTimerEvent(SCAN_INTERVAL);
llOwnerSay("RLV Relay Detector HUD v2.0 activated.\nTouch for avatar list and options.");
}
attach(key id)
{
if (id)
{
llResetScript();
}
else
{
llSetTimerEvent(0.0);
llListenRemove(listen_handle);
llListenRemove(dialog_handle);
}
}
touch_start(integer total_number)
{
if (llDetectedKey(0) == llGetOwner())
{
llListenRemove(dialog_handle);
dialog_handle = llListen(DIALOG_CHANNEL, "", llGetOwner(), "");
llSetTimerEvent(DIALOG_TIMEOUT);
show_avatar_menu();
}
}
timer()
{
// Check if this is dialog timeout
if (llGetListLength(detected_relays) == 0 || llGetTime() < DIALOG_TIMEOUT)
{
// Regular scan timer
clean_pending_pings();
// Update locations and verify existing detections
list updated_relays = [];
integer i;
for (i = 0; i < llGetListLength(detected_relays); i += 3)
{
key uuid = llList2Key(detected_relays, i);
string name = llList2String(detected_relays, i + 1);
vector avatar_pos = llList2Vector(llGetObjectDetails(uuid, [OBJECT_POS]), 0);
float distance = llVecDist(llGetPos(), avatar_pos);
if (distance <= SCAN_RANGE && avatar_pos != ZERO_VECTOR)
{
string location = get_location_name(avatar_pos);
updated_relays += [uuid, name, location];
}
}
detected_relays = updated_relays;
// Scan for new avatars
llSensor("", NULL_KEY, AGENT, SCAN_RANGE, PI);
update_display();
}
else
{
// Dialog timeout
llListenRemove(dialog_handle);
llSetTimerEvent(SCAN_INTERVAL);
}
}
sensor(integer num_detected)
{
integer i;
for (i = 0; i < num_detected; i++)
{
key avatar = llDetectedKey(i);
if (avatar == llGetOwner()) jump continue;
integer idx = -1;
integer j;
for (j = 0; j < llGetListLength(detected_relays); j += 3)
{
if (llList2Key(detected_relays, j) == avatar)
{
idx = j;
jump found;
}
}
@found;
if (idx == -1)
{
send_relay_ping(avatar);
}
@continue;
}
}
listen(integer channel, string name, key id, string message)
{
if (channel == RLV_RELAY_CHANNEL)
{
list parts = llParseString2List(message, [","], []);
if (llGetListLength(parts) >= 3)
{
string cmd = llList2String(parts, 0);
key source = (key)llList2String(parts, 1);
if (cmd == "ping" && source == llGetKey())
{
key avatar = llGetOwnerKey(id);
if (avatar == llGetOwner()) return;
integer idx = llListFindList(pending_pings, [avatar]);
if (idx != -1)
{
pending_pings = llDeleteSubList(pending_pings, idx, idx + 1);
integer found = FALSE;
integer j;
for (j = 0; j < llGetListLength(detected_relays); j += 3)
{
if (llList2Key(detected_relays, j) == avatar)
{
found = TRUE;
jump skip_add;
}
}
@skip_add;
if (!found)
{
string avatar_name = llKey2Name(avatar);
if (avatar_name == "") avatar_name = "Unknown";
vector avatar_pos = llList2Vector(llGetObjectDetails(avatar, [OBJECT_POS]), 0);
string location = get_location_name(avatar_pos);
detected_relays += [avatar, avatar_name, location];
llOwnerSay("Detected RLV relay: " + avatar_name + " at " + location);
update_display();
}
}
}
}
}
else if (channel == DIALOG_CHANNEL)
{
llListenRemove(dialog_handle);
dialog_handle = llListen(DIALOG_CHANNEL, "", llGetOwner(), "");
llSetTimerEvent(DIALOG_TIMEOUT);
if (message == "Close")
{
llListenRemove(dialog_handle);
llSetTimerEvent(SCAN_INTERVAL);
}
else if (message == "Refresh")
{
llSensor("", NULL_KEY, AGENT, SCAN_RANGE, PI);
show_avatar_menu();
}
else if (message == "< Back")
{
show_avatar_menu();
}
else if (message == "Options")
{
show_options_menu();
}
else if (message == "Range +")
{
SCAN_RANGE += 10.0;
if (SCAN_RANGE > 96.0) SCAN_RANGE = 96.0;
llOwnerSay("Scan range: " + (string)((integer)SCAN_RANGE) + "m");
show_options_menu();
}
else if (message == "Range -")
{
SCAN_RANGE -= 10.0;
if (SCAN_RANGE < 10.0) SCAN_RANGE = 10.0;
llOwnerSay("Scan range: " + (string)((integer)SCAN_RANGE) + "m");
show_options_menu();
}
else if (message == "Clear List")
{
detected_relays = [];
pending_pings = [];
llOwnerSay("Detection list cleared.");
update_display();
show_options_menu();
}
else if (message == "About")
{
llOwnerSay("RLV Relay Detector v2.0\nDetects avatars wearing active RLV relays within range.");
show_options_menu();
}
else if (message == "IM Avatar" && selected_avatar)
{
llInstantMessage(selected_avatar, "Hello! I detected you have an active RLV relay.");
llOwnerSay("IM sent to " + llKey2Name(selected_avatar));
}
else if (message == "Teleport" && selected_avatar)
{
vector pos = llList2Vector(llGetObjectDetails(selected_avatar, [OBJECT_POS]), 0);
llMapDestination(llGetRegionName(), pos, ZERO_VECTOR);
llOwnerSay("Opening map to " + llKey2Name(selected_avatar) + "'s location");
}
else if ((integer)message > 0 && (integer)message <= 9)
{
show_avatar_details((integer)message - 1);
}
}
}
changed(integer change)
{
if (change & CHANGED_OWNER)
{
llResetScript();
}
if (change & CHANGED_TELEPORT)
{
detected_relays = [];
pending_pings = [];
update_display();
}
}
on_rez(integer start_param)
{
llResetScript();
}
}