Clickable links in chat

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

JamiePlaysMinecraft

New Member
Apr 5, 2024
8
0
1
Hi, I'm trying to make a skript where i can put a url in the chat and it can be clicked.
This is the code i have so far:

Code:
function link(text:text) :: text:
    return {_text}.replaceAll("(https://[a-zA-Z0-9./]{10})", "<link:$1><##84E9FF>&n$1&r<reset>")


function chatFormat(p: player):
    set {playerprefix::%{_p}%'s uuid} to colorFormat({_p}'s prefix)
    set {playersuffix::%{_p}%'s uuid} to colorFormat({_p}'s suffix)
    set {message} to link({message})
    if {_p} has permission "jevents.colors":
        broadcast formatted "%{playerprefix::%{_p}%'s uuid}%%{_p}'s name%%{playersuffix::%{_p}%'s uuid}%&f: %{message}%"
    else:
        broadcast "%coloured {playerprefix::%{_p}%'s uuid}%%coloured {_p}'s name%%coloured {playersuffix::%{_p}%'s uuid}%&f: %{message}%"


function colorFormat(text:text) :: text:
    return {_text}.replaceAll("&##([a-fA-F0-9]{6})", "<##$1>")

on chat:
    cancel event
        set {message} to message
        chatFormat(player)

at the moment, this code can only do links of 10 characters after the "https://"
does anyone know how i can make this code work with links of any length
 
Looks like you already used that format in your first function, but yeah it should still be clickable in chat with literally just that.

I also advise you change some of the variables in your functions to be local, or just...use set chat format to "%player's prefix%%player%%player's suffix%&f: %message%"