forked from MIguel-tech/lj-hud-1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.lua
More file actions
80 lines (72 loc) · 2.82 KB
/
server.lua
File metadata and controls
80 lines (72 loc) · 2.82 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
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
76
77
78
79
80
local QBCore = exports['qb-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)
if QBCore.Functions.HasPermission(source, 'admin') then
TriggerClientEvent("qb-admin:client:ToggleDevmode", source)
else
TriggerClientEvent('QBCore:Notify', source, 'No Access To This Command ', 'error')
end
end)
RegisterNetEvent('hud:server:GainStress', function(amount)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local newStress
if Player ~= nil and Player.PlayerData.job.name ~= 'police' then
if not ResetStress then
if Player.PlayerData.metadata['stress'] == nil 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, 'Getting Stressed', 'error', 1500)
end
end)
RegisterNetEvent('hud:server:RelieveStress', function(amount)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local newStress
if Player ~= nil then
if not ResetStress then
if Player.PlayerData.metadata['stress'] == nil 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, 'You Are Relaxing')
end
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)