Ping: {{ ping }}
Health: {{ health }}
Stamina: {{ stamina }}
+Bank: {{ '$' + characterData.bank }}
+Cash: {{ '$' + characterData.cash }}
Street: {{ street }}
Discord ID: {{ player.discordId }}
From e9efed7deeda4100c125b84b9bf71106fc36b007 Mon Sep 17 00:00:00 2001 From: programmernb-ctrl <141086417+programmernb-ctrl@users.noreply.github.com> Date: Sat, 7 Dec 2024 08:43:28 +0100 Subject: [PATCH 09/10] (test) changed tp marker function --- server/index.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/server/index.ts b/server/index.ts index daec598..80e06a4 100644 --- a/server/index.ts +++ b/server/index.ts @@ -98,34 +98,31 @@ async function adminpanelTpMarker(player: alt.Player) { } const interval = alt.setInterval(async () => { + rPlayer.native.invoke('setFocusPosAndVel', waypoint.x, waypoint.y, waypoint.z, 0.0, 0.0, 0.0); + const groundZResponse = await rPlayer.native.invokeWithResult('getGroundZFor3dCoord', waypoint.x, waypoint.y, waypoint.z, 1000, false, false); if (groundZResponse[0] === true && typeof groundZResponse[1] === 'number') { const groundZ = groundZResponse[1]; - if (groundZ === 0) { - alt.clearInterval(interval); - return; - } - alt.clearInterval(interval); - rPlayer.native.invoke('setFocusPosAndVel', waypoint.x, waypoint.y, groundZ, 0.0, 0.0, 0.0); rPlayer.native.invoke('requestCollisionAtCoord', waypoint.x, waypoint.y, groundZ); const nextTick = alt.nextTick(async () => { player.frozen = true; + rPlayer.native.invoke('clearFocus'); player.pos = new alt.Vector3(waypoint.x, waypoint.y, groundZ); player.frozen = false; + rPlayer.notify.showNotification('Teleported successfully'); alt.clearNextTick(nextTick); }) - - rPlayer.notify.showNotification('Teleported successfully'); } else { alt.clearInterval(interval); + rPlayer.native.invoke('clearFocus'); return; } - }, 500); + }, 1000); } alt.onRpc(adminpanelEvents.rpc.giveAdmin, async (player: alt.Player) => { From 6bb1838b61b40d8c39ab7a549a323b06084bf975 Mon Sep 17 00:00:00 2001 From: programmernb-ctrl <141086417+programmernb-ctrl@users.noreply.github.com> Date: Thu, 12 Dec 2024 21:03:26 +0100 Subject: [PATCH 10/10] Update --- README.md | 23 ++++------- server/index.ts | 62 ++++++++++++++++++---------- shared/config.ts | 2 +- shared/events.ts | 9 ++-- webview/Adminpanel.vue | 24 ++++++----- webview/Users.vue | 1 - webview/composables/useAdminPanel.ts | 15 +++---- webview/composables/useUserSearch.ts | 12 +++--- 8 files changed, 82 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 85d543d..d67885c 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,22 @@ # rebar-adminpanel > [!IMPORTANT] -> It's required that you go to your Rebar directory -> and set up some things first before using the rebar-adminpanel plugin +> Please read all installation steps to prevent unwanted behaviour -## Installation +[](https://ko-fi.com/S6S3171498) -1. Go to your Rebar `main` server's directory and then to `./webview/src/index.css` -2. Add following code at the end of `index.css` +## Installation -```css -.neon-button { - @apply w-full rounded-lg border-2 border-transparent px-4 py-3 text-left text-sm text-gray-200 hover:animate-pulse hover:border-red-500 hover:bg-opacity-75 hover:shadow-md; -} -``` +1. Go to your Rebar `main` server's directory. -3. Now clone this repository in to your Rebar `main` directory using git commands. +2. Now clone this repository in to your Rebar `main` directory using git commands. ```bash cd path/to/your/rebar-altv/ git clone https://github.com/programmernb-ctrl/rebar-adminpanel.git src/plugins/rebar-adminpanel ``` -4. Should your character don't have the admin group you'll need to customize the config in `./shared/config.ts` +3. If your character doesn't already have the admin group, you'll need to customize the config in `./shared/config.ts` ```typescript export const adminpanelConfig = { @@ -30,7 +24,7 @@ export const adminpanelConfig = { }; ``` -5. Start the server once by using one of the below commands. The plugin will load __automatically.__ +4. Start the server once by using one of the below commands. The plugin will load __automatically.__ ``` pnpm start @@ -57,7 +51,8 @@ cd path/to/your/rebar-altv/src/plugins/rebar-adminpanel git pull ``` -- If you forked this repo and wanna update it, simply search for `merge from upstream` on [Google](https://www.google.com) +- If you forked this repo and want to update it, simply search for `merge from upstream` on [Google](https://www.google. + com) ## Dependencies diff --git a/server/index.ts b/server/index.ts index 80e06a4..1e4560e 100644 --- a/server/index.ts +++ b/server/index.ts @@ -4,18 +4,25 @@ import { adminpanelConfig } from '@Plugins/rebar-adminpanel/shared/config.js'; import { adminpanelEvents } from '@Plugins/rebar-adminpanel/shared/events.js'; const Rebar = useRebar(); - +const keyBinding = Rebar.useKeybinder(); const getter = Rebar.get.usePlayersGetter(); const worldGetter = Rebar.get.useWorldGetter(); -const keyBinding = Rebar.useKeybinder(); const syncedBinder = Rebar.systems.useStreamSyncedBinder(); syncedBinder.syncCharacterKey('cash'); syncedBinder.syncCharacterKey('bank'); if (adminpanelConfig.Settings.debug) { - alt.logWarning('[rebar-adminpanel] Debug Mode is still activated. Consider disable it to prevent unwanted' + - ' behaviour') + alt.logWarning( + '[rebar-adminpanel] Debug Mode is still activated. Consider disable it to prevent unwanted' + ' behaviour', + ); +} + +let keybinding = undefined; +async function showView(player: alt.Player) { + keybinding = keyBinding.on(adminpanelEvents.bindings.F4, () => { + adminpanelShow(player); + }); } /** @@ -23,6 +30,10 @@ if (adminpanelConfig.Settings.debug) { * @param player to show the webview to | alt.Player */ async function adminpanelShow(player: alt.Player) { + if (!player?.valid) { + return; + } + const character = Rebar.document.character.useCharacter(player); const isMember = character.groups.memberOf('admin'); // const hasPermission = Rebar.permissions.usePermissions(player).hasPermission('adminpanel'); @@ -44,6 +55,14 @@ async function adminpanelHide(player: alt.Player) { Rebar.player.useWorld(player).enableControls(); } +async function adminpanelHideUser(player: alt.Player) { + const view = Rebar.player.useWebview(player); + + view.hide('Users'); + Rebar.player.useAudio(player).playFrontendSound('Click_Fail', 'WEB_NAVIGATION_SOUNDS_PHONE'); + Rebar.player.useWorld(player).enableControls(); +} + async function getAdmin(player: alt.Player) { const character = Rebar.document.character.useCharacter(player); const hasGroup = character.groups.memberOf('admin'); @@ -75,14 +94,6 @@ async function adminpanelShowAllUsers(player: alt.Player) { view.emit(adminpanelEvents.webview.getUsers, playerDetails); } -async function adminpanelHideUser(player: alt.Player) { - const view = Rebar.player.useWebview(player); - - view.hide('Users'); - Rebar.player.useAudio(player).playFrontendSound('Click_Fail', 'WEB_NAVIGATION_SOUNDS_PHONE'); - Rebar.player.useWorld(player).enableControls(); -} - /** * Gets the waypoint set by the player and then teleports them to the new position * @param player the player to teleport to the marker @@ -91,7 +102,7 @@ async function adminpanelTpMarker(player: alt.Player) { if (!player?.valid) return; const rPlayer = Rebar.usePlayer(player); - const waypoint = await Rebar.usePlayer(player).waypoint.get() + const waypoint = await Rebar.usePlayer(player).waypoint.get(); if (!waypoint) { return; @@ -100,7 +111,15 @@ async function adminpanelTpMarker(player: alt.Player) { const interval = alt.setInterval(async () => { rPlayer.native.invoke('setFocusPosAndVel', waypoint.x, waypoint.y, waypoint.z, 0.0, 0.0, 0.0); - const groundZResponse = await rPlayer.native.invokeWithResult('getGroundZFor3dCoord', waypoint.x, waypoint.y, waypoint.z, 1000, false, false); + const groundZResponse = await rPlayer.native.invokeWithResult( + 'getGroundZFor3dCoord', + waypoint.x, + waypoint.y, + waypoint.z, + 1000, + false, + false, + ); if (groundZResponse[0] === true && typeof groundZResponse[1] === 'number') { const groundZ = groundZResponse[1]; @@ -111,12 +130,13 @@ async function adminpanelTpMarker(player: alt.Player) { const nextTick = alt.nextTick(async () => { player.frozen = true; + alt.log(player.dimension); rPlayer.native.invoke('clearFocus'); player.pos = new alt.Vector3(waypoint.x, waypoint.y, groundZ); player.frozen = false; rPlayer.notify.showNotification('Teleported successfully'); alt.clearNextTick(nextTick); - }) + }); } else { alt.clearInterval(interval); rPlayer.native.invoke('clearFocus'); @@ -165,14 +185,12 @@ alt.onClient(adminpanelEvents.toServer.closeUsers, async (player: alt.Player) => alt.onClient(adminpanelEvents.toServer.tpMarker, async (player: alt.Player) => { await adminpanelTpMarker(player); -}) +}); -alt.once('playerConnect', async (player: alt.Player) => { +alt.on('playerConnect', async (player: alt.Player) => { await showView(player); }); -async function showView(player: alt.Player) { - keyBinding.on(adminpanelEvents.bindings.F4, () => { - adminpanelShow(player); - }); -} \ No newline at end of file +alt.on('playerDisconnect', async (player: alt.Player) => { + keyBinding.off(adminpanelEvents.bindings.F4, keybinding); +}); diff --git a/shared/config.ts b/shared/config.ts index 389aead..19e2488 100644 --- a/shared/config.ts +++ b/shared/config.ts @@ -3,4 +3,4 @@ export const adminpanelConfig = { debug: false, adminMode: false, } -}; +}; \ No newline at end of file diff --git a/shared/events.ts b/shared/events.ts index 15897c4..a5936ed 100644 --- a/shared/events.ts +++ b/shared/events.ts @@ -2,18 +2,17 @@ export const adminpanelEvents = { toClient: {}, toServer: { closePanel: 'adminpanel:close', - closeUsers: 'adminpanel:closeUsers', + closeUsers: 'adminpanel:close:users', tpMarker: 'adminpanel:teleport:marker:hud', }, webview: { closeAdminpanelCallback: 'adminpanel', closeUserpanelCallback: 'adminpanel:users', - getUsers: 'adminpanel:getUsers', - + getUsers: 'adminpanel:get:users', }, rpc: { - showAllUsers: 'adminpanel:showAllUsers', - giveAdmin: 'adminpanel:giveadmin', + showAllUsers: 'adminpanel:show:all:users', + giveAdmin: 'adminpanel:admin', toWaypoint: 'adminpanel:towaypoint', }, bindings: { diff --git a/webview/Adminpanel.vue b/webview/Adminpanel.vue index dc2ddc7..45d791b 100644 --- a/webview/Adminpanel.vue +++ b/webview/Adminpanel.vue @@ -1,21 +1,25 @@