Skip to content

Commit

Permalink
fix(nui/PlayerModel): require OneSync for bring and goto (#851)
Browse files Browse the repository at this point in the history
GetPlayerPed is only available on the server-side, if OneSync is enable - note that it works on both legacy and infinity. having onesync off, which result in an invalid entity, resulting in the target coords being 0,0,0
  • Loading branch information
Mycroft-Studios committed Feb 21, 2024
1 parent c1523e0 commit 5aca63a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
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."
},
"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

0 comments on commit 5aca63a

Please sign in to comment.