mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
Update main.lua
This commit is contained in:
@@ -9,10 +9,10 @@ AddEventHandler('esx_holdup:tooFar', function(currentStore)
|
||||
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)
|
||||
robbers[_source] = nil
|
||||
ESX.ClearTimeout(robbers[_source])
|
||||
robbers[_source] = nil
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('robbery_cancelled_at', Stores[currentStore].nameOfStore))
|
||||
end
|
||||
end)
|
||||
@@ -21,53 +21,40 @@ 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')
|
||||
if #xPlayers >= Config.PoliceNumberRequired then
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
Stores[currentStore].lastRobbed = os.time()
|
||||
robbers[_source] = currentStore
|
||||
|
||||
SetTimeout(store.secondsRemaining * 1000, function()
|
||||
if robbers[_source] then
|
||||
rob = false
|
||||
if xPlayer then
|
||||
TriggerClientEvent('esx_holdup:robberyComplete', _source, store.reward)
|
||||
|
||||
if Config.GiveBlackMoney then
|
||||
xPlayer.addAccountMoney('black_money', store.reward)
|
||||
else
|
||||
xPlayer.addMoney(store.reward)
|
||||
end
|
||||
|
||||
local xPlayers = ESX.GetExtendedPlayers('job', 'police')
|
||||
for _, xPlayer in pairs(xPlayers) do
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('robbery_complete_at', store.nameOfStore))
|
||||
TriggerClientEvent('esx_holdup:killBlip', xPlayer.source)
|
||||
end
|
||||
end
|
||||
end
|
||||
robbers[_source] = ESX.SetTimeout(store.secondsRemaining * 1000, function()
|
||||
rob = false
|
||||
if xPlayer then
|
||||
TriggerClientEvent('esx_holdup:robberyComplete', _source, store.reward)
|
||||
if Config.GiveBlackMoney then
|
||||
xPlayer.addAccountMoney('black_money', store.reward)
|
||||
else
|
||||
xPlayer.addMoney(store.reward)
|
||||
end
|
||||
local xPlayers = ESX.GetExtendedPlayers('job', 'police')
|
||||
for _, xPlayer in pairs(xPlayers) do
|
||||
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('robbery_complete_at', store.nameOfStore))
|
||||
TriggerClientEvent('esx_holdup:killBlip', xPlayer.source)
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('min_police', Config.PoliceNumberRequired))
|
||||
|
||||
Reference in New Issue
Block a user