mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
feat(config): configure an export to be called at toggle to control phone access
Can serve as a primitive form of access control that can for example call a client side inventory check
This commit is contained in:
1 parent
b00bee0217
commit
fc939885a8
3 files changed
+31
-12
No files matched your search
+5
-1
@@ -2,7 +2,11 @@
|
|||||||
"Locale": "en",
|
"Locale": "en",
|
||||||
"KeyTogglePhone": 288,
|
"KeyTogglePhone": 288,
|
||||||
"KeyTakeCall": 38,
|
"KeyTakeCall": 38,
|
||||||
"PhoneAsItem": false,
|
"PhoneAsItem": {
|
||||||
|
"enabled": false,
|
||||||
|
"exportResource": "my-core-resource",
|
||||||
|
"exportName": "myCheckerFunction"
|
||||||
|
},
|
||||||
"SwimDestroy": false,
|
"SwimDestroy": false,
|
||||||
"RunRate": 10,
|
"RunRate": 10,
|
||||||
"DestroyChance": 100,
|
"DestroyChance": 100,
|
||||||
|
|||||||
+19
-10
@@ -7,8 +7,12 @@ import { PhotoEvents } from '../../typings/photo';
|
|||||||
import { CallEvents } from '../../typings/call';
|
import { CallEvents } from '../../typings/call';
|
||||||
import { config } from './client';
|
import { config } from './client';
|
||||||
import { animationService } from './animations/animation.controller';
|
import { animationService } from './animations/animation.controller';
|
||||||
|
import { RegisterNuiCB } from './cl_utils';
|
||||||
|
|
||||||
let isPhoneOpen = false;
|
let isPhoneOpen = false;
|
||||||
|
|
||||||
|
const exps = global.exports;
|
||||||
|
|
||||||
/* * * * * * * * * * * * *
|
/* * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Phone initialize data
|
* Phone initialize data
|
||||||
@@ -75,7 +79,7 @@ RegisterCommand(
|
|||||||
'phone',
|
'phone',
|
||||||
async () => {
|
async () => {
|
||||||
//-- Toggles Phone
|
//-- Toggles Phone
|
||||||
await Phone();
|
await togglePhone();
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
@@ -96,17 +100,22 @@ RegisterCommand(
|
|||||||
*
|
*
|
||||||
* * * * * * * * * * * * */
|
* * * * * * * * * * * * */
|
||||||
|
|
||||||
async function Phone(): Promise<void> {
|
const checkExportCanOpen = (): boolean => {
|
||||||
if (config.PhoneAsItem) {
|
const exportResp = exps[config.PhoneAsItem.exportResource][config.PhoneAsItem.exportFunction]();
|
||||||
// TODO: Do promise callback here
|
if (typeof exportResp !== 'number' && typeof exportResp !== 'boolean') {
|
||||||
// const hasPhoneItem = await emitNetPromise('phone:hasPhoneItem')
|
throw new Error('You must return either a boolean or number from your export function');
|
||||||
// if (!hasPhoneItem) return
|
|
||||||
}
|
}
|
||||||
if (isPhoneOpen) {
|
|
||||||
await hidePhone();
|
return !!exportResp;
|
||||||
} else {
|
};
|
||||||
|
|
||||||
|
async function togglePhone(): Promise<void> {
|
||||||
|
if (config.PhoneAsItem.enabled) {
|
||||||
|
const canAccess = checkExportCanOpen();
|
||||||
|
if (!canAccess) return;
|
||||||
|
}
|
||||||
|
if (isPhoneOpen) return await hidePhone();
|
||||||
await showPhone();
|
await showPhone();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onNet(PhoneEvents.SEND_CREDENTIALS, (number: string) => {
|
onNet(PhoneEvents.SEND_CREDENTIALS, (number: string) => {
|
||||||
|
|||||||
+7
-1
@@ -43,12 +43,18 @@ interface DatabaseConfig {
|
|||||||
useIdentifierPrefix: boolean;
|
useIdentifierPrefix: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface PhoneAsItemConfig {
|
||||||
|
enabled: boolean;
|
||||||
|
exportResource: string;
|
||||||
|
exportFunction: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ResourceConfig {
|
export interface ResourceConfig {
|
||||||
database: DatabaseConfig;
|
database: DatabaseConfig;
|
||||||
Locale: string;
|
Locale: string;
|
||||||
KeyTogglePhone: number;
|
KeyTogglePhone: number;
|
||||||
KeyTakeCall: number;
|
KeyTakeCall: number;
|
||||||
PhoneAsItem: boolean;
|
PhoneAsItem: PhoneAsItemConfig;
|
||||||
SwimDestroy: boolean;
|
SwimDestroy: boolean;
|
||||||
RunRate: number;
|
RunRate: number;
|
||||||
twitter: TwitterConfig;
|
twitter: TwitterConfig;
|
||||||
|
|||||||
Reference in new issue
Block a user