diff --git a/client/world.lua b/client/world.lua index c55ae316..98b6a2ec 100644 --- a/client/world.lua +++ b/client/world.lua @@ -17,3 +17,45 @@ RegisterNetEvent('ps-adminmenu:client:ChangeWeather', function(data, selectedDat TriggerServerEvent('qb-weathersync:server:setWeather', weather) end) + +RegisterNetEvent('ps-adminmenu:client:copyToClipboard', function(data, selectedData) + local data = CheckDataFromKey(data) + if not data or not CheckPerms(data.perms) then return end + + local dropdown = selectedData["Copy Coords"].value + local ped = PlayerPedId() + local string = nil + if dropdown == 'vector2' then + local coords = GetEntityCoords(ped) + local x = QBCore.Shared.Round(coords.x, 2) + local y = QBCore.Shared.Round(coords.y, 2) + string = "vector2(".. x ..", ".. y ..")" + QBCore.Functions.Notify(locale("copy_vector2"), 'success') + elseif dropdown == 'vector3' then + local coords = GetEntityCoords(ped) + local x = QBCore.Shared.Round(coords.x, 2) + local y = QBCore.Shared.Round(coords.y, 2) + local z = QBCore.Shared.Round(coords.z, 2) + string = "vector3(".. x ..", ".. y ..", ".. z ..")" + QBCore.Functions.Notify(locale("copy_vector3"), 'success') + elseif dropdown == 'vector4' then + local coords = GetEntityCoords(ped) + local x = QBCore.Shared.Round(coords.x, 2) + local y = QBCore.Shared.Round(coords.y, 2) + local z = QBCore.Shared.Round(coords.z, 2) + local heading = GetEntityHeading(ped) + local h = QBCore.Shared.Round(heading, 2) + string = "vector4(".. x ..", ".. y ..", ".. z ..", ".. h ..")" + QBCore.Functions.Notify(locale("copy_vector4"), 'success') + elseif dropdown == 'heading' then + local heading = GetEntityHeading(ped) + local h = QBCore.Shared.Round(heading, 2) + string = h + QBCore.Functions.Notify(locale("copy_heading"), 'success') + elseif string == nil then + QBCore.Functions.Notify(locale("empty_input"), 'error') + end + + lib.setClipboard(string) + +end) \ No newline at end of file diff --git a/shared/config.lua b/shared/config.lua index 799957bc..1f9f6568 100644 --- a/shared/config.lua +++ b/shared/config.lua @@ -155,10 +155,17 @@ Config.Actions = { label = "Copy Coords", perms = "mod", dropdown = { - { label = "Copy Vector2", option = "button", type = "command", event = "vector2" }, - { label = "Copy Vector3", option = "button", type = "command", event = "vector3" }, - { label = "Copy Vector4", option = "button", type = "command", event = "vector4" }, - { label = "Copy Heading", option = "button", type = "command", event = "heading" }, + { + label = "Copy Coords", + option = "dropdown", + data = { + { label = "Copy Vector2", value = "vector2" }, + { label = "Copy Vector3", value = "vector3" }, + { label = "Copy Vector4", value = "vector4" }, + { label = "Copy Heading", value = "heading" }, + }, + }, + { label = "Copy to Clipboard", option = "button", type = "client", event = "ps-adminmenu:client:copyToClipboard"}, }, }, @@ -511,7 +518,7 @@ Config.Actions = { }, }, - ["spactate_player"] = { + ["spectate_player"] = { label = "Spectate Player", perms = "mod", dropdown = { diff --git a/ui/src/pages/Actions/components/Button.svelte b/ui/src/pages/Actions/components/Button.svelte index 8510f8ce..bf5e3235 100644 --- a/ui/src/pages/Actions/components/Button.svelte +++ b/ui/src/pages/Actions/components/Button.svelte @@ -14,7 +14,7 @@