From 52a32b443d2bf070344393b85e3451d4d27e10a2 Mon Sep 17 00:00:00 2001 From: itschip Date: Sun, 17 Jan 2021 21:09:45 +0000 Subject: [PATCH] Prettified Code! --- resources/server/sv_call.ts | 61 ++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/resources/server/sv_call.ts b/resources/server/sv_call.ts index 7e0e932..19d9d05 100644 --- a/resources/server/sv_call.ts +++ b/resources/server/sv_call.ts @@ -1,7 +1,7 @@ -import { ESX } from "./server"; -import events from "../utils/events"; -import { getIdentifierByPhoneNumber, usePhoneNumber } from "./functions"; -import { XPlayer } from "esx.js/@types/server"; +import { ESX } from './server'; +import events from '../utils/events'; +import { getIdentifierByPhoneNumber, usePhoneNumber } from './functions'; +import { XPlayer } from 'esx.js/@types/server'; /** * Returns the player phoneNumber for a passed identifier * @param identifier The players phone number @@ -20,7 +20,7 @@ async function getPlayerFromIdentifier(identifier: string): Promise { } } - rej(new Error("Call Target Identifier was not found in xPlayers array")); + rej(new Error('Call Target Identifier was not found in xPlayers array')); }); } @@ -32,48 +32,53 @@ onNet(events.PHONE_BEGIN_CALL, async (phoneNumber: string) => { const _identifier = xPlayer.getIdentifier(); const callerName = xPlayer.getName(); const callerNumber = await usePhoneNumber(_identifier); - const targetIdentifier = await getIdentifierByPhoneNumber(phoneNumber) + const targetIdentifier = await getIdentifierByPhoneNumber(phoneNumber); const targetPlayer = await getPlayerFromIdentifier(targetIdentifier); - console.log('got the targetPlayer') - const targetName = targetPlayer.getName() - console.log('got the target name: ', targetName) + console.log('got the targetPlayer'); + const targetName = targetPlayer.getName(); + console.log('got the target name: ', targetName); // target // Sends information to the client: sourec, playerName, number, isTransmitter - emitNet(events.PHONE_START_CALL, targetPlayer.source, callerName, phoneNumber, false, pSource); + emitNet( + events.PHONE_START_CALL, + targetPlayer.source, + callerName, + phoneNumber, + false, + pSource + ); - // source + // source // Sends information to the client: sourec, playerName, number, isTransmitter - emitNet(events.PHONE_START_CALL, pSource, targetName, callerNumber, true, targetPlayer.source); - + emitNet( + events.PHONE_START_CALL, + pSource, + targetName, + callerNumber, + true, + targetPlayer.source + ); } catch (e) { console.error(e); console.log('Failed to call monkaS'); - //emit(events.PHONE_CALL_ERROR, callSource); + //emit(events.PHONE_CALL_ERROR, callSource); } }); // phoneNumber is the number you're calling onNet(events.PHONE_ACCEPT_CALL, async (phoneNumber: string) => { try { - const pSource = (global as any).source + const pSource = (global as any).source; // target - const targetIdentifier = await getIdentifierByPhoneNumber(phoneNumber) + const targetIdentifier = await getIdentifierByPhoneNumber(phoneNumber); const targetPlayer = await getPlayerFromIdentifier(targetIdentifier); - // client that is calling - emitNet('phone:callAccepted', pSource, targetPlayer.source) + emitNet('phone:callAccepted', pSource, targetPlayer.source); // client that is being called - emitNet('phone:callAccepted', targetPlayer.source, pSource) - - - - - - } catch (error) { - - } -}) + emitNet('phone:callAccepted', targetPlayer.source, pSource); + } catch (error) {} +});