-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lua
More file actions
48 lines (43 loc) · 1.61 KB
/
Copy pathserver.lua
File metadata and controls
48 lines (43 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
local ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
ESX.RegisterServerCallback('dahood:getSettings', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
local playerId = xPlayer.identifier
MySQL.Async.fetchAll('SELECT * FROM dahood_settings WHERE player_id = @player_id', {
['@player_id'] = playerId
}, function(result)
if result[1] then
cb(result[1])
else
MySQL.Async.execute('INSERT INTO dahood_settings (player_id) VALUES (@player_id)', {
['@player_id'] = playerId
}, function()
cb({
silent_aim = true,
esp = true,
fog_changer = true,
head_invisibility = true,
radius = 50.0,
hitbox_expander = true,
visibility = 1.0
})
end)
end
end)
end)
RegisterNetEvent('dahood:updateSettings')
AddEventHandler('dahood:updateSettings', function(setting, value)
local xPlayer = ESX.GetPlayerFromId(source)
local playerId = xPlayer.identifier
MySQL.Async.execute('UPDATE dahood_settings SET ' .. setting .. ' = @value WHERE player_id = @player_id', {
['@value'] = value,
['@player_id'] = playerId
}, function(rowsChanged)
if rowsChanged == 0 then
MySQL.Async.execute('INSERT INTO dahood_settings (player_id, ' .. setting .. ') VALUES (@player_id, @value)', {
['@player_id'] = playerId,
['@value'] = value
})
end
end)
end)