Skip to content

Commit

Permalink
Photo url copies to clipboard when taking a picture now (#21)
Browse files Browse the repository at this point in the history
* Fixed cam pos and minimap issue

fixed an issue with view of camera to front of the cam and fixed issue with minimap displaying at random

* Copy To Clipboard

* Copy To Clipboard
  • Loading branch information
lenzh authored Jun 9, 2023
1 parent ff61c35 commit 98a4367
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions client/cl_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ function CameraLoop()
if cameraprop then DeleteEntity(cameraprop) end
ClearPedTasks(lPed)
TriggerServerEvent("ps-camera:CreatePhoto", json.encode(image.attachments[1].proxy_url))
SendNUIMessage({action = "SavePic", pic = json.encode(image.attachments[1].proxy_url)})
SendNUIMessage({action = "hideOverlay"})
end)
end
Expand Down
14 changes: 12 additions & 2 deletions client/nui/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function open(image, location) {
}
}


function close() {
if (displayPicture) {
$('.picture-container').addClass('hide');
Expand All @@ -42,6 +41,15 @@ function close() {
}
}

const copyToClipboard = (str) => {
const el = document.createElement("textarea");
el.value = str.replace(/[" ]/g, "");
document.body.appendChild(el);
el.select();
document.execCommand("copy");
document.body.removeChild(el);
};

$(document).ready(function () {
window.addEventListener("message", function (event) {
if (event.data.action === "Open") {
Expand All @@ -55,6 +63,8 @@ $(document).ready(function () {
document.getElementById("camera-overlay").classList.add("hide");
} else if (event.data.action === "openPhoto") {
open(event.data.image, event.data.location);
} else if (event.data.action === "SavePic") {
copyToClipboard(event.data.pic);
}
});

Expand All @@ -68,4 +78,4 @@ $(document).ready(function () {
break;
}
};
});
});

0 comments on commit 98a4367

Please sign in to comment.