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 ​
| Name | Type |
|---|---|
T | (player: Player, ...args: any[]) => void |
Parameters ​
| Name | Type |
|---|---|
handler | T |
restrictions | Restrictions |
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 ​
| Name | Type |
|---|---|
functionName | "create" |
callback | <T>(handler: T, restrictions: Restrictions) => T |
Returns ​
any
V5 Docs