Initial commit — Southwest Roleplay FiveM
This commit is contained in:
21
src/server/core/commands/guards/permissions.command.guard.ts
Normal file
21
src/server/core/commands/guards/permissions.command.guard.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { permissionSystem } from '../../../features/permission';
|
||||
|
||||
export const PermissionCommandGuard = (...permissionNames: string[]): CommandGuard => {
|
||||
const permission = ((player: PlayerMp) => {
|
||||
for (const permissionName of permissionNames) {
|
||||
if (permissionSystem.doesPlayerHavePermission(player, permissionName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (permissionNames.includes('aduty') && player.getVariable('adminDuty')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return `You're not allowed to use this command`;
|
||||
}) as CommandGuard & { __permissions?: string[] };
|
||||
|
||||
permission.__permissions = [...permissionNames];
|
||||
|
||||
return permission;
|
||||
};
|
||||
Reference in New Issue
Block a user