Skip to content
On this page

Athena.utility.restrict ​

Interfaces ​

Functions ​

create ​

Usage

Athena.utility.restrict.create<T>(handler, restrictions): T

Wraps a function and creates restrictions on that function.

Always call the restricted function to invoke an automatic check against given permission strategy.

First argument of the handler must always be a player.

ts
function doPoliceWork(player: alt.Player) {
  // Restricted to characters who have 'police' permission
  // OR
  // Restricted to accounts who have 'admin' permission
}

const doPoliceWorkRestricted = Athena.utility.restrict.create(doPoliceWork, {
    strategy: 'hasOne',
    permissions: { account: ['admin'], character: ['police'] },
    notify: 'You are not part of the police force.',
});

alt.onClient('something-from-a-client', doPoliceWorkRestricted);

Type parameters ​

NameType
T(player: Player, ...args: any[]) => void

Parameters ​

NameType
handlerT
restrictionsRestrictions

Returns ​

T

Defined in ​

server/utility/restrict.ts:156


override ​

Usage

Athena.utility.restrict.override(functionName, callback): any

Used to override restrict utility funcs

Parameters ​

NameType
functionName"create"
callback<T>(handler: T, restrictions: Restrictions) => T

Returns ​

any

Defined in ​

server/utility/restrict.ts:186

Created by Stuyk | Est. 2020