Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nui/PlayerModel): require OneSync for bring and goto #851

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"not_enabled": "The txAdmin Menu is not enabled! You can enable it in the txAdmin settings page.",
"announcement_title": "Server Announcement by %{author}:",
"directmessage_title": "DM from admin %{author}:",
"dialog_empty_input": "You cannot have an empty input."
"dialog_empty_input": "You cannot have an empty input.",
"onesync_error": "This option requires OneSync to be enabled."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to future self: perhaps remove nui_menu.page_main.vehicle.onesync_error

},
"frozen": {
"froze_player": "You have frozen the player!",
Expand Down
22 changes: 21 additions & 1 deletion nui/src/components/PlayerModal/Tabs/DialogActionView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import { userHasPerm } from "../../../utils/miscUtils";
import { useTranslate } from "react-polyglot";
import { usePermissionsValue } from "../../../state/permissions.state";
import { DialogLoadError } from "./DialogLoadError";
mport { useServerCtxValue } from "../../../state/server.state";
import { GenericApiErrorResp, GenericApiResp } from "@shared/genericApiTypes";
import { useSetPlayerModalVisibility } from "@nui/src/state/playerModal.state";
mport { useSetPlayerModalVisibility } from "@nui/src/state/playerModal.state";

const PREFIX = "DialogActionView";

Expand Down Expand Up @@ -62,6 +63,7 @@ const DialogActionView: React.FC = () => {
const { enqueueSnackbar } = useSnackbar();
const t = useTranslate();
const { goToFramePage } = useIFrameCtx();
const serverCtx = useServerCtxValue();
const playerPerms = usePermissionsValue();
const setModalOpen = useSetPlayerModalVisibility();
const { closeMenu, showNoPerms } = usePlayerModalContext();
Expand Down Expand Up @@ -215,6 +217,15 @@ const DialogActionView: React.FC = () => {
if (!userHasPerm("players.teleport", playerPerms))
return showNoPerms("Teleport");

// Since we depend on server side gamestate awareness
// we disable this function from being used if onesync
// isn't on
if (!serverCtx.oneSync.status) {
return enqueueSnackbar(t("nui_menu.misc.onesync_error"), {
variant: "error",
});
}

closeMenu();
fetchNui("tpToPlayer", { id: assocPlayer.id });
enqueueSnackbar(
Expand All @@ -227,6 +238,15 @@ const DialogActionView: React.FC = () => {
if (!userHasPerm("players.teleport", playerPerms))
return showNoPerms("Teleport");

// Since we depend on server side gamestate awareness
// we disable this function from being used if onesync
// isn't on
if (!serverCtx.oneSync.status) {
return enqueueSnackbar(t("nui_menu.misc.onesync_error"), {
variant: "error",
});
}

closeMenu();
fetchNui("summonPlayer", { id: assocPlayer.id });
enqueueSnackbar(
Expand Down
Loading