mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 06:28:51 +00:00
update DatabaseConfig to have more flexibility in the future
This commit is contained in:
1 parent
96a3f7895a
commit
52f94fed7b
3 files changed
+12
-10
No files matched your search
@@ -4,12 +4,14 @@
|
||||
-- is possible. This mappings default to values that work with ESX.
|
||||
------
|
||||
DatabaseConfig = {
|
||||
userTable = 'users',
|
||||
-- all of the following columns are required to be in the userTable
|
||||
id = 'identifier', -- unique id of a player
|
||||
firstName = 'firstname', -- character's first name
|
||||
lastName = 'lastname', -- character's last name
|
||||
phoneNumber = 'phone_number' -- character's phone number
|
||||
users = {
|
||||
table = 'users',
|
||||
-- columns in the table
|
||||
id = 'another_identifier',
|
||||
firstName = 'my_first_name',
|
||||
lastName = 'my_last_name',
|
||||
phoneNumber = 'my_phone_number'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +21,7 @@ Config.Locale = 'en'
|
||||
|
||||
Config.KeyTogglePhone = 288 -- F1
|
||||
Config.KeyTakeCall = 38 -- E
|
||||
Config.PhoneAsItem = true
|
||||
Config.PhoneAsItem = false
|
||||
|
||||
------
|
||||
--Destroy Phone
|
||||
|
||||
@@ -9,7 +9,7 @@ TriggerEvent(
|
||||
)
|
||||
|
||||
function getIdentifierByNumber(phoneNumber)
|
||||
local result = MySQL.Sync.fetchAll("SELECT " .. db.id .. " AS identifier FROM " .. db.userTable .. " WHERE " .. db.phoneNumber .. " = @phone_number", {
|
||||
local result = MySQL.Sync.fetchAll("SELECT " .. db.users.id .. " AS identifier FROM " .. db.users.table .. " WHERE " .. db.users.phoneNumber .. " = @phone_number", {
|
||||
['@phone_number'] = phoneNumber
|
||||
})
|
||||
if result[1] ~= nil then
|
||||
@@ -19,7 +19,7 @@ function getIdentifierByNumber(phoneNumber)
|
||||
end
|
||||
|
||||
function getPhoneNumber(identifier)
|
||||
local result = MySQL.Sync.fetchAll("SELECT " .. db.phoneNumber .. " AS phone_number FROM " .. db.userTable .. " WHERE " .. db.id .. " = @identifier", {
|
||||
local result = MySQL.Sync.fetchAll("SELECT " .. db.users.phoneNumber .. " AS phone_number FROM " .. db.users.table .. " WHERE " .. db.users.id .. " = @identifier", {
|
||||
['@identifier'] = identifier
|
||||
})
|
||||
if result[1] ~= nil then
|
||||
|
||||
@@ -11,7 +11,7 @@ AddEventHandler('phone:getCredentials', function()
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local _identifier = xPlayer.getIdentifier()
|
||||
MySQL.Async.fetchAll('SELECT ' .. db.phoneNumber .. ' AS phone_number FROM ' .. db.userTable .. ' WHERE ' .. db.id .. '=@identifier',
|
||||
MySQL.Async.fetchAll('SELECT ' .. db.users.phoneNumber .. ' AS phone_number FROM ' .. db.users.table .. ' WHERE ' .. db.users.id .. '=@identifier',
|
||||
{
|
||||
['@identifier'] = _identifier
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user