-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsv_rapine.lua
139 lines (135 loc) · 7.67 KB
/
sv_rapine.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
local rob = false
local robbers = {}
RegisterServerEvent('esx_holdup:tooFar')
AddEventHandler('esx_holdup:tooFar', function(currentStore)
local _source = source
rob = false
if string.find(Stores[currentStore].nameOfStore, 'Gabriela') then
webhook = "https://discord.com/api/webhooks/1047321454397632512/3988mCSE5Y0BMf_CxohKVgPKHxZlTl1bNAV6exvVK1TQEQEak-oVG8NEeVgyQc8r3b08"
elseif string.find(Stores[currentStore].nameOfStore, 'Fleeca') then
webhook = "https://discord.com/api/webhooks/1047321454397632512/3988mCSE5Y0BMf_CxohKVgPKHxZlTl1bNAV6exvVK1TQEQEak-oVG8NEeVgyQc8r3b08"
elseif string.find(Stores[currentStore].nameOfStore, 'Blaine') then
webhook = "https://discord.com/api/webhooks/1047321454397632512/3988mCSE5Y0BMf_CxohKVgPKHxZlTl1bNAV6exvVK1TQEQEak-oVG8NEeVgyQc8r3b08"
elseif string.find(Stores[currentStore].nameOfStore, 'Pacific') then
webhook = "https://discord.com/api/webhooks/1047321454397632512/3988mCSE5Y0BMf_CxohKVgPKHxZlTl1bNAV6exvVK1TQEQEak-oVG8NEeVgyQc8r3b08"
else
webhook = "https://discord.com/api/webhooks/1047321454397632512/3988mCSE5Y0BMf_CxohKVgPKHxZlTl1bNAV6exvVK1TQEQEak-oVG8NEeVgyQc8r3b08"
end
local msg = "Il player **"..GetPlayerName(_source).."** ha annullato una rapina al **"..Stores[currentStore].nameOfStore.."**"
ESX.Log(webhook, msg)
for _, xPlayer in pairs(ESX.GetExtendedPlayers('job', 'police')) do
--TriggerClientEvent('esx:showNotification', xPlayer.source, _U('robbery_cancelled_at', Stores[currentStore].nameOfStore))
TriggerClientEvent('esx_holdup:killBlip', xPlayer.source)
end
for _, xPlayer in pairs(ESX.GetExtendedPlayers('job', 'sceriffo')) do
--TriggerClientEvent('esx:showNotification', xPlayer.source, _U('robbery_cancelled_at', Stores[currentStore].nameOfStore))
TriggerClientEvent('esx_holdup:killBlip', xPlayer.source)
end
if robbers[_source] then
TriggerClientEvent('esx_holdup:tooFar', _source)
ESX.ClearTimeout(robbers[_source])
robbers[_source] = nil
TriggerClientEvent('esx:showNotification', _source, _U('robbery_cancelled_at', Stores[currentStore].nameOfStore))
end
end)
RegisterServerEvent('esx_holdup:robberyStarted')
AddEventHandler('esx_holdup:robberyStarted', function(currentStore)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
if Stores[currentStore] then
local store = Stores[currentStore]
if (os.time() - store.lastRobbed) < Config.TimerBeforeNewRob and store.lastRobbed ~= 0 then
TriggerClientEvent('esx:showNotification', _source, _U('recently_robbed', Config.TimerBeforeNewRob - (os.time() - store.lastRobbed)))
return
end
if not rob then
local xPlayers = ESX.GetExtendedPlayers('job', 'police')
local xPlayers2 = ESX.GetExtendedPlayers('job', 'sceriffo')
if #xPlayers + #xPlayers2 >= store.cops then
local webhook = nil
rob = true
for _, xPlayer in pairs(xPlayers) do
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('rob_in_prog', store.nameOfStore))
TriggerClientEvent('esx_holdup:setBlip', xPlayer.source, Stores[currentStore].position)
end
for _, xPlayer in pairs(xPlayers2) do
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('rob_in_prog', store.nameOfStore))
TriggerClientEvent('esx_holdup:setBlip', xPlayer.source, Stores[currentStore].position)
end
if string.find(store.nameOfStore, 'Gabriela') then
webhook = "https://discord.com/api/webhooks/1047321728226959520/TI03VswaO7HFjd10jOP1p6TrvUO-iigz11Z5h8m7KpW4NHpgE-XvAkswSHi0YqPWCcIM"
elseif string.find(store.nameOfStore, 'Fleeca') then
webhook = "https://discord.com/api/webhooks/1047321807876788234/rdViz_IBw9PGWI8zZDjz3WN6zyau-jDkqJYlrR1fcgxKl1M6E2xLGjodYvf-2tAjzO2j"
elseif string.find(store.nameOfStore, 'Blaine') then
webhook = "https://discord.com/api/webhooks/1047321915339059321/s5F4x-gQXBIgrlDiMHHFJjZ2R9Ai-EfuADRctKDSxKyJPAoMKd1qawe18Qkv2e6_yshM"
elseif string.find(store.nameOfStore, 'Pacific') then
webhook = "https://discord.com/api/webhooks/1077994611160645713/ydnxqA-rsHwkNBtRPTzlEWBXif2dAjdevLuw6lexov09FvwL1XPaZiYX4MVVWgotUTkA"
else
webhook = "https://discord.com/api/webhooks/1047322001511039097/5yL06FlkxZ3HuSvshdaORgsOq1fGHZPo72l0uMVW0MCgUGagwBPnGLWTOGgQyiFafdzC"
end
local msg = "Il player **"..GetPlayerName(_source).."** ha avviato una rapina al **"..store.nameOfStore.."**"
ESX.Log(webhook, msg)
TriggerClientEvent('esx:showNotification', _source, _U('started_to_rob', store.nameOfStore))
TriggerClientEvent('esx:showNotification', _source, _U('alarm_triggered'))
TriggerClientEvent('esx_holdup:currentlyRobbing', _source, currentStore)
TriggerClientEvent('esx_holdup:startTimer', _source)
TriggerClientEvent('flr:iniziarap', _source)
Stores[currentStore].lastRobbed = os.time()
Stores[currentStore].RobberSource = _source
robbers[_source] = ESX.SetTimeout(store.secondsRemaining * 1000, function()
rob = false
if xPlayer and Stores[currentStore].RobberSource then
Stores[currentStore].RobberSource = nil
TriggerClientEvent('esx_holdup:robberyComplete', _source, store.reward)
if Config.GiveBlackMoney then
xPlayer.addInventoryItem('black_money', store.reward)
else
xPlayer.addMoney(store.reward)
end
local xPlayers = ESX.GetExtendedPlayers('job', 'police')
local xPlayers2 = ESX.GetExtendedPlayers('job', 'sceriffo')
for _, xPlayer in pairs(xPlayers) do
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('robbery_complete_at', store.nameOfStore))
TriggerClientEvent('esx_holdup:killBlip', xPlayer.source)
end
for _, xPlayer in pairs(xPlayers2) do
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('robbery_complete_at', store.nameOfStore))
TriggerClientEvent('esx_holdup:killBlip', xPlayer.source)
end
end
end)
else
TriggerClientEvent('flr:stopparap', _source)
TriggerClientEvent('esx:showNotification', _source, _U('min_police', store.cops))
end
else
TriggerClientEvent('esx:showNotification', _source, 'I Poliziotti sono impegnati in altre rapine al momento!')
end
end
end)
RegisterServerEvent('esx_holdup:StopTimer', function(market)
local _source = source
if Stores[market].RobberSource then
local xPlayer = ESX.GetPlayerFromId(Stores[market].RobberSource)
TriggerClientEvent('esx_holdup:ConfirmStop', Stores[market].RobberSource)
TriggerClientEvent('esx_holdup:robberyComplete', Stores[market].RobberSource, Stores[market].reward)
if Config.GiveBlackMoney then
xPlayer.addInventoryItem('black_money', Stores[market].reward)
else
xPlayer.addMoney(Stores[market].reward)
end
local xPlayers = ESX.GetExtendedPlayers('job', 'police')
local xPlayers2 = ESX.GetExtendedPlayers('job', 'sceriffo')
for _, xPlayer in pairs(xPlayers) do
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('robbery_complete_at', Stores[market].nameOfStore))
TriggerClientEvent('esx_holdup:killBlip', xPlayer.source)
end
for _, xPlayer in pairs(xPlayers2) do
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('robbery_complete_at', Stores[market].nameOfStore))
TriggerClientEvent('esx_holdup:killBlip', xPlayer.source)
end
Stores[market].RobberSource = nil
else
TriggerClientEvent('esx:showNotification', _source, 'Non è in corso nessuna rapina qua!')
end
end)