-
Notifications
You must be signed in to change notification settings - Fork 210
/
server.lua
70 lines (64 loc) · 2.59 KB
/
server.lua
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
local QBCore = exports['qb-core']:GetCoreObject()
local ResetStress = false
QBCore.Commands.Add('cash', 'Check Cash Balance', {}, false, function(source, _)
local Player = QBCore.Functions.GetPlayer(source)
local cashamount = Player.PlayerData.money.cash
TriggerClientEvent('hud:client:ShowAccounts', source, 'cash', cashamount)
end)
QBCore.Commands.Add('bank', 'Check Bank Balance', {}, false, function(source, _)
local Player = QBCore.Functions.GetPlayer(source)
local bankamount = Player.PlayerData.money.bank
TriggerClientEvent('hud:client:ShowAccounts', source, 'bank', bankamount)
end)
QBCore.Commands.Add('dev', 'Enable/Disable developer Mode', {}, false, function(source, _)
TriggerClientEvent('qb-admin:client:ToggleDevmode', source)
end, 'admin')
RegisterNetEvent('hud:server:GainStress', function(amount)
if Config.DisableStress then return end
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local Job = Player.PlayerData.job.name
local JobType = Player.PlayerData.job.type
local newStress
if not Player or Config.WhitelistedJobs[JobType] or Config.WhitelistedJobs[Job] then return end
if not ResetStress then
if not Player.PlayerData.metadata['stress'] then
Player.PlayerData.metadata['stress'] = 0
end
newStress = Player.PlayerData.metadata['stress'] + amount
if newStress <= 0 then newStress = 0 end
else
newStress = 0
end
if newStress > 100 then
newStress = 100
end
Player.Functions.SetMetaData('stress', newStress)
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
TriggerClientEvent('QBCore:Notify', src, Lang:t('notify.stress_gain'), 'error', 1500)
end)
RegisterNetEvent('hud:server:RelieveStress', function(amount)
if Config.DisableStress then return end
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local newStress
if not Player then return end
if not ResetStress then
if not Player.PlayerData.metadata['stress'] then
Player.PlayerData.metadata['stress'] = 0
end
newStress = Player.PlayerData.metadata['stress'] - amount
if newStress <= 0 then newStress = 0 end
else
newStress = 0
end
if newStress > 100 then
newStress = 100
end
Player.Functions.SetMetaData('stress', newStress)
TriggerClientEvent('hud:client:UpdateStress', src, newStress)
TriggerClientEvent('QBCore:Notify', src, Lang:t('notify.stress_removed'))
end)
QBCore.Functions.CreateCallback('hud:server:getMenu', function(_, cb)
cb(Config.Menu)
end)