Skip to content

Commit

Permalink
Merge pull request #829 from Gravxd/master
Browse files Browse the repository at this point in the history
feat: add copy discord id button to player menu
  • Loading branch information
Blumlaut authored Mar 15, 2024
2 parents 7dd4bee + 5def053 commit 4c9574f
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 20 deletions.
4 changes: 4 additions & 0 deletions client/admin_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ function unFreezeMe()
end
end

RegisterNetEvent("EasyAdmin:CopyDiscord", function(discord)
copyToClipboard(discord)
end)

RegisterNetEvent("EasyAdmin:requestSpectate", function(playerServerId, playerData)

local localPlayerPed = PlayerPedId()
Expand Down
14 changes: 12 additions & 2 deletions client/gui_c.lua
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,8 @@ function GenerateMenu() -- this is a big ass function
if RedM and not settings.infinity then
thePlayer = {
id = GetPlayerServerId(thePlayer),
name = GetPlayerName(thePlayer)
name = GetPlayerName(thePlayer),
discord = thePlayer.discord,
}
end
local thisPlayerMenu = _menuPool:AddSubMenu(playermanagement,"["..thePlayer.id.."] "..thePlayer.name,"",true)
Expand Down Expand Up @@ -779,7 +780,16 @@ function GenerateMenu() -- this is a big ass function
playermanagement:Visible(true)
end
end


local copyDiscordItem = NativeUI.CreateItem(GetLocalisedText("copydiscord"), "")
thisPlayer:AddItem(copyDiscordItem)
copyDiscordItem.Activated = function(ParentMenu, SelectedItem)
if thePlayer.discord then
copyToClipboard(thePlayer.discord)
else
TriggerEvent("EasyAdmin:showNotification", GetLocalisedText("nodiscordpresent"))
end
end

TriggerEvent("EasyAdmin:BuildPlayerOptions", thePlayer.id)
for i, plugin in pairs(plugins) do
Expand Down
3 changes: 3 additions & 0 deletions language/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
"menuOffsetguide": "Menü länger machen.\nErfordert erneutes öffnen des Adminpanels.",
"resetmenuOffset": "Menüoffset Zurücksetzen",
"takescreenshot": "Screenshot erstellen",
"copydiscord": "Discord-ID kopieren",
"discordcopied": "Discord-ID in die Zwischenablage kopiert.",
"nodiscordpresent": "Keine Discord-ID gefunden.",
"admintookscreenshot": "**%s** hat ein Screenshot von **%s**'s Bildschirm Erstellt: %s",
"screenshotinprogress": "Ein Screenshot wird bereits erstellt, bitte warten!",
"screenshotlink": "Der Screenshot ist hier verfügbar: %s",
Expand Down
3 changes: 3 additions & 0 deletions language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
"menuOffsetguide": "Set Menu Size Offset\nRequires Re-opening of Menu.",
"resetmenuOffset": "Reset Menu Offset",
"takescreenshot": "Take Screenshot",
"copydiscord": "Copy Discord ID",
"discordcopied": "Discord ID copied to clipboard.",
"nodiscordpresent": "No Discord ID found.",
"admintookscreenshot": "**%s** took a Screenshot of **%s**'s Screen: %s",
"screenshotinprogress": "a Screenshot is already in progress, please wait!",
"screenshotlink": "The Screenshot is available here: %s",
Expand Down
3 changes: 3 additions & 0 deletions language/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
"menuOffsetguide": "Establecer tamaño del menu\nRequiere reabrir el menú.",
"resetmenuOffset": "Reestablecer tamaño del menu",
"takescreenshot": "Sacar una captura",
"copydiscord": "Copiar ID de Discord",
"discordcopied": "ID de Discord copiada al portapapeles",
"nodiscordpresent": "No hay ID de Discord disponible.",
"admintookscreenshot": "**%s** saco una captura de pantalla de **%s**'s Pantalla: %s",
"screenshotinprogress": "una captura de pantalla ya esta en progreso, por favor espere",
"screenshotlink": "La captura de pantalla estara disponible aqui: %s",
Expand Down
3 changes: 3 additions & 0 deletions language/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
"menuOffsetguide": "Définir la taille du menu\nNécessite la réouverture du menu.",
"resetmenuOffset": "Réinitialiser la largeur du menu",
"takescreenshot": "Faire une capture d'écran",
"copydiscord": "Copier l'identifiant Discord",
"discordcopied": "Identifiant Discord copié dans le presse-papiers.",
"nodiscordpresent": "Aucun identifiant Discord n'a été trouvé.",
"admintookscreenshot": "**%s** a fait une capture d'écran de l'écran de **%s** : %s",
"screenshotinprogress": "Une capture d'écran est déjà en cours, veuillez patienter !",
"screenshotlink": "La capture d'écran est disponible ici : %s",
Expand Down
3 changes: 3 additions & 0 deletions language/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
"menuOffsetguide": "Imposta l'offset della dimensione del menù\nRichiede la riapertura del menù.",
"resetmenuOffset": "Resetta larghezza del menù",
"takescreenshot": "Prendi uno Screenshot",
"copydiscord": "Copy Discord ID",
"discordcopied": "Discord ID Copiato.",
"nodiscordpresent": "Nessun ID Discordia trovato.",
"admintookscreenshot": "**%s** ha preso uno Screenshot dallo schermo di **%s** : %s",
"screenshotinprogress": "si sta già catturando lo Screenshot, attendi!",
"screenshotlink": "Lo screenshot è disponibile qui: %s",
Expand Down
3 changes: 3 additions & 0 deletions language/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
"menuOffsetguide": "Stel Menu Grootte in\nVereist menu Heropenen",
"resetmenuOffset": "Reset Menu Grootte",
"takescreenshot": "Neem Schermafbeelding",
"copydiscord": "Kopieer Discord-ID",
"discordcopied": "Discord ID gekopieerd naar klembord.",
"nodiscordpresent": "Geen Discord ID gevonden.",
"admintookscreenshot": "**%s** Nam een Schermafbeelding van **%s** zijn Scherm: %s",
"screenshotinprogress": "een Schermafbeelding is is al aan de gang, even geduld aub!",
"screenshotlink": "De schermafbeelding is beschikbaar hier: %s",
Expand Down
3 changes: 3 additions & 0 deletions language/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
"menuOffsetguide": "Ustaw Przesunięcie menu\nWymaga Ponownego otwarcie menu.",
"resetmenuOffset": "Resetuj przesunięcie menu ",
"takescreenshot": "Zrzut ekranu",
"copydiscord": "Skopiuj identyfikator Discord",
"discordcopied": "Identyfikator Discord został skopiowany do schowka.",
"nodiscordpresent": "Ten gracz nie ma przypisanego identyfikatora Discord.",
"admintookscreenshot": "**%s** zrobił zrzut ekranu **%s**'s Zrzut ekranu: %s",
"screenshotinprogress": "Zrzut ekranu jest w trakcie tworzenia, zaczekaj!",
"screenshotlink": "Zrzut ekranu jest dostępny tutaj: %s",
Expand Down
28 changes: 13 additions & 15 deletions server/admin_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ AddEventHandler('playerDropped', function (reason)
PrintDebugMessage(source.." disconnected.", 4)
end)

local Contributors = {
['736521574383091722'] = true, -- Jaccosf
['1001065851790839828'] = true, -- robbybaseplate
['840695262460641311'] = true, -- Knight
['270731163822325770'] = true, -- Skypo
['186980021850734592'] = true, -- coleminer0112
['469916940710707231'] = true -- Grav
}

RegisterServerEvent("EasyAdmin:GetInfinityPlayerList", function()
PrintDebugMessage(getName(source, true).." requested Playerlist.", 4)
Expand All @@ -165,20 +173,10 @@ RegisterServerEvent("EasyAdmin:GetInfinityPlayerList", function()

for i, player in pairs(players) do
local player = tonumber(player)
cachePlayer(player)
for i, cached in pairs(CachedPlayers) do
if (cached.id == player) then
local pData = {id = cached.id, name = cached.name, immune = cached.immune}
for i, v in pairs(cached.identifiers) do
if v == "discord:178889658128793600" then
pData.developer = true
elseif v == "discord:736521574383091722" --[[ Jaccosf ]] or v == "discord:1001065851790839828" --[[ robbybaseplate ]] or v == "discord:840695262460641311" --[[ Knight ]] or v == "discord:270731163822325770" --[[ Skypo ]] or v == "discord:186980021850734592" --[[ coleminer0112 ]] or v == 'discord:469916940710707231' --[[ Grav ]] then
pData.contributor = true
end
end
table.insert(l, pData)
end
end
local cachedPlayer = cachePlayer(player)
local pData = { id = cachedPlayer.id, name = cachedPlayer.name, immune = cachedPlayer.immune, discord = cachedPlayer.discord, contributor = Contributors[cachedPlayer.discord], developer = cachedPlayer.discord == "178889658128793600" }

l[#l + 1] = pData
end

-- each player is more or less 2000bytes big.
Expand Down Expand Up @@ -734,7 +732,7 @@ Citizen.CreateThread(function()
end
end
exports('getName', getName)

RegisterServerEvent("EasyAdmin:warnPlayer", function(id, reason)
local src = source
if DoesPlayerHavePermission(src,"player.warn") and not CachedPlayers[id].immune and CheckAdminCooldown(source, "warn") then
Expand Down
6 changes: 3 additions & 3 deletions server/playercache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ end)

function cachePlayer(playerId)
if not CachedPlayers[playerId] then
CachedPlayers[playerId] = {id = playerId, name = getName(playerId, true), identifiers = getAllPlayerIdentifiers(playerId), immune = DoesPlayerHavePermission(playerId, "immune")}
CachedPlayers[playerId] = { id = playerId, name = getName(playerId, true), identifiers = getAllPlayerIdentifiers(playerId), immune = DoesPlayerHavePermission(playerId, "immune"), discord = GetPlayerIdentifierByType(playerId, 'discord') and GetPlayerIdentifierByType(playerId, 'discord'):gsub("discord:", "") or false }
PrintDebugMessage(getName(playerId).." has been added to cache.", 4)
return true
return CachedPlayers[playerId]
end
return false
return CachedPlayers[playerId]
end

RegisterServerEvent("EasyAdmin:requestCachedPlayers", function()
Expand Down

0 comments on commit 4c9574f

Please sign in to comment.