Skip to content

Commit

Permalink
fix(nui/PlayerModel): require OneSync for bring and goto
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 Jul 16, 2023
1 parent 9ccba0b commit 0e3d678
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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
20 changes: 20 additions & 0 deletions nui/src/components/PlayerModal/Tabs/DialogActionView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { userHasPerm } from "../../../utils/miscUtils";
import { useTranslate } from "react-polyglot";
import { usePermissionsValue } from "../../../state/permissions.state";
import { DialogLoadError } from "./DialogLoadError";
import { useServerCtxValue } from "../../../state/server.state";
import { GenericApiError, GenericApiResp } from "@shared/genericApiTypes";
import { useSetPlayerModalVisibility } from "@nui/src/state/playerModal.state";

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 0e3d678

Please sign in to comment.