From ab2b32b2304ff6107576ecb2c790d86e354650ea Mon Sep 17 00:00:00 2001 From: LuaDeldu Date: Thu, 2 Nov 2017 00:04:36 +0100 Subject: [PATCH 1/3] chore(coding-style): correct indentation --- __resource.lua | 28 ++++---- client/esx_holdup_cl.lua | 142 ++++++++++++++++++------------------- config.lua | 96 ++++++++++++------------- locales/br.lua | 38 +++++----- locales/de.lua | 38 +++++----- locales/en.lua | 38 +++++----- locales/fr.lua | 38 +++++----- server/esx_holdup_sv.lua | 146 +++++++++++++++++++-------------------- 8 files changed, 282 insertions(+), 282 deletions(-) diff --git a/__resource.lua b/__resource.lua index f159d027..c2697d45 100644 --- a/__resource.lua +++ b/__resource.lua @@ -3,21 +3,21 @@ version '1.0.0' dependency 'essentialmode' client_scripts { - '@es_extended/locale.lua', - 'locales/de.lua', - 'locales/br.lua', - 'locales/en.lua', - 'locales/fr.lua', - 'config.lua', - 'client/esx_holdup_cl.lua' + '@es_extended/locale.lua', + 'locales/de.lua', + 'locales/br.lua', + 'locales/en.lua', + 'locales/fr.lua', + 'config.lua', + 'client/esx_holdup_cl.lua' } server_scripts { - '@es_extended/locale.lua', - 'locales/de.lua', - 'locales/br.lua', - 'locales/en.lua', - 'locales/fr.lua', - 'config.lua', - 'server/esx_holdup_sv.lua' + '@es_extended/locale.lua', + 'locales/de.lua', + 'locales/br.lua', + 'locales/en.lua', + 'locales/fr.lua', + 'config.lua', + 'server/esx_holdup_sv.lua' } diff --git a/client/esx_holdup_cl.lua b/client/esx_holdup_cl.lua index 059b8fda..23e287a5 100644 --- a/client/esx_holdup_cl.lua +++ b/client/esx_holdup_cl.lua @@ -5,16 +5,16 @@ local blipRobbery = nil ESX = nil Citizen.CreateThread(function() - while ESX == nil do - TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) - Citizen.Wait(0) - end + while ESX == nil do + TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) + Citizen.Wait(0) + end end) function DisplayHelpText(str) - SetTextComponentFormat("STRING") - AddTextComponentString(str) - DisplayHelpTextFromStringLabel(0, 0, 1, -1) + SetTextComponentFormat("STRING") + AddTextComponentString(str) + DisplayHelpTextFromStringLabel(0, 0, 1, -1) end function drawTxt(x,y ,width,height,scale, text, r,g,b,a, outline) @@ -26,8 +26,8 @@ function drawTxt(x,y ,width,height,scale, text, r,g,b,a, outline) SetTextEdge(1, 0, 0, 0, 255) SetTextDropShadow() if(outline)then - SetTextOutline() - end + SetTextOutline() + end SetTextEntry("STRING") AddTextComponentString(text) DrawText(x - width/2, y - height/2 + 0.005) @@ -35,9 +35,9 @@ end RegisterNetEvent('esx_holdup:currentlyrobbing') AddEventHandler('esx_holdup:currentlyrobbing', function(robb) - holdingup = true - store = robb - secondsRemaining = 300 + holdingup = true + store = robb + secondsRemaining = 300 end) RegisterNetEvent('esx_holdup:killblip') @@ -56,87 +56,87 @@ end) RegisterNetEvent('esx_holdup:toofarlocal') AddEventHandler('esx_holdup:toofarlocal', function(robb) - holdingup = false - ESX.ShowNotification(_U('robbery_cancelled')) - robbingName = "" - secondsRemaining = 0 - incircle = false + holdingup = false + ESX.ShowNotification(_U('robbery_cancelled')) + robbingName = "" + secondsRemaining = 0 + incircle = false end) RegisterNetEvent('esx_holdup:robberycomplete') AddEventHandler('esx_holdup:robberycomplete', function(robb) - holdingup = false - ESX.ShowNotification(_U('robbery_cancelled') .. Stores[store].reward) - store = "" - secondsRemaining = 0 - incircle = false + holdingup = false + ESX.ShowNotification(_U('robbery_cancelled') .. Stores[store].reward) + store = "" + secondsRemaining = 0 + incircle = false end) Citizen.CreateThread(function() - while true do - Citizen.Wait(0) - if holdingup then - Citizen.Wait(1000) - if(secondsRemaining > 0)then - secondsRemaining = secondsRemaining - 1 - end - end - end + while true do + Citizen.Wait(0) + if holdingup then + Citizen.Wait(1000) + if(secondsRemaining > 0)then + secondsRemaining = secondsRemaining - 1 + end + end + end end) Citizen.CreateThread(function() - for k,v in pairs(Stores)do - local ve = v.position + for k,v in pairs(Stores)do + local ve = v.position - local blip = AddBlipForCoord(ve.x, ve.y, ve.z) - SetBlipSprite(blip, 156) - SetBlipScale(blip, 0.8) - SetBlipAsShortRange(blip, true) - BeginTextCommandSetBlipName("STRING") - AddTextComponentString(_U('shop_robbery')) - EndTextCommandSetBlipName(blip) - end + local blip = AddBlipForCoord(ve.x, ve.y, ve.z) + SetBlipSprite(blip, 156) + SetBlipScale(blip, 0.8) + SetBlipAsShortRange(blip, true) + BeginTextCommandSetBlipName("STRING") + AddTextComponentString(_U('shop_robbery')) + EndTextCommandSetBlipName(blip) + end end) incircle = false Citizen.CreateThread(function() - while true do - local pos = GetEntityCoords(GetPlayerPed(-1), true) + while true do + local pos = GetEntityCoords(GetPlayerPed(-1), true) - for k,v in pairs(Stores)do - local pos2 = v.position + for k,v in pairs(Stores)do + local pos2 = v.position - if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) < 15.0)then - if not holdingup then - DrawMarker(1, v.position.x, v.position.y, v.position.z - 1, 0, 0, 0, 0, 0, 0, 1.0001, 1.0001, 1.5001, 1555, 0, 0,255, 0, 0, 0,0) + if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) < 15.0)then + if not holdingup then + DrawMarker(1, v.position.x, v.position.y, v.position.z - 1, 0, 0, 0, 0, 0, 0, 1.0001, 1.0001, 1.5001, 1555, 0, 0,255, 0, 0, 0,0) - if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) < 1.0)then - if (incircle == false) then - DisplayHelpText(_U('press_to_rob') .. v.nameofstore) - end - incircle = true - if IsControlJustReleased(1, 51) then - TriggerServerEvent('esx_holdup:rob', k) - end - elseif(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 1.0)then - incircle = false - end - end - end - end + if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) < 1.0)then + if (incircle == false) then + DisplayHelpText(_U('press_to_rob') .. v.nameofstore) + end + incircle = true + if IsControlJustReleased(1, 51) then + TriggerServerEvent('esx_holdup:rob', k) + end + elseif(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 1.0)then + incircle = false + end + end + end + end - if holdingup then + if holdingup then - drawTxt(0.66, 1.44, 1.0,1.0,0.4, _U('robbery_of') .. secondsRemaining .. _U('seconds_remaining'), 255, 255, 255, 255) + drawTxt(0.66, 1.44, 1.0,1.0,0.4, _U('robbery_of') .. secondsRemaining .. _U('seconds_remaining'), 255, 255, 255, 255) - local pos2 = Stores[store].position + local pos2 = Stores[store].position - if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 7.5)then - TriggerServerEvent('esx_holdup:toofar', store) - end - end + if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 7.5)then + TriggerServerEvent('esx_holdup:toofar', store) + end + end - Citizen.Wait(0) - end + Citizen.Wait(0) + end end) diff --git a/config.lua b/config.lua index 2ac8d1c9..98332dd7 100644 --- a/config.lua +++ b/config.lua @@ -2,52 +2,52 @@ Config = {} Config.Locale = 'fr' Stores = { - --[["paleto_twentyfourseven"] = { - position = { ['x'] = 1736.32092285156, ['y'] = 6419.4970703125, ['z'] = 35.037223815918 }, - reward = math.random(100,1000), - nameofstore = "24/7. (Paleto Bay)", - lastrobbed = 0 - },]] - ["sandyshores_twentyfoursever"] = { - position = { ['x'] = 1961.24682617188, ['y'] = 3749.46069335938, ['z'] = 32.3437461853027 }, - reward = math.random(500,5000), - nameofstore = "24/7. (Sandy Shores)", - lastrobbed = 0 - }, - ["bar_one"] = { - position = { ['x'] = 1986.1240234375, ['y'] = 3053.8747558594, ['z'] = 47.215171813965 }, - reward = math.random(500,5000), - nameofstore = "Yellow Jack. (Sandy Shores)", - lastrobbed = 0 - }, - ["ocean_liquor"] = { - position = { ['x'] = -2959.33715820313, ['y'] = 388.214172363281, ['z'] = 14.0432071685791 }, - reward = math.random(1000,10000), - nameofstore = "Robs Liquor. (Great Ocean Higway)", - lastrobbed = 0 - }, - ["sanandreas_liquor"] = { - position = { ['x'] = -1219.85607910156, ['y'] = -916.276550292969, ['z'] = 11.3262157440186 }, - reward = math.random(1000,10000), - nameofstore = "Robs Liquor. (San andreas Avenue)", - lastrobbed = 0 - }, - ["grove_ltd"] = { - position = { ['x'] = -43.4035377502441, ['y'] = -1749.20922851563, ['z'] = 29.421012878418 }, - reward = math.random(1000,10000), - nameofstore = "LTD Gasoline. (Grove Street)", - lastrobbed = 0 - }, - ["mirror_ltd"] = { - position = { ['x'] = 1160.67578125, ['y'] = -314.400451660156, ['z'] = 69.2050552368164 }, - reward = math.random(1000,10000), - nameofstore = "LTD Gasoline. (Mirror Park Boulevard)", - lastrobbed = 0 - }, - ["littleseoul_twentyfourseven"] = { - position = { ['x'] = -709.17022705078, ['y'] = -904.21722412109, ['z'] = 19.215591430664 }, - reward = math.random(1000,10000), - nameofstore = "24/7. (Little Seoul)", - lastrobbed = 0 - } + --[["paleto_twentyfourseven"] = { + position = { ['x'] = 1736.32092285156, ['y'] = 6419.4970703125, ['z'] = 35.037223815918 }, + reward = math.random(100,1000), + nameofstore = "24/7. (Paleto Bay)", + lastrobbed = 0 + },]] + ["sandyshores_twentyfoursever"] = { + position = { ['x'] = 1961.24682617188, ['y'] = 3749.46069335938, ['z'] = 32.3437461853027 }, + reward = math.random(500,5000), + nameofstore = "24/7. (Sandy Shores)", + lastrobbed = 0 + }, + ["bar_one"] = { + position = { ['x'] = 1986.1240234375, ['y'] = 3053.8747558594, ['z'] = 47.215171813965 }, + reward = math.random(500,5000), + nameofstore = "Yellow Jack. (Sandy Shores)", + lastrobbed = 0 + }, + ["ocean_liquor"] = { + position = { ['x'] = -2959.33715820313, ['y'] = 388.214172363281, ['z'] = 14.0432071685791 }, + reward = math.random(1000,10000), + nameofstore = "Robs Liquor. (Great Ocean Higway)", + lastrobbed = 0 + }, + ["sanandreas_liquor"] = { + position = { ['x'] = -1219.85607910156, ['y'] = -916.276550292969, ['z'] = 11.3262157440186 }, + reward = math.random(1000,10000), + nameofstore = "Robs Liquor. (San andreas Avenue)", + lastrobbed = 0 + }, + ["grove_ltd"] = { + position = { ['x'] = -43.4035377502441, ['y'] = -1749.20922851563, ['z'] = 29.421012878418 }, + reward = math.random(1000,10000), + nameofstore = "LTD Gasoline. (Grove Street)", + lastrobbed = 0 + }, + ["mirror_ltd"] = { + position = { ['x'] = 1160.67578125, ['y'] = -314.400451660156, ['z'] = 69.2050552368164 }, + reward = math.random(1000,10000), + nameofstore = "LTD Gasoline. (Mirror Park Boulevard)", + lastrobbed = 0 + }, + ["littleseoul_twentyfourseven"] = { + position = { ['x'] = -709.17022705078, ['y'] = -904.21722412109, ['z'] = 19.215591430664 }, + reward = math.random(1000,10000), + nameofstore = "24/7. (Little Seoul)", + lastrobbed = 0 + } } diff --git a/locales/br.lua b/locales/br.lua index f6c50ecb..d058b945 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -1,23 +1,23 @@ Locales['br'] = { - ['robbery_cancelled'] = 'O roubo será cancelado, você não ganhará nada!', - ['robbery_successful'] = 'O roubo foi um sucesso. Você ganhou ~g~$', - ['shop_robbery'] = 'Loja roubavel', - ['press_to_rob'] = 'Pressione ~INPUT_CONTEXT~ para roubar ~b~', - ['robbery_of'] = 'Loja roubavel: ~r~', - ['seconds_remaining'] = '~w~ segundos restantes', - ['robbery_cancelled_at'] = '~r~ Roubo cancelado em: ~b~', - ['robbery_has_cancelled'] = '~r~ O assalto foi cancelado: ~b~', - ['already_robbed'] = 'Esta loja já foi roubada. Por favor, espere: ', - ['seconds'] = 'segundos.', - ['rob_in_prog'] = '~r~ Assalto em curso em: ~b~', - ['started_to_rob'] = 'Você começou a roubar ', - ['do_not_move'] = ', Não se afaste!', - ['alarm_triggered'] = 'O alarme foi disparado', - ['hold_pos'] = 'Segure por 5 minutos e o dinheiro é seu!', - ['robbery_complete'] = '~r~ Roubo completo.~s~ ~h~ Corre!', - ['robbery_complete_at'] = '~r~ Roubo completo em: ~b~', - ['min_two_police'] = 'Deve haver pelo menos ~b~2 policiais~s~ na cidade para roubar.', - ['robbery_already'] = '~r~Um assalto já está em andamento.', + ['robbery_cancelled'] = 'O roubo será cancelado, você não ganhará nada!', + ['robbery_successful'] = 'O roubo foi um sucesso. Você ganhou ~g~$', + ['shop_robbery'] = 'Loja roubavel', + ['press_to_rob'] = 'Pressione ~INPUT_CONTEXT~ para roubar ~b~', + ['robbery_of'] = 'Loja roubavel: ~r~', + ['seconds_remaining'] = '~w~ segundos restantes', + ['robbery_cancelled_at'] = '~r~ Roubo cancelado em: ~b~', + ['robbery_has_cancelled'] = '~r~ O assalto foi cancelado: ~b~', + ['already_robbed'] = 'Esta loja já foi roubada. Por favor, espere: ', + ['seconds'] = 'segundos.', + ['rob_in_prog'] = '~r~ Assalto em curso em: ~b~', + ['started_to_rob'] = 'Você começou a roubar ', + ['do_not_move'] = ', Não se afaste!', + ['alarm_triggered'] = 'O alarme foi disparado', + ['hold_pos'] = 'Segure por 5 minutos e o dinheiro é seu!', + ['robbery_complete'] = '~r~ Roubo completo.~s~ ~h~ Corre!', + ['robbery_complete_at'] = '~r~ Roubo completo em: ~b~', + ['min_two_police'] = 'Deve haver pelo menos ~b~2 policiais~s~ na cidade para roubar.', + ['robbery_already'] = '~r~Um assalto já está em andamento.', } diff --git a/locales/de.lua b/locales/de.lua index 900f6d53..867bf34a 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -1,23 +1,23 @@ Locales['de'] = { - ['robbery_cancelled'] = 'der Raub wurde abgebrochen, du bekommst nichts!', - ['robbery_successful'] = 'Raub erfolgreich du erbeutest ~g~$', - ['shop_robbery'] = 'Ladenraub', - ['press_to_rob'] = 'Drücke ~INPUT_CONTEXT~ zum ausrauben ~b~', - ['robbery_of'] = 'Ladenraub: ~r~', - ['seconds_remaining'] = '~w~ sekunden übrig', - ['robbery_cancelled_at'] = '~r~ Raub abgebrochen bei: ~b~', - ['robbery_has_cancelled'] = '~r~ Raub wurde abgebrochen: ~b~', - ['already_robbed'] = 'dieser Laden wurde bereits ausgeraubt. Bitte warte: ', - ['seconds'] = 'sekunden.', - ['rob_in_prog'] = '~r~ Raub im gange bei: ~b~', - ['started_to_rob'] = 'du hast einen Raub gestartet ', - ['do_not_move'] = ', laufe nicht weg!', - ['alarm_triggered'] = 'der Alarm wurde ausgelöst', - ['hold_pos'] = 'halte 5 Minuten lang durch, und die Beute gehört dir!', - ['robbery_complete'] = '~r~ Raub erfolgreich.~s~ ~h~ LAUF!', - ['robbery_complete_at'] = '~r~ Raub erfolgreich bei: ~b~', - ['min_two_police'] = 'es müssen mindestens ~b~2 Polizisten~s~ im Dienst sein um einen Raub starten zu können.', - ['robbery_already'] = '~r~Ein Raub ist bereits im gange.', + ['robbery_cancelled'] = 'der Raub wurde abgebrochen, du bekommst nichts!', + ['robbery_successful'] = 'Raub erfolgreich du erbeutest ~g~$', + ['shop_robbery'] = 'Ladenraub', + ['press_to_rob'] = 'Drücke ~INPUT_CONTEXT~ zum ausrauben ~b~', + ['robbery_of'] = 'Ladenraub: ~r~', + ['seconds_remaining'] = '~w~ sekunden übrig', + ['robbery_cancelled_at'] = '~r~ Raub abgebrochen bei: ~b~', + ['robbery_has_cancelled'] = '~r~ Raub wurde abgebrochen: ~b~', + ['already_robbed'] = 'dieser Laden wurde bereits ausgeraubt. Bitte warte: ', + ['seconds'] = 'sekunden.', + ['rob_in_prog'] = '~r~ Raub im gange bei: ~b~', + ['started_to_rob'] = 'du hast einen Raub gestartet ', + ['do_not_move'] = ', laufe nicht weg!', + ['alarm_triggered'] = 'der Alarm wurde ausgelöst', + ['hold_pos'] = 'halte 5 Minuten lang durch, und die Beute gehört dir!', + ['robbery_complete'] = '~r~ Raub erfolgreich.~s~ ~h~ LAUF!', + ['robbery_complete_at'] = '~r~ Raub erfolgreich bei: ~b~', + ['min_two_police'] = 'es müssen mindestens ~b~2 Polizisten~s~ im Dienst sein um einen Raub starten zu können.', + ['robbery_already'] = '~r~Ein Raub ist bereits im gange.', } diff --git a/locales/en.lua b/locales/en.lua index 6e6ce02d..80a51126 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,23 +1,23 @@ Locales['en'] = { - ['robbery_cancelled'] = 'the robbery will be cancelled, you will gain nothing!', - ['robbery_successful'] = 'successful robbery you have gained ~g~$', - ['shop_robbery'] = 'shop Robbery', - ['press_to_rob'] = 'press ~INPUT_CONTEXT~ to rob ~b~', - ['robbery_of'] = 'store robbery: ~r~', - ['seconds_remaining'] = '~w~ seconds remaning', - ['robbery_cancelled_at'] = '~r~ Robbery cancelled at: ~b~', - ['robbery_has_cancelled'] = '~r~ robbery has been cancelled: ~b~', - ['already_robbed'] = 'this store has already been robbed. Please wait: ', - ['seconds'] = 'seconds.', - ['rob_in_prog'] = '~r~ robbery in progress at: ~b~', - ['started_to_rob'] = 'you started to rob ', - ['do_not_move'] = ', do not move away!', - ['alarm_triggered'] = 'the alarm has been triggered', - ['hold_pos'] = 'hold for 5 minutes and the money is yours!', - ['robbery_complete'] = '~r~ Robbery complete.~s~ ~h~ Run!', - ['robbery_complete_at'] = '~r~ Robbery complete at: ~b~', - ['min_two_police'] = 'there must be at least ~b~2 policemen~s~ in town to rob.', - ['robbery_already'] = '~r~A robbery is already in progress.', + ['robbery_cancelled'] = 'the robbery will be cancelled, you will gain nothing!', + ['robbery_successful'] = 'successful robbery you have gained ~g~$', + ['shop_robbery'] = 'shop Robbery', + ['press_to_rob'] = 'press ~INPUT_CONTEXT~ to rob ~b~', + ['robbery_of'] = 'store robbery: ~r~', + ['seconds_remaining'] = '~w~ seconds remaning', + ['robbery_cancelled_at'] = '~r~ Robbery cancelled at: ~b~', + ['robbery_has_cancelled'] = '~r~ robbery has been cancelled: ~b~', + ['already_robbed'] = 'this store has already been robbed. Please wait: ', + ['seconds'] = 'seconds.', + ['rob_in_prog'] = '~r~ robbery in progress at: ~b~', + ['started_to_rob'] = 'you started to rob ', + ['do_not_move'] = ', do not move away!', + ['alarm_triggered'] = 'the alarm has been triggered', + ['hold_pos'] = 'hold for 5 minutes and the money is yours!', + ['robbery_complete'] = '~r~ Robbery complete.~s~ ~h~ Run!', + ['robbery_complete_at'] = '~r~ Robbery complete at: ~b~', + ['min_two_police'] = 'there must be at least ~b~2 policemen~s~ in town to rob.', + ['robbery_already'] = '~r~A robbery is already in progress.', } diff --git a/locales/fr.lua b/locales/fr.lua index a88233ec..85e6a024 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -1,23 +1,23 @@ Locales['fr'] = { - ['robbery_cancelled'] = 'le braquage vas être annulé, vous ne gagnerez rien!', - ['robbery_successful'] = 'braquage réussi vous avez gagné ~g~$', - ['shop_robbery'] = 'braquage magasin', - ['press_to_rob'] = 'appuyer sur ~INPUT_CONTEXT~ pour braquer ~b~', - ['robbery_of'] = 'braquage de magasin: ~r~', - ['seconds_remaining'] = '~w~ secondes restantes', - ['robbery_cancelled_at'] = '~r~ Braquage annulé à: ~b~', - ['robbery_has_cancelled'] = '~r~ le braquage à été annulé: ~b~', - ['already_robbed'] = 'ce magasin a déjà été braqué. Veuillez attendre: ', - ['seconds'] = 'secondes.', - ['rob_in_prog'] = '~r~ braquage en cours à: ~b~', - ['started_to_rob'] = 'vous avez commencé à braquer ', - ['do_not_move'] = ', ne vous éloignez pas!', - ['alarm_triggered'] = 'l\'alarme à été déclenché', - ['hold_pos'] = 'tenez la position pendant 5min et l\'argent est à vous!', - ['robbery_complete'] = '~r~ Braquage terminé.~s~ ~h~ Fuie!', - ['robbery_complete_at'] = '~r~ Braquage terminé à: ~b~', - ['min_two_police'] = 'il faut minimum ~b~2 policiers~s~ en ville pour braquer.', - ['robbery_already'] = '~r~Un braquage est déjà en cours.', + ['robbery_cancelled'] = 'le braquage vas être annulé, vous ne gagnerez rien!', + ['robbery_successful'] = 'braquage réussi vous avez gagné ~g~$', + ['shop_robbery'] = 'braquage magasin', + ['press_to_rob'] = 'appuyer sur ~INPUT_CONTEXT~ pour braquer ~b~', + ['robbery_of'] = 'braquage de magasin: ~r~', + ['seconds_remaining'] = '~w~ secondes restantes', + ['robbery_cancelled_at'] = '~r~ Braquage annulé à: ~b~', + ['robbery_has_cancelled'] = '~r~ le braquage à été annulé: ~b~', + ['already_robbed'] = 'ce magasin a déjà été braqué. Veuillez attendre: ', + ['seconds'] = 'secondes.', + ['rob_in_prog'] = '~r~ braquage en cours à: ~b~', + ['started_to_rob'] = 'vous avez commencé à braquer ', + ['do_not_move'] = ', ne vous éloignez pas!', + ['alarm_triggered'] = 'l\'alarme à été déclenché', + ['hold_pos'] = 'tenez la position pendant 5min et l\'argent est à vous!', + ['robbery_complete'] = '~r~ Braquage terminé.~s~ ~h~ Fuie!', + ['robbery_complete_at'] = '~r~ Braquage terminé à: ~b~', + ['min_two_police'] = 'il faut minimum ~b~2 policiers~s~ en ville pour braquer.', + ['robbery_already'] = '~r~Un braquage est déjà en cours.', } diff --git a/server/esx_holdup_sv.lua b/server/esx_holdup_sv.lua index 50205e24..8c5d1654 100644 --- a/server/esx_holdup_sv.lua +++ b/server/esx_holdup_sv.lua @@ -5,100 +5,100 @@ ESX = nil TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) function get3DDistance(x1, y1, z1, x2, y2, z2) - return math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2) + math.pow(z1 - z2, 2)) + return math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2) + math.pow(z1 - z2, 2)) end RegisterServerEvent('esx_holdup:toofar') AddEventHandler('esx_holdup:toofar', function(robb) - local source = source - local xPlayers = ESX.GetPlayers() - rob = false - for i=1, #xPlayers, 1 do - local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) - if xPlayer.job.name == 'police' then - TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_cancelled_at') .. Stores[robb].nameofstore) - TriggerClientEvent('esx_holdup:killblip', xPlayers[i]) - end - end - if(robbers[source])then - TriggerClientEvent('esx_holdup:toofarlocal', source) - robbers[source] = nil - TriggerClientEvent('esx:showNotification', source, _U('robbery_has_cancelled') .. Stores[robb].nameofstore) - end + local source = source + local xPlayers = ESX.GetPlayers() + rob = false + for i=1, #xPlayers, 1 do + local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + if xPlayer.job.name == 'police' then + TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_cancelled_at') .. Stores[robb].nameofstore) + TriggerClientEvent('esx_holdup:killblip', xPlayers[i]) + end + end + if(robbers[source])then + TriggerClientEvent('esx_holdup:toofarlocal', source) + robbers[source] = nil + TriggerClientEvent('esx:showNotification', source, _U('robbery_has_cancelled') .. Stores[robb].nameofstore) + end end) RegisterServerEvent('esx_holdup:rob') AddEventHandler('esx_holdup:rob', function(robb) - local source = source - local xPlayer = ESX.GetPlayerFromId(source) - local xPlayers = ESX.GetPlayers() + local source = source + local xPlayer = ESX.GetPlayerFromId(source) + local xPlayers = ESX.GetPlayers() - if Stores[robb] then + if Stores[robb] then - local store = Stores[robb] + local store = Stores[robb] - if (os.time() - store.lastrobbed) < 600 and store.lastrobbed ~= 0 then + if (os.time() - store.lastrobbed) < 600 and store.lastrobbed ~= 0 then - TriggerClientEvent('esx:showNotification', source, _U('already_robbed') .. (1800 - (os.time() - store.lastrobbed)) .. _U('seconds')) - return - end + TriggerClientEvent('esx:showNotification', source, _U('already_robbed') .. (1800 - (os.time() - store.lastrobbed)) .. _U('seconds')) + return + end - local cops = 0 - for i=1, #xPlayers, 1 do - local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) - if xPlayer.job.name == 'police' then - cops = cops + 1 - end - end + local cops = 0 + for i=1, #xPlayers, 1 do + local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + if xPlayer.job.name == 'police' then + cops = cops + 1 + end + end - if rob == false then + if rob == false then - if(cops > 1)then + if(cops > 1)then - rob = true - for i=1, #xPlayers, 1 do - local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) - if xPlayer.job.name == 'police' then - TriggerClientEvent('esx:showNotification', xPlayers[i], _U('rob_in_prog') .. store.nameofstore) - TriggerClientEvent('esx_holdup:setblip', xPlayers[i], Stores[robb].position) - end - end + rob = true + for i=1, #xPlayers, 1 do + local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + if xPlayer.job.name == 'police' then + TriggerClientEvent('esx:showNotification', xPlayers[i], _U('rob_in_prog') .. store.nameofstore) + TriggerClientEvent('esx_holdup:setblip', xPlayers[i], Stores[robb].position) + end + end - TriggerClientEvent('esx:showNotification', source, _U('started_to_rob') .. store.nameofstore .. _U('do_not_move')) - TriggerClientEvent('esx:showNotification', source, _U('alarm_triggered')) - TriggerClientEvent('esx:showNotification', source, _U('hold_pos')) - TriggerClientEvent('esx_holdup:currentlyrobbing', source, robb) - Stores[robb].lastrobbed = os.time() - robbers[source] = robb - local savedSource = source - SetTimeout(300000, function() + TriggerClientEvent('esx:showNotification', source, _U('started_to_rob') .. store.nameofstore .. _U('do_not_move')) + TriggerClientEvent('esx:showNotification', source, _U('alarm_triggered')) + TriggerClientEvent('esx:showNotification', source, _U('hold_pos')) + TriggerClientEvent('esx_holdup:currentlyrobbing', source, robb) + Stores[robb].lastrobbed = os.time() + robbers[source] = robb + local savedSource = source + SetTimeout(300000, function() - if(robbers[savedSource])then + if(robbers[savedSource])then - rob = false - TriggerClientEvent('esx_holdup:robberycomplete', savedSource, job) - if(xPlayer)then + rob = false + TriggerClientEvent('esx_holdup:robberycomplete', savedSource, job) + if(xPlayer)then - xPlayer.addAccountMoney('black_money', store.reward) - local xPlayers = ESX.GetPlayers() - for i=1, #xPlayers, 1 do - local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) - if xPlayer.job.name == 'police' then - TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_complete_at') .. store.nameofstore) - TriggerClientEvent('esx_holdup:killblip', xPlayers[i]) - end - end - end - end - end) - else - TriggerClientEvent('esx:showNotification', source, _U('min_two_police')) - end - else - TriggerClientEvent('esx:showNotification', source, _U('robbery_already')) - end - end + xPlayer.addAccountMoney('black_money', store.reward) + local xPlayers = ESX.GetPlayers() + for i=1, #xPlayers, 1 do + local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + if xPlayer.job.name == 'police' then + TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_complete_at') .. store.nameofstore) + TriggerClientEvent('esx_holdup:killblip', xPlayers[i]) + end + end + end + end + end) + else + TriggerClientEvent('esx:showNotification', source, _U('min_two_police')) + end + else + TriggerClientEvent('esx:showNotification', source, _U('robbery_already')) + end + end end) From 8276cf15a9ede482f6efff9a752b958f70de4219 Mon Sep 17 00:00:00 2001 From: LuaDeldu Date: Thu, 2 Nov 2017 00:12:54 +0100 Subject: [PATCH 2/3] ESX file names + better config.lua + rob timer per shop With the help of AshdeuzoFR --- README.md | 4 +- __resource.lua | 7 +-- client/main.lua | 149 ++++++++++++++++++++++++++++++++++++++++++++++++ config.lua | 29 +++++++--- locales/br.lua | 7 ++- locales/de.lua | 7 ++- locales/en.lua | 7 ++- locales/fr.lua | 33 +++++------ server/main.lua | 108 +++++++++++++++++++++++++++++++++++ 9 files changed, 312 insertions(+), 39 deletions(-) create mode 100644 client/main.lua create mode 100644 server/main.lua diff --git a/README.md b/README.md index 631b0713..26da0c0b 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,14 @@ FXserver ESX Hold Up [REQUIREMENTS] - * esx_policejob => https://github.com/FXServer-ESX/fxserver-esx_policejob + * esx_policejob => https://github.com/ESX-Org/esx_policejob [INSTALLATION] 1) CD in your resources/[esx] folder 2) Clone the repository ``` -git clone https://github.com/FXServer-ESX/fxserver_esx_holdup esx_holdup +git clone https://github.com/ESX-Org/esx_holdup esx_holdup ``` 3) Add this in your server.cfg : diff --git a/__resource.lua b/__resource.lua index c2697d45..cac35769 100644 --- a/__resource.lua +++ b/__resource.lua @@ -1,6 +1,5 @@ -version '1.0.0' +version '1.1.0' -dependency 'essentialmode' client_scripts { '@es_extended/locale.lua', @@ -9,7 +8,7 @@ client_scripts { 'locales/en.lua', 'locales/fr.lua', 'config.lua', - 'client/esx_holdup_cl.lua' + 'client/main.lua' } server_scripts { @@ -19,5 +18,5 @@ server_scripts { 'locales/en.lua', 'locales/fr.lua', 'config.lua', - 'server/esx_holdup_sv.lua' + 'server/main.lua' } diff --git a/client/main.lua b/client/main.lua new file mode 100644 index 00000000..cff11a99 --- /dev/null +++ b/client/main.lua @@ -0,0 +1,149 @@ +local holdingup = false +local store = "" +local blipRobbery = nil +ESX = nil + +Citizen.CreateThread(function() + while ESX == nil do + TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) + Citizen.Wait(0) + end +end) + +function DisplayHelpText(str) + SetTextComponentFormat("STRING") + AddTextComponentString(str) + DisplayHelpTextFromStringLabel(0, 0, 1, -1) +end + +function drawTxt(x,y ,width,height,scale, text, r,g,b,a, outline) + SetTextFont(0) + SetTextProportional(0) + SetTextScale(scale, scale) + SetTextColour(r, g, b, a) + SetTextDropShadow(0, 0, 0, 0,255) + SetTextEdge(1, 0, 0, 0, 255) + SetTextDropShadow() + if(outline)then + SetTextOutline() + end + SetTextEntry("STRING") + AddTextComponentString(text) + DrawText(x - width/2, y - height/2 + 0.005) +end + +RegisterNetEvent('esx_holdup:currentlyrobbing') +AddEventHandler('esx_holdup:currentlyrobbing', function(robb) + holdingup = true + store = robb +end) + +RegisterNetEvent('esx_holdup:killblip') +AddEventHandler('esx_holdup:killblip', function() + RemoveBlip(blipRobbery) +end) + +RegisterNetEvent('esx_holdup:setblip') +AddEventHandler('esx_holdup:setblip', function(position) + blipRobbery = AddBlipForCoord(position.x, position.y, position.z) + SetBlipSprite(blipRobbery , 161) + SetBlipScale(blipRobbery , 2.0) + SetBlipColour(blipRobbery, 3) + PulseBlip(blipRobbery) +end) + +RegisterNetEvent('esx_holdup:toofarlocal') +AddEventHandler('esx_holdup:toofarlocal', function(robb) + holdingup = false + ESX.ShowNotification(_U('robbery_cancelled')) + robbingName = "" + incircle = false +end) + + +RegisterNetEvent('esx_holdup:robberycomplete') +AddEventHandler('esx_holdup:robberycomplete', function(robb) + holdingup = false + ESX.ShowNotification(_U('robbery_complete')) + store = "" + incircle = false +end) + + +RegisterNetEvent('esx_holdup:starttimer') +AddEventHandler('esx_holdup:starttimer', function(source) + timer = Stores[store].secondsRemaining + Citizen.CreateThread(function() + while timer > 0 do + Citizen.Wait(0) + Citizen.Wait(1000) + if(timer > 0)then + timer = timer - 1 + end + end + end) + Citizen.CreateThread(function() + while true do + Citizen.Wait(0) + if holdingup then + drawTxt(0.66, 1.44, 1.0,1.0,0.4, _U('robbery_of') .. timer .. _U('seconds_remaining'), 255, 255, 255, 255) + end + end + end) +end) + + +Citizen.CreateThread(function() + for k,v in pairs(Stores)do + local ve = v.position + + local blip = AddBlipForCoord(ve.x, ve.y, ve.z) + SetBlipSprite(blip, 156) + SetBlipScale(blip, 0.8) + SetBlipAsShortRange(blip, true) + BeginTextCommandSetBlipName("STRING") + AddTextComponentString(_U('shop_robbery')) + EndTextCommandSetBlipName(blip) + end +end) +incircle = false + + +Citizen.CreateThread(function() + while true do + local pos = GetEntityCoords(GetPlayerPed(-1), true) + + for k,v in pairs(Stores)do + local pos2 = v.position + + if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) < 15.0)then + if not holdingup then + DrawMarker(1, v.position.x, v.position.y, v.position.z - 1, 0, 0, 0, 0, 0, 0, 1.0001, 1.0001, 1.5001, 1555, 0, 0,255, 0, 0, 0,0) + + if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) < 1.0)then + if (incircle == false) then + DisplayHelpText(_U('press_to_rob') .. v.nameofstore) + end + incircle = true + if IsControlJustReleased(1, 51) then + TriggerServerEvent('esx_holdup:rob', k) + end + elseif(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 1.0)then + incircle = false + end + end + end + end + + if holdingup then + + local pos2 = Stores[store].position + + if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 13)then + TriggerServerEvent('esx_holdup:toofar', store) + end + end + + Citizen.Wait(0) + end +end) diff --git a/config.lua b/config.lua index 98332dd7..500f9a31 100644 --- a/config.lua +++ b/config.lua @@ -1,53 +1,66 @@ Config = {} Config.Locale = 'fr' +Config.PoliceNumberRequired = 2 +Config.TimerBeforeNewRob = 1800 -- seconds + + +-- Change secondsRemaining if you want another timer Stores = { --[["paleto_twentyfourseven"] = { position = { ['x'] = 1736.32092285156, ['y'] = 6419.4970703125, ['z'] = 35.037223815918 }, reward = math.random(100,1000), nameofstore = "24/7. (Paleto Bay)", + secondsRemaining = 200, -- seconds lastrobbed = 0 },]] ["sandyshores_twentyfoursever"] = { position = { ['x'] = 1961.24682617188, ['y'] = 3749.46069335938, ['z'] = 32.3437461853027 }, - reward = math.random(500,5000), + reward = math.random(500,2500), nameofstore = "24/7. (Sandy Shores)", + secondsRemaining = 200, -- seconds lastrobbed = 0 }, ["bar_one"] = { - position = { ['x'] = 1986.1240234375, ['y'] = 3053.8747558594, ['z'] = 47.215171813965 }, - reward = math.random(500,5000), + position = { ['x'] = 1990.579, ['y'] = 3044.957, ['z'] = 47.215171813965 }, + reward = math.random(500,2500), nameofstore = "Yellow Jack. (Sandy Shores)", + secondsRemaining = 200, -- seconds lastrobbed = 0 }, ["ocean_liquor"] = { position = { ['x'] = -2959.33715820313, ['y'] = 388.214172363281, ['z'] = 14.0432071685791 }, - reward = math.random(1000,10000), + reward = math.random(1000,3000), nameofstore = "Robs Liquor. (Great Ocean Higway)", + secondsRemaining = 200, -- seconds lastrobbed = 0 }, ["sanandreas_liquor"] = { position = { ['x'] = -1219.85607910156, ['y'] = -916.276550292969, ['z'] = 11.3262157440186 }, - reward = math.random(1000,10000), + reward = math.random(3000,8000), nameofstore = "Robs Liquor. (San andreas Avenue)", + secondsRemaining = 200, -- seconds lastrobbed = 0 }, ["grove_ltd"] = { position = { ['x'] = -43.4035377502441, ['y'] = -1749.20922851563, ['z'] = 29.421012878418 }, - reward = math.random(1000,10000), + reward = math.random(3000,8000), nameofstore = "LTD Gasoline. (Grove Street)", + secondsRemaining = 200, -- seconds lastrobbed = 0 }, ["mirror_ltd"] = { position = { ['x'] = 1160.67578125, ['y'] = -314.400451660156, ['z'] = 69.2050552368164 }, - reward = math.random(1000,10000), + reward = math.random(3000,8000), nameofstore = "LTD Gasoline. (Mirror Park Boulevard)", + secondsRemaining = 200, -- seconds lastrobbed = 0 }, ["littleseoul_twentyfourseven"] = { position = { ['x'] = -709.17022705078, ['y'] = -904.21722412109, ['z'] = 19.215591430664 }, - reward = math.random(1000,10000), + reward = math.random(3000,8000), nameofstore = "24/7. (Little Seoul)", + secondsRemaining = 200, -- seconds lastrobbed = 0 } } diff --git a/locales/br.lua b/locales/br.lua index d058b945..96c38cdc 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -11,13 +11,14 @@ Locales['br'] = { ['already_robbed'] = 'Esta loja já foi roubada. Por favor, espere: ', ['seconds'] = 'segundos.', ['rob_in_prog'] = '~r~ Assalto em curso em: ~b~', - ['started_to_rob'] = 'Você começou a roubar ', - ['do_not_move'] = ', Não se afaste!', + ['started_to_rob'] = 'Você começou a roubar ~b~', + ['do_not_move'] = '~s~, Não se afaste!', ['alarm_triggered'] = 'O alarme foi disparado', ['hold_pos'] = 'Segure por 5 minutos e o dinheiro é seu!', ['robbery_complete'] = '~r~ Roubo completo.~s~ ~h~ Corre!', ['robbery_complete_at'] = '~r~ Roubo completo em: ~b~', - ['min_two_police'] = 'Deve haver pelo menos ~b~2 policiais~s~ na cidade para roubar.', + ['min_police'] = 'there must be at least ~b~', + ['in_city'] = '~s~ policemen in town to rob.', ['robbery_already'] = '~r~Um assalto já está em andamento.', } diff --git a/locales/de.lua b/locales/de.lua index 867bf34a..10d2faa4 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -11,13 +11,14 @@ Locales['de'] = { ['already_robbed'] = 'dieser Laden wurde bereits ausgeraubt. Bitte warte: ', ['seconds'] = 'sekunden.', ['rob_in_prog'] = '~r~ Raub im gange bei: ~b~', - ['started_to_rob'] = 'du hast einen Raub gestartet ', - ['do_not_move'] = ', laufe nicht weg!', + ['started_to_rob'] = 'du hast einen Raub gestartet ~b~', + ['do_not_move'] = '~s~, laufe nicht weg!', ['alarm_triggered'] = 'der Alarm wurde ausgelöst', ['hold_pos'] = 'halte 5 Minuten lang durch, und die Beute gehört dir!', ['robbery_complete'] = '~r~ Raub erfolgreich.~s~ ~h~ LAUF!', ['robbery_complete_at'] = '~r~ Raub erfolgreich bei: ~b~', - ['min_two_police'] = 'es müssen mindestens ~b~2 Polizisten~s~ im Dienst sein um einen Raub starten zu können.', + ['min_police'] = 'there must be at least ~b~', + ['in_city'] = '~s~ policemen in town to rob.', ['robbery_already'] = '~r~Ein Raub ist bereits im gange.', } diff --git a/locales/en.lua b/locales/en.lua index 80a51126..cbf6cb25 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -11,13 +11,14 @@ Locales['en'] = { ['already_robbed'] = 'this store has already been robbed. Please wait: ', ['seconds'] = 'seconds.', ['rob_in_prog'] = '~r~ robbery in progress at: ~b~', - ['started_to_rob'] = 'you started to rob ', - ['do_not_move'] = ', do not move away!', + ['started_to_rob'] = 'you started to rob ~b~', + ['do_not_move'] = '~s~, do not move away!', ['alarm_triggered'] = 'the alarm has been triggered', ['hold_pos'] = 'hold for 5 minutes and the money is yours!', ['robbery_complete'] = '~r~ Robbery complete.~s~ ~h~ Run!', ['robbery_complete_at'] = '~r~ Robbery complete at: ~b~', - ['min_two_police'] = 'there must be at least ~b~2 policemen~s~ in town to rob.', + ['min_police'] = 'there must be at least ~b~', + ['in_city'] = '~s~ policemen in town to rob.', ['robbery_already'] = '~r~A robbery is already in progress.', } diff --git a/locales/fr.lua b/locales/fr.lua index 85e6a024..3bf3db32 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -1,23 +1,24 @@ Locales['fr'] = { - ['robbery_cancelled'] = 'le braquage vas être annulé, vous ne gagnerez rien!', - ['robbery_successful'] = 'braquage réussi vous avez gagné ~g~$', - ['shop_robbery'] = 'braquage magasin', - ['press_to_rob'] = 'appuyer sur ~INPUT_CONTEXT~ pour braquer ~b~', - ['robbery_of'] = 'braquage de magasin: ~r~', + ['robbery_cancelled'] = 'Le braquage va être annulé, vous ne gagnerez rien !', + ['robbery_successful'] = 'Braquage réussi, vous avez gagné ~g~$', + ['shop_robbery'] = 'Braquage magasin', + ['press_to_rob'] = 'Appuyez sur ~INPUT_CONTEXT~ pour braquer ~b~', + ['robbery_of'] = 'Braquage de magasin :\n ~r~', ['seconds_remaining'] = '~w~ secondes restantes', ['robbery_cancelled_at'] = '~r~ Braquage annulé à: ~b~', - ['robbery_has_cancelled'] = '~r~ le braquage à été annulé: ~b~', - ['already_robbed'] = 'ce magasin a déjà été braqué. Veuillez attendre: ', - ['seconds'] = 'secondes.', - ['rob_in_prog'] = '~r~ braquage en cours à: ~b~', - ['started_to_rob'] = 'vous avez commencé à braquer ', - ['do_not_move'] = ', ne vous éloignez pas!', - ['alarm_triggered'] = 'l\'alarme à été déclenché', - ['hold_pos'] = 'tenez la position pendant 5min et l\'argent est à vous!', - ['robbery_complete'] = '~r~ Braquage terminé.~s~ ~h~ Fuie!', - ['robbery_complete_at'] = '~r~ Braquage terminé à: ~b~', - ['min_two_police'] = 'il faut minimum ~b~2 policiers~s~ en ville pour braquer.', + ['robbery_has_cancelled'] = '~r~ Le braquage à été annulé: ~b~', + ['already_robbed'] = 'Ce magasin a déjà été braqué. Attendez ~r~ ', + ['seconds'] = '~b~ secondes.', + ['rob_in_prog'] = '~r~ Braquage en cours à: ~b~', + ['started_to_rob'] = 'Vous avez commencé à braquer ~b~', + ['do_not_move'] = '~s~, ne vous éloignez pas !', + ['alarm_triggered'] = 'l\'alarme a été déclenchée', + ['hold_pos'] = 'Tenez la position et l\'argent sera à vous !', + ['robbery_complete'] = '~r~ Braquage terminé.~s~ ~h~ Cours petite fille !', + ['robbery_complete_at'] = '~r~ Braquage terminé à : ~b~', + ['min_police'] = 'Il faut minimum ~b~', + ['in_city'] = '~s~ policiers en ville pour braquer.', ['robbery_already'] = '~r~Un braquage est déjà en cours.', } diff --git a/server/main.lua b/server/main.lua new file mode 100644 index 00000000..9eb9be7b --- /dev/null +++ b/server/main.lua @@ -0,0 +1,108 @@ +local rob = false +local robbers = {} +ESX = nil + +TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) + +function get3DDistance(x1, y1, z1, x2, y2, z2) + return math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2) + math.pow(z1 - z2, 2)) +end + +RegisterServerEvent('esx_holdup:toofar') +AddEventHandler('esx_holdup:toofar', function(robb) + local source = source + local xPlayers = ESX.GetPlayers() + rob = false + for i=1, #xPlayers, 1 do + local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + if xPlayer.job.name == 'police' then + TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_cancelled_at') .. Stores[robb].nameofstore) + TriggerClientEvent('esx_holdup:killblip', xPlayers[i]) + end + end + if(robbers[source])then + TriggerClientEvent('esx_holdup:toofarlocal', source) + robbers[source] = nil + TriggerClientEvent('esx:showNotification', source, _U('robbery_has_cancelled') .. Stores[robb].nameofstore) + end +end) + +RegisterServerEvent('esx_holdup:rob') +AddEventHandler('esx_holdup:rob', function(robb) + + local source = source + local xPlayer = ESX.GetPlayerFromId(source) + local xPlayers = ESX.GetPlayers() + + if Stores[robb] then + + local store = Stores[robb] + + if (os.time() - store.lastrobbed) < Config.TimerBeforeNewRob and store.lastrobbed ~= 0 then + + TriggerClientEvent('esx:showNotification', source, _U('already_robbed') .. (Config.TimerBeforeNewRob - (os.time() - store.lastrobbed)) .. _U('seconds')) + return + end + + + local cops = 0 + for i=1, #xPlayers, 1 do + local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + if xPlayer.job.name == 'police' then + cops = cops + 1 + end + end + + + if rob == false then + + if(cops >= Config.PoliceNumberRequired)then + + rob = true + for i=1, #xPlayers, 1 do + local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + if xPlayer.job.name == 'police' then + TriggerClientEvent('esx:showNotification', xPlayers[i], _U('rob_in_prog') .. store.nameofstore) + TriggerClientEvent('esx_holdup:setblip', xPlayers[i], Stores[robb].position) + end + end + + TriggerClientEvent('esx:showNotification', source, _U('started_to_rob') .. store.nameofstore .. _U('do_not_move')) + TriggerClientEvent('esx:showNotification', source, _U('alarm_triggered')) + TriggerClientEvent('esx:showNotification', source, _U('hold_pos')) + + TriggerClientEvent('esx_holdup:currentlyrobbing', source, robb) + TriggerClientEvent('esx_holdup:starttimer', source) + + + Stores[robb].lastrobbed = os.time() + robbers[source] = robb + local savedSource = source + SetTimeout(store.secondsRemaining*1000, function() + + if(robbers[savedSource])then + + rob = false + TriggerClientEvent('esx_holdup:robberycomplete', savedSource, job) + if(xPlayer)then + + xPlayer.addAccountMoney('black_money', store.reward) + local xPlayers = ESX.GetPlayers() + for i=1, #xPlayers, 1 do + local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) + if xPlayer.job.name == 'police' then + TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_complete_at') .. store.nameofstore) + TriggerClientEvent('esx_holdup:killblip', xPlayers[i]) + end + end + end + end + end) + else + TriggerClientEvent('esx:showNotification', source, _U('min_police') .. Config.PoliceNumberRequired .. _U('in_city')) + end + else + TriggerClientEvent('esx:showNotification', source, _U('robbery_already')) + end + end +end) From c98a79f4fb5c9a52e2a71c398d0e644f2327a37a Mon Sep 17 00:00:00 2001 From: LuaDeldu Date: Thu, 2 Nov 2017 00:16:04 +0100 Subject: [PATCH 3/3] Old file names deletion --- client/esx_holdup_cl.lua | 142 --------------------------------------- server/esx_holdup_sv.lua | 104 ---------------------------- 2 files changed, 246 deletions(-) delete mode 100644 client/esx_holdup_cl.lua delete mode 100644 server/esx_holdup_sv.lua diff --git a/client/esx_holdup_cl.lua b/client/esx_holdup_cl.lua deleted file mode 100644 index 23e287a5..00000000 --- a/client/esx_holdup_cl.lua +++ /dev/null @@ -1,142 +0,0 @@ -local holdingup = false -local store = "" -local secondsRemaining = 0 -local blipRobbery = nil -ESX = nil - -Citizen.CreateThread(function() - while ESX == nil do - TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) - Citizen.Wait(0) - end -end) - -function DisplayHelpText(str) - SetTextComponentFormat("STRING") - AddTextComponentString(str) - DisplayHelpTextFromStringLabel(0, 0, 1, -1) -end - -function drawTxt(x,y ,width,height,scale, text, r,g,b,a, outline) - SetTextFont(0) - SetTextProportional(0) - SetTextScale(scale, scale) - SetTextColour(r, g, b, a) - SetTextDropShadow(0, 0, 0, 0,255) - SetTextEdge(1, 0, 0, 0, 255) - SetTextDropShadow() - if(outline)then - SetTextOutline() - end - SetTextEntry("STRING") - AddTextComponentString(text) - DrawText(x - width/2, y - height/2 + 0.005) -end - -RegisterNetEvent('esx_holdup:currentlyrobbing') -AddEventHandler('esx_holdup:currentlyrobbing', function(robb) - holdingup = true - store = robb - secondsRemaining = 300 -end) - -RegisterNetEvent('esx_holdup:killblip') -AddEventHandler('esx_holdup:killblip', function() - RemoveBlip(blipRobbery) -end) - -RegisterNetEvent('esx_holdup:setblip') -AddEventHandler('esx_holdup:setblip', function(position) - blipRobbery = AddBlipForCoord(position.x, position.y, position.z) - SetBlipSprite(blipRobbery , 161) - SetBlipScale(blipRobbery , 2.0) - SetBlipColour(blipRobbery, 3) - PulseBlip(blipRobbery) -end) - -RegisterNetEvent('esx_holdup:toofarlocal') -AddEventHandler('esx_holdup:toofarlocal', function(robb) - holdingup = false - ESX.ShowNotification(_U('robbery_cancelled')) - robbingName = "" - secondsRemaining = 0 - incircle = false -end) - - -RegisterNetEvent('esx_holdup:robberycomplete') -AddEventHandler('esx_holdup:robberycomplete', function(robb) - holdingup = false - ESX.ShowNotification(_U('robbery_cancelled') .. Stores[store].reward) - store = "" - secondsRemaining = 0 - incircle = false -end) - -Citizen.CreateThread(function() - while true do - Citizen.Wait(0) - if holdingup then - Citizen.Wait(1000) - if(secondsRemaining > 0)then - secondsRemaining = secondsRemaining - 1 - end - end - end -end) - -Citizen.CreateThread(function() - for k,v in pairs(Stores)do - local ve = v.position - - local blip = AddBlipForCoord(ve.x, ve.y, ve.z) - SetBlipSprite(blip, 156) - SetBlipScale(blip, 0.8) - SetBlipAsShortRange(blip, true) - BeginTextCommandSetBlipName("STRING") - AddTextComponentString(_U('shop_robbery')) - EndTextCommandSetBlipName(blip) - end -end) -incircle = false - -Citizen.CreateThread(function() - while true do - local pos = GetEntityCoords(GetPlayerPed(-1), true) - - for k,v in pairs(Stores)do - local pos2 = v.position - - if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) < 15.0)then - if not holdingup then - DrawMarker(1, v.position.x, v.position.y, v.position.z - 1, 0, 0, 0, 0, 0, 0, 1.0001, 1.0001, 1.5001, 1555, 0, 0,255, 0, 0, 0,0) - - if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) < 1.0)then - if (incircle == false) then - DisplayHelpText(_U('press_to_rob') .. v.nameofstore) - end - incircle = true - if IsControlJustReleased(1, 51) then - TriggerServerEvent('esx_holdup:rob', k) - end - elseif(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 1.0)then - incircle = false - end - end - end - end - - if holdingup then - - drawTxt(0.66, 1.44, 1.0,1.0,0.4, _U('robbery_of') .. secondsRemaining .. _U('seconds_remaining'), 255, 255, 255, 255) - - local pos2 = Stores[store].position - - if(Vdist(pos.x, pos.y, pos.z, pos2.x, pos2.y, pos2.z) > 7.5)then - TriggerServerEvent('esx_holdup:toofar', store) - end - end - - Citizen.Wait(0) - end -end) diff --git a/server/esx_holdup_sv.lua b/server/esx_holdup_sv.lua deleted file mode 100644 index 8c5d1654..00000000 --- a/server/esx_holdup_sv.lua +++ /dev/null @@ -1,104 +0,0 @@ -local rob = false -local robbers = {} -ESX = nil - -TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) - -function get3DDistance(x1, y1, z1, x2, y2, z2) - return math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2) + math.pow(z1 - z2, 2)) -end - -RegisterServerEvent('esx_holdup:toofar') -AddEventHandler('esx_holdup:toofar', function(robb) - local source = source - local xPlayers = ESX.GetPlayers() - rob = false - for i=1, #xPlayers, 1 do - local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) - if xPlayer.job.name == 'police' then - TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_cancelled_at') .. Stores[robb].nameofstore) - TriggerClientEvent('esx_holdup:killblip', xPlayers[i]) - end - end - if(robbers[source])then - TriggerClientEvent('esx_holdup:toofarlocal', source) - robbers[source] = nil - TriggerClientEvent('esx:showNotification', source, _U('robbery_has_cancelled') .. Stores[robb].nameofstore) - end -end) - -RegisterServerEvent('esx_holdup:rob') -AddEventHandler('esx_holdup:rob', function(robb) - - local source = source - local xPlayer = ESX.GetPlayerFromId(source) - local xPlayers = ESX.GetPlayers() - - if Stores[robb] then - - local store = Stores[robb] - - if (os.time() - store.lastrobbed) < 600 and store.lastrobbed ~= 0 then - - TriggerClientEvent('esx:showNotification', source, _U('already_robbed') .. (1800 - (os.time() - store.lastrobbed)) .. _U('seconds')) - return - end - - - local cops = 0 - for i=1, #xPlayers, 1 do - local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) - if xPlayer.job.name == 'police' then - cops = cops + 1 - end - end - - - if rob == false then - - if(cops > 1)then - - rob = true - for i=1, #xPlayers, 1 do - local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) - if xPlayer.job.name == 'police' then - TriggerClientEvent('esx:showNotification', xPlayers[i], _U('rob_in_prog') .. store.nameofstore) - TriggerClientEvent('esx_holdup:setblip', xPlayers[i], Stores[robb].position) - end - end - - TriggerClientEvent('esx:showNotification', source, _U('started_to_rob') .. store.nameofstore .. _U('do_not_move')) - TriggerClientEvent('esx:showNotification', source, _U('alarm_triggered')) - TriggerClientEvent('esx:showNotification', source, _U('hold_pos')) - TriggerClientEvent('esx_holdup:currentlyrobbing', source, robb) - Stores[robb].lastrobbed = os.time() - robbers[source] = robb - local savedSource = source - SetTimeout(300000, function() - - if(robbers[savedSource])then - - rob = false - TriggerClientEvent('esx_holdup:robberycomplete', savedSource, job) - if(xPlayer)then - - xPlayer.addAccountMoney('black_money', store.reward) - local xPlayers = ESX.GetPlayers() - for i=1, #xPlayers, 1 do - local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) - if xPlayer.job.name == 'police' then - TriggerClientEvent('esx:showNotification', xPlayers[i], _U('robbery_complete_at') .. store.nameofstore) - TriggerClientEvent('esx_holdup:killblip', xPlayers[i]) - end - end - end - end - end) - else - TriggerClientEvent('esx:showNotification', source, _U('min_two_police')) - end - else - TriggerClientEvent('esx:showNotification', source, _U('robbery_already')) - end - end -end)