Repository navigation
Expand file tree
/
Copy pathserver.lua
More file actions
68 lines (60 loc) · 2 KB
/
Copy pathserver.lua
File metadata and controls
68 lines (60 loc) · 2 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
GlobalState.GettingRobbed = false
RegisterNetEvent('FinishRobbery')
AddEventHandler('FinishRobbery', function()
local cashMoney = Config.cashPayout
local chance = math.random(1, 10)
exports.ox_inventory:RemoveItem(source, 'advanced_lockpick', 1)
exports.ox_inventory:AddItem(source, 'money', cashMoney)
if chance >= 4 then
exports.ox_inventory:AddItem(source, 'safecracker', 1)
end
TimerThread()
end)
RegisterNetEvent('FinishSafeRobbery')
AddEventHandler('FinishSafeRobbery', function()
local cashMoney = Config.safePayout
local chance = math.random(1, 10)
exports.ox_inventory:RemoveItem(source, 'safecracker', 1)
exports.ox_inventory:AddItem(source, 'money', cashMoney)
if chance >= 4 then
exports.ox_inventory:AddItem(source, Config.rewardItem, 1)
end
TimerThread()
end)
RegisterNetEvent('FailRobbery')
AddEventHandler('FailRobbery', function()
exports.ox_inventory:RemoveItem(source, 'advanced_lockpick', 1)
end)
function TimerThread()
print('TimerThread')
GlobalState.GettingRobbed = true
local magicMath = Config.Cooldown * 60000
Wait(magicMath)
GlobalState.GettingRobbed = false
end
local function getPoliceOnline()
local NDCore = exports["ND_Core"]
local amount = 0
local policeDepartments = {"sahp", "lspd", "bcso"}
local players = NDCore.getPlayers()
for _, player in pairs(players) do
if lib.table.contains(policeDepartments, player.job) then
amount += 1
end
end
return amount
end
--policecount
if Config.framework == 'esx' then
ESX = exports["es_extended"]:getSharedObject()
local count = #ESX.GetExtendedPlayers('job', 'police')
GlobalState.police = count
elseif Config.framework == 'nd' then
local NDCore = exports["ND_Core"]
GlobalState.police = getPoliceOnline()
elseif Config.framework == 'ox' then
--coming soon
elseif Config.framework == 'qb-core' then
local QBCore = exports['qb-core']:GetCoreObject()
GlobalState.police = QBCore.Functions.GetDutyCount('police')
end