diff --git a/locale/en.json b/locale/en.json index 67161ad44..2d540c337 100644 --- a/locale/en.json +++ b/locale/en.json @@ -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." }, "frozen": { "froze_player": "You have frozen the player!", diff --git a/nui/src/components/PlayerModal/Tabs/DialogActionView.tsx b/nui/src/components/PlayerModal/Tabs/DialogActionView.tsx index 8dd23b85a..43bccf2c7 100644 --- a/nui/src/components/PlayerModal/Tabs/DialogActionView.tsx +++ b/nui/src/components/PlayerModal/Tabs/DialogActionView.tsx @@ -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"; @@ -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(); @@ -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( @@ -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(