Jump to content

Získání jména s discord tagem


Isigar

Recommended Posts

Přikladám malou funkci, která je užitečná pro získání jména hráče plus mít tag na uživatele.

function findDiscordIdentifier(source)
    local discordId
    for _, id in ipairs(GetPlayerIdentifiers(source)) do
        if string.match(id, "discord:") then
            discordId = string.gsub(id, "discord:", "")
        end
    end
    return discordId
end

function getNameWithDiscordTag(playerId)
    local discordLicense = findDiscordIdentifier(playerId)
    if discordLicense then
        return string.format('%s <@%s>', GetPlayerName(playerId), discordLicense)
    end

    return GetPlayerName(playerId)
end

Vrací textový řetězec ve formátu SteamJméno <@DISCORD_ID> čili například Isigar <@DISCORD_ID> pak to na discordu vypadá takto 
image.png.e6fa42c8c5aa45b5f85637c5e67bd3f9.png

  • Thanks 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...