Working database interactions and NUI callbacks

This commit is contained in:
erik-sn committed 2020-09-24 23:25:35 -04:00
1 parent 1e900baab9
commit ba0f122938
19 files changed
+372 -127

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj)
ESX = obj
end)
ESX.RegisterServerCallback('phone:fetchTweets', function(source, cb)
print('RegisterServerCallback: phone:fetchTweets')
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local _identifier = xPlayer.getIdentifier()
MySQL.Async.fetchAll('SELECT * FROM npwd_twitter_tweets WHERE visible = 1 ORDER BY updatedAt DESC', {}, function(tweets)
cb(tweets)
end)
end)
ESX.RegisterServerCallback('phone:createTweet', function(source, cb, data)
print('RegisterServerEvent: phone:createTweet')
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local _identifier = xPlayer.getIdentifier()
MySQL.Async.execute('INSERT INTO npwd_twitter_tweets (`identifier`, `realUser`, `message`) VALUES (@identifier, @realUser, @message)',
{
['identifier'] = _identifier,
['realUser'] = data.realUser,
['message'] = data.message
}, function(result)
cb(result)
end)
end)