From 446daf59992a2ee448b7387fe104aa02ae3808c8 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Tue, 3 Jul 2018 14:42:28 +0200 Subject: [PATCH] Refactored files, minor improvementrs & cleanup --- __resource.lua | 24 ++-- {jobs => client/jobs}/fisherman.lua | 0 {jobs => client/jobs}/fueler.lua | 0 {jobs => client/jobs}/lumberjack.lua | 0 {jobs => client/jobs}/miner.lua | 0 {jobs => client/jobs}/reporter.lua | 0 {jobs => client/jobs}/slaughterer.lua | 0 {jobs => client/jobs}/tailor.lua | 6 +- client/{esx_jobs_cl.lua => main.lua} | 176 +++++++++++++------------- esx_jobs.sql | 2 +- localization/br_esx_jobs.sql | 2 +- localization/en_esx_jobs.sql | 2 +- localization/fi_esx_jobs.sql | 2 +- localization/sv_esx_jobs.sql | 2 +- server/{esx_jobs_sv.lua => main.lua} | 0 15 files changed, 111 insertions(+), 105 deletions(-) rename {jobs => client/jobs}/fisherman.lua (100%) rename {jobs => client/jobs}/fueler.lua (100%) rename {jobs => client/jobs}/lumberjack.lua (100%) rename {jobs => client/jobs}/miner.lua (100%) rename {jobs => client/jobs}/reporter.lua (100%) rename {jobs => client/jobs}/slaughterer.lua (100%) rename {jobs => client/jobs}/tailor.lua (98%) rename client/{esx_jobs_cl.lua => main.lua} (82%) rename server/{esx_jobs_sv.lua => main.lua} (100%) diff --git a/__resource.lua b/__resource.lua index 70296101..7f2fe7d3 100644 --- a/__resource.lua +++ b/__resource.lua @@ -14,7 +14,7 @@ server_scripts { 'locales/fr.lua', 'locales/sv.lua', 'config.lua', - 'server/esx_jobs_sv.lua' + 'server/main.lua' } client_scripts { @@ -26,12 +26,18 @@ client_scripts { 'locales/fr.lua', 'locales/sv.lua', 'config.lua', - 'jobs/fisherman.lua', - 'jobs/fueler.lua', - 'jobs/lumberjack.lua', - 'jobs/miner.lua', - 'jobs/reporter.lua', - 'jobs/slaughterer.lua', - 'jobs/tailor.lua', - 'client/esx_jobs_cl.lua' + 'client/jobs/fisherman.lua', + 'client/jobs/fueler.lua', + 'client/jobs/lumberjack.lua', + 'client/jobs/miner.lua', + 'client/jobs/reporter.lua', + 'client/jobs/slaughterer.lua', + 'client/jobs/tailor.lua', + 'client/main.lua' } + +dependencies { + 'es_extended', + 'esx_addonaccount', + 'esx_skin' +} \ No newline at end of file diff --git a/jobs/fisherman.lua b/client/jobs/fisherman.lua similarity index 100% rename from jobs/fisherman.lua rename to client/jobs/fisherman.lua diff --git a/jobs/fueler.lua b/client/jobs/fueler.lua similarity index 100% rename from jobs/fueler.lua rename to client/jobs/fueler.lua diff --git a/jobs/lumberjack.lua b/client/jobs/lumberjack.lua similarity index 100% rename from jobs/lumberjack.lua rename to client/jobs/lumberjack.lua diff --git a/jobs/miner.lua b/client/jobs/miner.lua similarity index 100% rename from jobs/miner.lua rename to client/jobs/miner.lua diff --git a/jobs/reporter.lua b/client/jobs/reporter.lua similarity index 100% rename from jobs/reporter.lua rename to client/jobs/reporter.lua diff --git a/jobs/slaughterer.lua b/client/jobs/slaughterer.lua similarity index 100% rename from jobs/slaughterer.lua rename to client/jobs/slaughterer.lua diff --git a/jobs/tailor.lua b/client/jobs/tailor.lua similarity index 98% rename from jobs/tailor.lua rename to client/jobs/tailor.lua index 4b2cfb10..c3598ba7 100644 --- a/jobs/tailor.lua +++ b/client/jobs/tailor.lua @@ -24,7 +24,7 @@ Config.Jobs.tailor = { GPS = {x = 740.808776855469, y = -970.066650390625, z = 23.4693908691406} }, - Whool = { + Wool = { Pos = {x = 1978.92407226563, y = 5171.70166015625, z = 46.6391181945801}, Size = {x = 3.0, y = 3.0, z = 1.0}, Color = {r = 204, g = 204, b = 0}, @@ -35,7 +35,7 @@ Config.Jobs.tailor = { Item = { { name = _U('dd_wool'), - db_name= "whool", + db_name= "wool", time = 3000, max = 40, add = 1, @@ -65,7 +65,7 @@ Config.Jobs.tailor = { max = 80, add = 2, remove = 1, - requires = "whool", + requires = "wool", requires_name = _U('dd_wool'), drop = 100 } diff --git a/client/esx_jobs_cl.lua b/client/main.lua similarity index 82% rename from client/esx_jobs_cl.lua rename to client/main.lua index 6464e522..e4db6d52 100644 --- a/client/esx_jobs_cl.lua +++ b/client/main.lua @@ -60,10 +60,6 @@ AddEventHandler('esx:playerLoaded', function(xPlayer) refreshBlips() end) -AddEventHandler('esx_jobs:publicTeleports', function(position) - SetEntityCoords(GetPlayerPed(-1), position.x, position.y, position.z) -end) - function OpenMenu() ESX.UI.Menu.CloseAll() @@ -336,14 +332,16 @@ end) -- Show top left hint Citizen.CreateThread(function() - while true do - Citizen.Wait(10) - if hintIsShowed == true then - SetTextComponentFormat("STRING") - AddTextComponentString(hintToDisplay) - DisplayHelpTextFromStringLabel(0, 0, 1, -1) - end - end + while true do + Citizen.Wait(10) + if hintIsShowed then + SetTextComponentFormat("STRING") + AddTextComponentString(hintToDisplay) + DisplayHelpTextFromStringLabel(0, 0, 1, -1) + else + Citizen.Wait(1000) + end + end end) -- Display markers (only if on duty and the player's job ones) @@ -372,51 +370,52 @@ end) -- Display public markers Citizen.CreateThread(function() - while true do - Citizen.Wait(0) - local coords = GetEntityCoords(GetPlayerPed(-1)) - for k,v in pairs(Config.PublicZones) do - if(v.Marker ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then - DrawMarker(v.Marker, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, true, 2, false, false, false, false) - end - end - end + while true do + Citizen.Wait(0) + local coords = GetEntityCoords(GetPlayerPed(-1)) + for k,v in pairs(Config.PublicZones) do + if(v.Marker ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then + DrawMarker(v.Marker, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, true, 2, false, false, false, false) + end + end + end end) -- Activate public marker Citizen.CreateThread(function() - while true do - Citizen.Wait(0) - local coords = GetEntityCoords(GetPlayerPed(-1)) - local position = nil - local zone = nil + while true do + Citizen.Wait(10) + local coords = GetEntityCoords(GetPlayerPed(-1)) + local position = nil + local zone = nil - for k,v in pairs(Config.PublicZones) do - if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x) then - isInPublicMarker = true - position = v.Teleport - zone = v - break - else - isInPublicMarker = false - end - end + for k,v in pairs(Config.PublicZones) do + if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x) then + isInPublicMarker = true + position = v.Teleport + zone = v + break + else + isInPublicMarker = false + end + end - if IsControlJustReleased(0, Keys["E"]) and isInPublicMarker then - TriggerEvent('esx_jobs:publicTeleports', position) - end + if IsControlJustReleased(0, Keys['E']) and isInPublicMarker then + ESX.Game.Teleport(GetPlayerPed(-1), position) + isInPublicMarker = false + end - -- hide or show top left zone hints - if isInPublicMarker then - hintToDisplay = zone.Hint - hintIsShowed = true - else - if not isInMarker then - hintToDisplay = "no hint to display" - hintIsShowed = false - end - end - end + -- hide or show top left zone hints + if isInPublicMarker then + hintToDisplay = zone.Hint + hintIsShowed = true + else + if not isInMarker then + hintToDisplay = "no hint to display" + hintIsShowed = false + end + end + end end) -- Activate menu when player is inside marker @@ -513,46 +512,47 @@ end) -- VEHICLE CAUTION Citizen.CreateThread(function() - while true do - Citizen.Wait(0) - if vehicleInCaseofDrop ~= nil then - if onDuty and IsVehicleModel(vehicleInCaseofDrop, vehicleHashInCaseofDrop) then - local vehicleHealth = GetEntityHealth(vehicleInCaseofDrop) - if vehicleOldHealthInCaseofDrop ~= vehicleHealth then - local cautionValue = 0 - vehicleOldHealthInCaseofDrop = vehicleHealth - if vehicleHealth == vehicleMaxHealthInCaseofDrop then - cautionValue = maxCautionVehicleInCaseofDrop - cautionVehicleInCaseofDrop = cautionValue - else - local healthPct = (vehicleHealth * 100) / vehicleMaxHealthInCaseofDrop - local damagePct = 100 - healthPct - cautionValue = math.ceil(cautionVehicleInCaseofDrop - cautionVehicleInCaseofDrop * damagePct * 2.5 / 100) - if cautionValue < 0 then - cautionValue = 0 - elseif cautionValue >= cautionVehicleInCaseofDrop then - cautionValue = cautionVehicleInCaseofDrop - end - cautionVehicleInCaseofDrop = cautionValue - end - TriggerServerEvent('esx_jobs:setCautionInCaseOfDrop', cautionValue) - end - end - end - end + while true do + Citizen.Wait(0) + if vehicleInCaseofDrop ~= nil then + if onDuty and IsVehicleModel(vehicleInCaseofDrop, vehicleHashInCaseofDrop) then + local vehicleHealth = GetEntityHealth(vehicleInCaseofDrop) + + if vehicleOldHealthInCaseofDrop ~= vehicleHealth then + local cautionValue = 0 + vehicleOldHealthInCaseofDrop = vehicleHealth + if vehicleHealth == vehicleMaxHealthInCaseofDrop then + cautionValue = maxCautionVehicleInCaseofDrop + cautionVehicleInCaseofDrop = cautionValue + else + local healthPct = (vehicleHealth * 100) / vehicleMaxHealthInCaseofDrop + local damagePct = 100 - healthPct + cautionValue = math.ceil(cautionVehicleInCaseofDrop - cautionVehicleInCaseofDrop * damagePct * 2.5 / 100) + if cautionValue < 0 then + cautionValue = 0 + elseif cautionValue >= cautionVehicleInCaseofDrop then + cautionValue = cautionVehicleInCaseofDrop + end + cautionVehicleInCaseofDrop = cautionValue + end + TriggerServerEvent('esx_jobs:setCautionInCaseOfDrop', cautionValue) + end + end + else + Citizen.Wait(1000) + end + end end) Citizen.CreateThread(function() + -- Slaughterer + RemoveIpl("CS1_02_cf_offmission") + RequestIpl("CS1_02_cf_onmission1") + RequestIpl("CS1_02_cf_onmission2") + RequestIpl("CS1_02_cf_onmission3") + RequestIpl("CS1_02_cf_onmission4") - -- Slaughterer - RemoveIpl("CS1_02_cf_offmission") - RequestIpl("CS1_02_cf_onmission1") - RequestIpl("CS1_02_cf_onmission2") - RequestIpl("CS1_02_cf_onmission3") - RequestIpl("CS1_02_cf_onmission4") - - -- Textil - RequestIpl("id2_14_during_door") - RequestIpl("id2_14_during1") - + -- Textil + RequestIpl("id2_14_during_door") + RequestIpl("id2_14_during1") end) diff --git a/esx_jobs.sql b/esx_jobs.sql index 53808d51..79234905 100644 --- a/esx_jobs.sql +++ b/esx_jobs.sql @@ -41,7 +41,7 @@ INSERT INTO `items` (`name`, `label`, `limit`) VALUES ('petrol', 'Pétrole', 24), ('petrol_raffin', 'Pétrole Raffiné', 24), ('essence', 'Essence', 24), - ('whool', 'Laine', 40), + ('wool', 'Laine', 40), ('fabric', 'Tissu', 80), ('clothe', 'Vêtement', 40) ; diff --git a/localization/br_esx_jobs.sql b/localization/br_esx_jobs.sql index 3dc206dd..33c65b47 100644 --- a/localization/br_esx_jobs.sql +++ b/localization/br_esx_jobs.sql @@ -41,7 +41,7 @@ INSERT INTO `items` (`name`, `label`) VALUES ('petrol', 'Petroleo', 24), ('petrol_raffin', 'Petroleo Refinado', 24), ('essence', 'Gasolina', 24), - ('whool', 'Lã', 40), + ('wool', 'Lã', 40), ('fabric', 'Tecido', 80), ('clothe', 'Roupa', 40) ; diff --git a/localization/en_esx_jobs.sql b/localization/en_esx_jobs.sql index 7fc36e84..c9aad07e 100644 --- a/localization/en_esx_jobs.sql +++ b/localization/en_esx_jobs.sql @@ -41,7 +41,7 @@ INSERT INTO `items` (`name`, `label`, `limit`) VALUES ('petrol', 'oil', 24), ('petrol_raffin', 'processed oil', 24), ('essence', 'gas', 24), - ('whool', 'wool', 40), + ('wool', 'wool', 40), ('fabric', 'fabric', 80), ('clothe', 'cloth', 40) ; diff --git a/localization/fi_esx_jobs.sql b/localization/fi_esx_jobs.sql index 297e1857..5859b3cd 100644 --- a/localization/fi_esx_jobs.sql +++ b/localization/fi_esx_jobs.sql @@ -41,7 +41,7 @@ INSERT INTO `items` (`name`, `label`, `limit`) VALUES ('petrol', 'Öljy', 24), ('petrol_raffin', 'Prosessoitu Öljy', 24), ('essence', 'Polttoöljy', 24), - ('whool', 'Villa', 40), + ('wool', 'Villa', 40), ('fabric', 'Kangas', 80), ('clothe', 'Vaate', 40) ; diff --git a/localization/sv_esx_jobs.sql b/localization/sv_esx_jobs.sql index d67bef3b..c9a5a71a 100644 --- a/localization/sv_esx_jobs.sql +++ b/localization/sv_esx_jobs.sql @@ -41,7 +41,7 @@ INSERT INTO `items` (`name`, `label`, `limit`) VALUES ('petrol', 'olja', 24), ('petrol_raffin', 'bearbetad olja', 24), ('essence', 'gas', 24), - ('whool', 'ull', 40), + ('wool', 'ull', 40), ('fabric', 'tyg', 80), ('clothe', 'kläde', 40) ; diff --git a/server/esx_jobs_sv.lua b/server/main.lua similarity index 100% rename from server/esx_jobs_sv.lua rename to server/main.lua