mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Working database interactions and NUI callbacks
This commit is contained in:
1 parent
1e900baab9
commit
ba0f122938
19 files changed
+372
-127
No files matched your search
@@ -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)
|
||||
Reference in new issue
Block a user