mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-02 22:17:39 +00:00
Feat(Main): Sending credentials
This commit is contained in:
1 parent
1bb7a60e4d
commit
bd37aa5da7
3 files changed
+80
-3
No files matched your search
@@ -10,7 +10,7 @@ RegisterCommand('phone:close', (source: any, args: string[], raw: any) => {
|
||||
JSON.stringify({
|
||||
app: "PHONE",
|
||||
method: "setVisibility",
|
||||
data: true
|
||||
data: false
|
||||
})
|
||||
)
|
||||
}, false)
|
||||
@@ -56,7 +56,7 @@ function deletePhone() { //-- Triggered in newphoneProp function. Only way to de
|
||||
async function loadAnimDict(dict: any) { //-- Loads the animation dict. Used in the anim functions.
|
||||
while (!HasAnimDictLoaded(dict)) {
|
||||
RequestAnimDict(dict)
|
||||
await Delay(0)
|
||||
await Delay(100)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ async function Phone() {
|
||||
isPhoneOpen = true
|
||||
await phoneOpenAnim()
|
||||
console.log("phone is now open") //Left for testing purposes.
|
||||
TriggerServerEvent('phone:getCredentials', source)
|
||||
emitNet('phone:getCredentials') // Gets the credentials. Will eventually most likely only get the phone number and name, idk.
|
||||
SetCursorLocation(0.936, 0.922) //Experimental
|
||||
let res = GetActiveScreenResolution()
|
||||
SendNuiMessage(
|
||||
@@ -278,3 +278,13 @@ setTick(async () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
onNet('phone:sendCredentials', (number: string) => {
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
app: "SIMCARD",
|
||||
method: "setNumber",
|
||||
data: number
|
||||
})
|
||||
)
|
||||
});
|
||||
@@ -2,6 +2,7 @@ import { ESXServer } from "fivem-esx-js/server/esx_server";
|
||||
|
||||
import './db';
|
||||
import './sv_twitter';
|
||||
import './sv_main';
|
||||
|
||||
export let ESX: ESXServer = null;
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import { ESX } from './server';
|
||||
import { pool } from './db';
|
||||
|
||||
//db = DatabaseConfig //helper variable for use in server function
|
||||
|
||||
//we pass the server configuration to the phone so that we can have phone or
|
||||
//app specific settings configured by the server owner
|
||||
//ESX.RegisterServerCallback('phone:phoneConfig', function(source, cb) {
|
||||
// cb(Config)
|
||||
//});
|
||||
|
||||
interface Credentials {
|
||||
phone_number: string;
|
||||
}
|
||||
|
||||
async function getCredentials(identifier: string) : Promise<string> {
|
||||
const query = "SELECT phone_number FROM users WHERE identifier = ?";
|
||||
const [ result ] = await pool.query(query, [identifier]);
|
||||
const number = <Credentials[]>result;
|
||||
if (number.length === 0) return "###-####";
|
||||
return number[0].phone_number;
|
||||
}
|
||||
|
||||
onNet('phone:getCredentials', async () => {
|
||||
try {
|
||||
const _source = (global as any).source;
|
||||
const xPlayer = ESX.GetPlayerFromId(_source);
|
||||
const _identifier = xPlayer.getIdentifier();
|
||||
const number = await getCredentials(_identifier);
|
||||
emitNet('phone:sendCredentials', _source, number)
|
||||
} catch (error) {
|
||||
console.log('Failed to get number. ', error);
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
//
|
||||
//ESX.RegisterServerCallback('phone:getItemAmount', function(source, cb, item)
|
||||
// local xPlayer = ESX.GetPlayerFromId(source)
|
||||
// local items = xPlayer.getInventoryItem(item)
|
||||
//
|
||||
// if items == nil then
|
||||
// cb(0)
|
||||
// else
|
||||
// cb(items.count)
|
||||
// end
|
||||
//end)
|
||||
//
|
||||
//----
|
||||
//--Destroy Phone
|
||||
//--
|
||||
//
|
||||
//ESX.RegisterServerCallback('phone:removephone', function(source, cb, item)
|
||||
// local xPlayer = ESX.GetPlayerFromId(source)
|
||||
// local items = xPlayer.getInventoryItem(item)
|
||||
//
|
||||
// if items == nil then
|
||||
// cb(0)
|
||||
// else
|
||||
// cb(items.count)
|
||||
// if items.count > 0 then
|
||||
// xPlayer.removeInventoryItem('phone', items.count)
|
||||
// xPlayer.addInventoryItem('dphone', items.count)
|
||||
// end
|
||||
// end
|
||||
//end)
|
||||
Reference in new issue
Block a user