mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
sellout server cleanup
This commit is contained in:
1 parent
a3d8285265
commit
c8af1fc61f
1 file changed
+25
-14
@@ -4,26 +4,27 @@ import { ESX } from './server';
|
|||||||
import { getSource } from "./functions";
|
import { getSource } from "./functions";
|
||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import { usePhoneNumber } from './functions';
|
import { usePhoneNumber } from './functions';
|
||||||
|
import { Listings} from "../../phone/src/common/typings/listings";
|
||||||
|
|
||||||
|
|
||||||
interface Listing {
|
/*
|
||||||
title: string;
|
Fetches all the listings and returns an array of objects
|
||||||
name: string;
|
*/
|
||||||
url?: string;
|
async function fetchAllListings(): Promise<Listings[]> {
|
||||||
description: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function fetchAllListings(): Promise<Listing[]> {
|
|
||||||
const query = "SELECT * FROM npwd_sellout_listings ORDER BY id DESC";
|
const query = "SELECT * FROM npwd_sellout_listings ORDER BY id DESC";
|
||||||
|
|
||||||
const [ results ] = await pool.query(query);
|
const [ results ] = await pool.query(query);
|
||||||
const listings = <Listing[]>results;
|
return <Listings[]>results;
|
||||||
|
|
||||||
return listings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addListing(identifier: string, name: string, number: any, listing: Listing): Promise<any> {
|
/**
|
||||||
|
* Adds the note to the database with the player identifier and the note.
|
||||||
|
* @param identifier A players unique identifier
|
||||||
|
* @param name The player in-game name
|
||||||
|
* @param number The players phone number
|
||||||
|
* @param listing The listing object
|
||||||
|
*/
|
||||||
|
async function addListing(identifier: string, name: string, number: string, listing: Listings): Promise<any> {
|
||||||
const query = "INSERT INTO npwd_sellout_listings (identifier, name, number, title, url, description) VALUES (?, ?, ?, ?, ?, ?)"
|
const query = "INSERT INTO npwd_sellout_listings (identifier, name, number, title, url, description) VALUES (?, ?, ?, ?, ?, ?)"
|
||||||
await pool.query(query, [
|
await pool.query(query, [
|
||||||
identifier,
|
identifier,
|
||||||
@@ -35,6 +36,9 @@ async function addListing(identifier: string, name: string, number: any, listing
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Event that sends the listings to client, which sends to NUI
|
||||||
|
*/
|
||||||
onNet(events.SELLOUT_FETCH_LISTING, async () => {
|
onNet(events.SELLOUT_FETCH_LISTING, async () => {
|
||||||
try {
|
try {
|
||||||
const _source = (global as any).source;
|
const _source = (global as any).source;
|
||||||
@@ -46,7 +50,10 @@ onNet(events.SELLOUT_FETCH_LISTING, async () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onNet(events.SELLOUT_ADD_LISTING, async (listing: Listing) => {
|
/*
|
||||||
|
Event
|
||||||
|
*/
|
||||||
|
onNet(events.SELLOUT_ADD_LISTING, async (listing: Listings) => {
|
||||||
try {
|
try {
|
||||||
const xPlayer = ESX.GetPlayerFromId(getSource())
|
const xPlayer = ESX.GetPlayerFromId(getSource())
|
||||||
const _identifier = xPlayer.getIdentifier()
|
const _identifier = xPlayer.getIdentifier()
|
||||||
@@ -58,3 +65,7 @@ onNet(events.SELLOUT_ADD_LISTING, async (listing: Listing) => {
|
|||||||
console.log("Failed to add contact: ", error)
|
console.log("Failed to add contact: ", error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onNet('phone:createExternalProccess', async () => {
|
||||||
|
|
||||||
|
})
|
||||||
Reference in new issue
Block a user