-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathserver.lua
94 lines (88 loc) · 3.81 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
ESX.RegisterServerCallback('loffe_burglary:getDoorFreezeStatus', function(source, cb, house)
cb(Config.Burglary[house].Door.Frozen)
end)
ESX.RegisterServerCallback('loffe_burglary:getDoorHealth', function(source, cb, house)
cb(Config.Burglary[house].Door.Health)
end)
RegisterServerEvent('loffe_burglary:setDoorFreezeStatus')
AddEventHandler('loffe_burglary:setDoorFreezeStatus', function(house, status)
if status == false then
local src = source
local cops = 0
local xPlayers = ESX.GetPlayers()
for i = 1, #xPlayers do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
cops = cops + 1
end
end
if cops >= Config.Burglary[house].Cops then
Config.Burglary[house].Door.Frozen = status
else
sendNotification(src, 'Det är inte tillräckligt med poliser online!', 'error', 3500)
end
else
Config.Burglary[house].Door.Frozen = status
Config.Burglary[house].Door.Health = 1000
TriggerClientEvent('loffe_burglary:setHealth', -1, house, Config.Burglary[house].Door.Health)
end
TriggerClientEvent('loffe_burglary:setFrozen', -1, house, Config.Burglary[house].Door.Frozen)
end)
RegisterServerEvent('loffe_burglary:setDoorHealth')
AddEventHandler('loffe_burglary:setDoorHealth', function(house, health)
local src = source
local cops = 0
local xPlayers = ESX.GetPlayers()
for i = 1, #xPlayers do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
cops = cops + 1
end
end
if cops >= Config.Burglary[house].Cops then
Config.Burglary[house].Door.Health = health
else
sendNotification(src, 'Det är inte tillräckligt med poliser online!', 'error', 3500)
end
TriggerClientEvent('loffe_burglary:setHealth', -1, house, Config.Burglary[house].Door.Health)
end)
RegisterServerEvent('loffe_burglary:loot')
AddEventHandler('loffe_burglary:loot', function(house, furniture)
local src = source
local cops = 0
local xPlayers = ESX.GetPlayers()
for i = 1, #xPlayers do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == 'police' then
cops = cops + 1
end
end
if cops >= Config.Burglary[house].Cops then
Config.Burglary[house].MultipleSearch[furniture].Items = Config.Burglary[house].MultipleSearch[furniture].Items - 1
TriggerClientEvent('loffe_burglary:setItems', -1, house, furniture, Config.Burglary[house].MultipleSearch[furniture].Items)
Wait(6500)
local xPlayer = ESX.GetPlayerFromId(src)
local randomItem = math.random(1, #Config.Items)
local randomAmount = math.random(1, 3)
if Config.Items[randomItem].Amount ~= nil then
xPlayer.addInventoryItem(Config.Items[randomItem].Name, Config.Items[randomItem].Amount)
sendNotification(src, 'Du hittade ' .. Config.Items[randomItem].Amount .. ' ' .. Config.Items[randomItem].Label)
else
xPlayer.addInventoryItem(Config.Items[randomItem].Name, randomAmount)
sendNotification(src, 'Du hittade ' .. randomAmount .. ' ' .. Config.Items[randomItem].Label)
end
else
sendNotification(src, 'Det är inte tillräckligt med poliser online!', 'error', 3500)
end
end)
function sendNotification(xSource, message, messageType, messageTimeout)
TriggerClientEvent("pNotify:SendNotification", xSource, {
text = message,
type = messageType,
queue = "lmfao",
timeout = messageTimeout,
layout = "bottomCenter"
})
end