Skip to content
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
28 changes: 17 additions & 11 deletions client/chat.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
-- Staff Chat
RegisterNUICallback("GetMessages", function(data, cb)
local data = lib.callback.await('ps-adminmenu:callback:GetMessages', false)
SendNUIMessage({
action = "setMessages",
data = data
})
if not data then return end
local function getMessagesCallBack()
return lib.callback.await('ps-adminmenu:callback:GetMessages', false)
end

RegisterNUICallback("GetMessages", function(_, cb)
local data = getMessagesCallBack()
if next(data) then
SendNUIMessage({
action = "setMessages",
data = data
})
end
cb(1)
end)

RegisterNUICallback("SendMessage", function(data, cb)
local message = data.message
RegisterNUICallback("SendMessage", function(msgData, cb)
local message = msgData.message
print(message, PlayerData.citizenid, PlayerData.charinfo.firstname .. " " .. PlayerData.charinfo.lastname )

TriggerServerEvent("ps-adminmenu:server:sendMessageServer", message, PlayerData.citizenid, PlayerData.charinfo.firstname .. " " .. PlayerData.charinfo.lastname)

local data = lib.callback.await('ps-adminmenu:callback:GetMessages', false)
local data = getMessagesCallBack()
SendNUIMessage({
action = "setMessages",
data = data
})
cb(1)
end)
2 changes: 2 additions & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ local function setupMenu()
Wait(500)
PlayerData = QBCore.Functions.GetPlayerData()
local resources = lib.callback.await('ps-adminmenu:callback:GetResources', false)
local commands = lib.callback.await('ps-adminmenu:callback:GetCommands', false)
GetData()
SendNUIMessage({
action = "setupUI",
data = {
actions = Config.Actions,
resources = resources,
playerData = PlayerData,
commands = commands
}
})
end
Expand Down
2 changes: 1 addition & 1 deletion html/index.css

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions html/index.js

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions server/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@ local messages = {}

-- Staff Chat
RegisterNetEvent('ps-adminmenu:server:sendMessageServer', function(message, citizenid, fullname)
if not CheckPerms('mod') then return end

local time = os.time() * 1000
local players = QBCore.Functions.GetPlayers()

for i = 1, #players, 1 do
local player = players[i]
if QBCore.Functions.HasPermission(player, 'mod') or IsPlayerAceAllowed(player, 'command') then
if QBCore.Functions.IsOptin(player) then
QBCore.Functions.Notify(player, locale("new_staffchat", 'inform', 7500))
end
end
end

messages[#messages + 1] = { message = message, citizenid = citizenid, fullname = fullname, time = time }
end)

lib.callback.register('ps-adminmenu:callback:GetMessages', function(source)
if QBCore.Functions.HasPermission(player, 'mod') or IsPlayerAceAllowed(player, 'command') then
return messages
end

return {}
lib.callback.register('ps-adminmenu:callback:GetMessages', function()
if not CheckPerms('mod') then return {} end
return messages
end)
32 changes: 32 additions & 0 deletions server/regcommands.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
local commandsTable, addedCommands = {}, {}
local blacklistCommands = {
"sv_", "adhesive_", "citizen_", "con_", "endpoint_", "fileserver", "load_server",
"mysql_connection", "net_tcp", "netPort", "netlib", "onesync", "onesync_",
"rateLimiter_", "svgui", "web_base", "temp_", "txAdmin", "txa",
}

local function isCommandBlacklisted(commandName)
for _, bcommand in pairs(blacklistCommands) do
if string.match(commandName, '^' .. bcommand) then
return true
end
end
return false
end

lib.callback.register('ps-adminmenu:callback:GetCommands', function()
if not CheckPerms(Config.ShowCommandsPerms) then return {} end

local allCommands = GetRegisteredCommands()

for _, command in ipairs(allCommands) do
if not isCommandBlacklisted(command.name) and not addedCommands[command.name] then
commandsTable[#commandsTable + 1] = {
name = '/' .. command.name
}
addedCommands[command.name] = true -- prevent duplicates
end
end

return commandsTable
end)
1 change: 1 addition & 0 deletions shared/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Config = Config or {}

Config.Fuel = "ps-fuel" -- "ps-fuel", "LegacyFuel"
Config.ResourcePerms = 'admin' -- permission to control resource(start stop restart)
Config.ShowCommandsPerms = 'admin' -- permission to show all commands
Config.RenewedPhone = false -- if you use qb-phone from renewed. (multijob)

-- Key Bindings
Expand Down
3 changes: 3 additions & 0 deletions ui/src/layout/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import Server from '@pages/Server/Server.svelte'
import StaffChat from '@pages/Chat/Chat.svelte'
import Players from '@pages/Players/Players.svelte'
import Commands from '@pages/Commands/Commands.svelte'
</script>

<div
Expand All @@ -22,6 +23,8 @@
<StaffChat />
{:else if $ACTIVE_PAGE == 'Players'}
<Players />
{:else if $ACTIVE_PAGE == 'Commands'}
<Commands />
{/if}
</div>
</div>
2 changes: 2 additions & 0 deletions ui/src/layout/Sidebar/Components/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
before:absolute
before:-right-3 before:top-1/2
before:w-max before:max-w-xs
before:px-[1vh]
before:py-[0.5vh]
before:-translate-x-full before:-translate-y-1/2
before:bg-tertiary before:text-white
before:rounded-md before:opacity-0
Expand Down
3 changes: 3 additions & 0 deletions ui/src/layout/Sidebar/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{ value: 'Staffchat', icon: 'fas fa-message' },
{ value: 'Players', icon: 'fas fa-users' },
{ value: 'Server', icon: 'fas fa-server' },
{ value: 'Commands', icon: 'fas fa-slash' },
{ value: 'Actions', icon: 'fas fa-wand-magic-sparkles' },
]
</script>
Expand Down Expand Up @@ -40,6 +41,8 @@
before:absolute
before:-right-3 before:top-1/2
before:w-max before:max-w-xs
before:px-[1vh]
before:py-[0.5vh]
before:-translate-x-full before:-translate-y-1/2
before:bg-tertiary before:text-white
before:rounded-md before:opacity-0
Expand Down
37 changes: 37 additions & 0 deletions ui/src/pages/Commands/Commands.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<script>
import { MENU_WIDE } from '@store/stores'
import { COMMANDS } from '@store/server'

import Header from '@components/Header.svelte'
import CommandsCard from './components/CommandsCard.svelte'

let search = ''

let SortedCommands = $COMMANDS ? $COMMANDS.slice().sort((a, b) => a.name.localeCompare(b.name)) : []
</script>

<div class="h-full w-[33vh] px-[2vh]">
<Header
title={'Commands'}
hasSearch={true}
onSearchInput={event => (search = event.target.value)}
/>
<div class="w-full h-[84%] flex flex-col gap-[1vh] mt-[1vh] overflow-auto">
{#if $COMMANDS}
{#if $COMMANDS && $COMMANDS.filter((commands) => commands.name.toLowerCase().includes(search.toLowerCase())).length === 0}
<div class="text-tertiary text-center text-[1.7vh] font-medium mt-[1vh]">No Commands Found.</div>
{:else}
<small class="font-medium">Total Commands: {SortedCommands.length}</small>
{#each SortedCommands.filter((commands) => commands.name.toLowerCase().includes(search.toLowerCase())) as commands}
<CommandsCard label={commands.name} />
{/each}
{/if}
{/if}
</div>
</div>

{#if $MENU_WIDE}
<div class="h-full w-[66vh] border-l-[0.2vh] border-tertiary px-[2vh]">
<Header title={'Dashboard'} />
</div>
{/if}
10 changes: 10 additions & 0 deletions ui/src/pages/Commands/components/CommandsCard.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script>
export let label
</script>

<button class="w-full flex justify-between rounded-[0.5vh] bg-tertiary items-center">
<div class="flex items-center p-[2vh]">
<i class="fas fa-angle-right mr-[1vh]"></i>
<p class="text-[1.5vh]">{label ? label : ''}</p>
</div>
</button>
3 changes: 2 additions & 1 deletion ui/src/providers/AlwaysListener.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { ACTION } from '@store/actions'
import { ITEM_DATA, VEHICLE_DATA, JOB_DATA, GANG_DATA, LOCATION_DATA, PED_LIST } from '@store/data'
import { PLAYER, PLAYER_DATA } from '@store/players'
import { RESOURCE, RESOURCES } from '@store/server'
import { RESOURCE, RESOURCES, COMMANDS } from '@store/server'
import { VEHICLE_DEV } from '@store/vehicle_dev'
import { TOGGLE_COORDS } from '@store/togglecoords'
import { Message, Messages } from "@store/staffchat";
Expand All @@ -29,6 +29,7 @@
$ACTION = data.actions
$RESOURCE = data.resources
$PLAYER_DATA = data.playerData
$COMMANDS = data.commands
})

ReceiveNUI('setResourceData', (data: any) => {
Expand Down
8 changes: 6 additions & 2 deletions ui/src/store/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { writable } from "svelte/store";

export const RESOURCE = writable<RESOURCE_DATA[]>(null);
export const RESOURCES = writable<RESOURCE_DATA>(null);
export const COMMANDS = writable<COMMANDS_DATA[]>(null);

export const SERVER = writable<SERVER_DATA[]>(null);

Expand All @@ -12,7 +13,7 @@ interface RESOURCE_DATA {
description?: string;
resourceState?: string;
}

interface SERVER_DATA {
TotalCash?: string;
TotalBank?: string;
Expand All @@ -22,4 +23,7 @@ interface SERVER_DATA {
BansCount?: string;
UniquePlayers?: string;
}


interface COMMANDS_DATA {
name?: string;
}