mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
add database config object
Adds a DatabaseConfig dictionary which will allow an admin to specify a custom table/columns that exist outside of ESX. This gives us flexibility between ESX versions as well as making the phone frameworkas decoupled from ESX as possible. Also updates the contacts table to be namespaces with npwd
This commit is contained in:
1 parent
3a172a425b
commit
cb75d2f5cc
5 files changed
+27
-7
No files matched your search
@@ -1,4 +1,5 @@
|
||||
ESX = nil
|
||||
db = DatabaseConfig -- helper variable for use in server functions
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj)
|
||||
ESX = obj
|
||||
@@ -8,7 +9,7 @@ ESX.RegisterServerCallback('phone:getContacts', function(source, cb)
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local _identifier = xPlayer.getIdentifier()
|
||||
MySQL.Async.fetchAll('SELECT * FROM phone_contacts WHERE `identifier`=@identifier',
|
||||
MySQL.Async.fetchAll('SELECT * FROM npwd_phone_contacts WHERE `identifier`=@identifier',
|
||||
{
|
||||
['@identifier'] = _identifier
|
||||
}, function(contacts)
|
||||
@@ -26,7 +27,7 @@ AddEventHandler('phone:addContacts', function(display, number)
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local _identifier = xPlayer.getIdentifier()
|
||||
print(display, number)
|
||||
MySQL.Async.execute('INSERT INTO phone_contacts (`identifier`, `number`, `display`) VALUES (@identifier, @number, @display)',
|
||||
MySQL.Async.execute('INSERT INTO npwd_phone_contacts (`identifier`, `number`, `display`) VALUES (@identifier, @number, @display)',
|
||||
{
|
||||
identifier = _identifier,
|
||||
number = number,
|
||||
|
||||
Reference in new issue
Block a user