-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathserver.lua
75 lines (69 loc) · 2.71 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
71
72
73
74
75
local QBCore = exports[Config.Core]:GetCoreObject()
local ResetStress = false
QBCore.Commands.Add('cash', 'Check Cash Balance', {}, false, function(source, args)
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, args)
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, args)
TriggerClientEvent("qb-admin:client:ToggleDevmode", source)
end, 'admin')
RegisterNetEvent('hud:server:GainStress', function(amount)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local newStress
if not Player or (Config.DisablePoliceStress and Player.PlayerData.job.name == 'police') 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)
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:HasHarness', function(source, cb)
local Ply = QBCore.Functions.GetPlayer(source)
local Harness = Ply.Functions.GetItemByName("harness")
if Harness ~= nil then
cb(true)
else
cb(false)
end
end)
QBCore.Functions.CreateCallback('hud:server:getMenu', function(source, cb)
cb(Config.Menu)
end)