mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +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.
|
-- is possible. This mappings default to values that work with ESX.
|
||||||
------
|
------
|
||||||
DatabaseConfig = {
|
DatabaseConfig = {
|
||||||
userTable = 'users',
|
users = {
|
||||||
-- all of the following columns are required to be in the userTable
|
table = 'users',
|
||||||
id = 'identifier', -- unique id of a player
|
-- columns in the table
|
||||||
firstName = 'firstname', -- character's first name
|
id = 'another_identifier',
|
||||||
lastName = 'lastname', -- character's last name
|
firstName = 'my_first_name',
|
||||||
phoneNumber = 'phone_number' -- character's phone number
|
lastName = 'my_last_name',
|
||||||
|
phoneNumber = 'my_phone_number'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -19,7 +21,7 @@ Config.Locale = 'en'
|
|||||||
|
|
||||||
Config.KeyTogglePhone = 288 -- F1
|
Config.KeyTogglePhone = 288 -- F1
|
||||||
Config.KeyTakeCall = 38 -- E
|
Config.KeyTakeCall = 38 -- E
|
||||||
Config.PhoneAsItem = true
|
Config.PhoneAsItem = false
|
||||||
|
|
||||||
------
|
------
|
||||||
--Destroy Phone
|
--Destroy Phone
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ TriggerEvent(
|
|||||||
)
|
)
|
||||||
|
|
||||||
function getIdentifierByNumber(phoneNumber)
|
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
|
['@phone_number'] = phoneNumber
|
||||||
})
|
})
|
||||||
if result[1] ~= nil then
|
if result[1] ~= nil then
|
||||||
@@ -19,7 +19,7 @@ function getIdentifierByNumber(phoneNumber)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function getPhoneNumber(identifier)
|
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
|
['@identifier'] = identifier
|
||||||
})
|
})
|
||||||
if result[1] ~= nil then
|
if result[1] ~= nil then
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ AddEventHandler('phone:getCredentials', function()
|
|||||||
local _source = source
|
local _source = source
|
||||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||||
local _identifier = xPlayer.getIdentifier()
|
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
|
['@identifier'] = _identifier
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user