diff --git a/[esx_addons]/esx_mechanicjob/client/main.lua b/[esx_addons]/esx_mechanicjob/client/main.lua index 612c5e31..b7accd91 100644 --- a/[esx_addons]/esx_mechanicjob/client/main.lua +++ b/[esx_addons]/esx_mechanicjob/client/main.lua @@ -46,7 +46,7 @@ function StopNPCJob(cancel) NPCHasBeenNextToTowable = false if cancel then - ESX.ShowNotification(_U('mission_canceled')) + ESX.ShowNotification(_U('mission_canceled'), "error") else --TriggerServerEvent('esx_mechanicjob:onNPCJobCompleted') end @@ -279,11 +279,11 @@ function OpenMobileMechanicActionsMenu() local amount = tonumber(data.value) if amount == nil or amount < 0 then - ESX.ShowNotification(_U('amount_invalid')) + ESX.ShowNotification(_U('amount_invalid'), "error") else local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() if closestPlayer == -1 or closestDistance > 3.0 then - ESX.ShowNotification(_U('no_players_nearby')) + ESX.ShowNotification(_U('no_players_nearby'), "error") else menu.close() TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_mechanic', _U('mechanic'), amount) @@ -831,7 +831,7 @@ CreateThread(function() for k,v in pairs(Config.Zones) do if v.Type ~= -1 and #(coords - v.Pos) < Config.DrawDistance then Sleep = 0 - DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.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, nil, nil, false) + DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.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, true, true, 2, true, nil, nil, false) letSleep = false end end @@ -919,12 +919,13 @@ end) -- Key Controls CreateThread(function() - while CurrentAction do - Wait(0) + while true do + local sleep = 500 + if CurrentAction then + sleep = 0 ESX.ShowHelpNotification(CurrentActionMsg) if IsControlJustReleased(0, 38) and ESX.PlayerData.job and ESX.PlayerData.job.name == 'mechanic' then - if CurrentAction == 'mechanic_actions_menu' then OpenMechanicActionsMenu() elseif CurrentAction == 'mechanic_harvest_menu' then @@ -932,58 +933,58 @@ CreateThread(function() elseif CurrentAction == 'mechanic_craft_menu' then OpenMechanicCraftMenu() elseif CurrentAction == 'delete_vehicle' then + if Config.EnableSocietyOwnedVehicles then - if Config.EnableSocietyOwnedVehicles then + local vehicleProps = ESX.Game.GetVehicleProperties(CurrentActionData.vehicle) + TriggerServerEvent('esx_society:putVehicleInGarage', 'mechanic', vehicleProps) + else + local entityModel = GetEntityModel(CurrentActionData.vehicle) - local vehicleProps = ESX.Game.GetVehicleProperties(CurrentActionData.vehicle) - TriggerServerEvent('esx_society:putVehicleInGarage', 'mechanic', vehicleProps) - - else - local entityModel = GetEntityModel(CurrentActionData.vehicle) - - if - entityModel == GetHashKey("flatbed") or - entityModel == GetHashKey("towtruck2") or - entityModel == GetHashKey("slamvan3") - then - TriggerServerEvent('esx_service:disableService', 'mechanic') - end - - end - - ESX.Game.DeleteVehicle(CurrentActionData.vehicle) - - elseif CurrentAction == 'remove_entity' then - DeleteEntity(CurrentActionData.entity) + if entityModel == GetHashKey("flatbed") or entityModel == GetHashKey("towtruck2") or entityModel == GetHashKey("slamvan3") then + TriggerServerEvent('esx_service:disableService', 'mechanic') + end + end + ESX.Game.DeleteVehicle(CurrentActionData.vehicle) + elseif CurrentAction == 'remove_entity' then + DeleteEntity(CurrentActionData.entity) end CurrentAction = nil - end - end - - if IsControlJustReleased(0, 167) and not isDead and ESX.PlayerData.job and ESX.PlayerData.job.name == 'mechanic' then + end + end + Wait(sleep) + end +end) +RegisterCommand('mechanicMenu', function() + if ESX.PlayerData.job and ESX.PlayerData.job.name == 'mechanic' then OpenMobileMechanicActionsMenu() end +end, false) - if IsControlJustReleased(0, 178) and not isDead and ESX.PlayerData.job and ESX.PlayerData.job.name == 'mechanic' then + + +RegisterCommand('startmechanicjob', function() + local playerPed = PlayerPedId() + if ESX.PlayerData.job and ESX.PlayerData.job.name == 'mechanic' then if NPCOnJob then if GetGameTimer() - NPCLastCancel > 5 * 60000 then StopNPCJob(true) NPCLastCancel = GetGameTimer() else - ESX.ShowNotification(_U('wait_five')) + ESX.ShowNotification(_U('wait_five'), "error") end else - local playerPed = PlayerPedId() - if IsPedInAnyVehicle(playerPed, false) and IsVehicleModel(GetVehiclePedIsIn(playerPed, false), GetHashKey('flatbed')) then StartNPCJob() else - ESX.ShowNotification(_U('must_in_flatbed')) + ESX.ShowNotification(_U('must_in_flatbed'), "error") end end end -end) +end, false) + +RegisterKeyMapping('mechanicMenu', 'Open Mechanic Menu', 'keyboard', 'F6') +RegisterKeyMapping('mechanicjob', 'Togggle NPC Job', 'keyboard', 'F6') AddEventHandler('esx:onPlayerDeath', function(data) isDead = true end) AddEventHandler('esx:onPlayerSpawn', function(spawn) isDead = false end) diff --git a/[esx_addons]/esx_mechanicjob/config.lua b/[esx_addons]/esx_mechanicjob/config.lua index eb6271a4..e8dc1dff 100644 --- a/[esx_addons]/esx_mechanicjob/config.lua +++ b/[esx_addons]/esx_mechanicjob/config.lua @@ -25,24 +25,24 @@ Config.Vehicles = { Config.Zones = { MechanicActions = { - Pos = vector3(-342.291, -133.370, 38.009 ), - Size = { x = 1.5, y = 1.5, z = 1.0 }, - Color = { r = 204, g = 204, b = 0 }, - Type = 1 + Pos = vector3(-342.291, -133.370, 39.009 ), + Size = { x = 1.0, y = 1.0, z = 1.0 }, + Color = { r = 50, g = 200, b = 50 }, + Type = 21 }, Garage = { - Pos = vector3(-97.5, 6496.1, 30.4 ), - Size = { x = 1.5, y = 1.5, z = 1.0 }, - Color = { r = 204, g = 204, b = 0 }, - Type = 1 + Pos = vector3(-97.5, 6496.1, 31.4 ), + Size = { x = 1.0, y = 1.0, z = 1.0 }, + Color = { r = 50, g = 200, b = 50 }, + Type = 21 }, Craft = { - Pos = vector3( -323.140, -129.882, 37.999 ), - Size = { x = 1.5, y = 1.5, z = 1.0 }, - Color = { r = 204, g = 204, b = 0 }, - Type = 1 + Pos = vector3( -323.140, -129.882, 38.999 ), + Size = { x = 1.0, y = 1.0, z = 1.0 }, + Color = { r = 50, g = 200, b = 50 }, + Type = 21 }, VehicleSpawnPoint = { diff --git a/[esx_addons]/esx_mechanicjob/esx_mechanicjob.sql b/[esx_addons]/esx_mechanicjob/esx_mechanicjob.sql index b048dd78..6493bf1b 100644 --- a/[esx_addons]/esx_mechanicjob/esx_mechanicjob.sql +++ b/[esx_addons]/esx_mechanicjob/esx_mechanicjob.sql @@ -1,19 +1,19 @@ USE `es_extended`; INSERT INTO `addon_account` (name, label, shared) VALUES - ('society_mechanic', 'Mécano', 1) + ('society_mechanic', 'Mechanic', 1) ; INSERT INTO `addon_inventory` (name, label, shared) VALUES - ('society_mechanic', 'Mécano', 1) + ('society_mechanic', 'Mechanic', 1) ; INSERT INTO `datastore` (name, label, shared) VALUES - ('society_mechanic', 'Mécano', 1) + ('society_mechanic', 'Mechanic', 1) ; INSERT INTO `jobs` (name, label) VALUES - ('mechanic', 'Mécano') + ('mechanic', 'Mechanic') ; INSERT INTO `job_grades` (job_name, grade, name, label, salary, skin_male, skin_female) VALUES diff --git a/[esx_addons]/esx_mechanicjob/fxmanifest.lua b/[esx_addons]/esx_mechanicjob/fxmanifest.lua index 80ab8883..dfc4140a 100644 --- a/[esx_addons]/esx_mechanicjob/fxmanifest.lua +++ b/[esx_addons]/esx_mechanicjob/fxmanifest.lua @@ -10,14 +10,28 @@ shared_script '@es_extended/imports.lua' client_scripts { '@es_extended/locale.lua', - 'locales/*.lua', + 'locales/en.lua', + 'locales/es.lua', + 'locales/fi.lua', + 'locales/fr.lua', + 'locales/br.lua', + 'locales/sv.lua', + 'locales/pl.lua', + 'locales/nl.lua', 'config.lua', 'client/main.lua' } server_scripts { '@es_extended/locale.lua', - 'locales/*.lua', + 'locales/en.lua', + 'locales/es.lua', + 'locales/fi.lua', + 'locales/fr.lua', + 'locales/br.lua', + 'locales/sv.lua', + 'locales/pl.lua', + 'locales/nl.lua', 'config.lua', 'server/main.lua' } diff --git a/[esx_addons]/esx_mechanicjob/locales/en.lua b/[esx_addons]/esx_mechanicjob/locales/en.lua index 45a04246..38d48934 100644 --- a/[esx_addons]/esx_mechanicjob/locales/en.lua +++ b/[esx_addons]/esx_mechanicjob/locales/en.lua @@ -1,7 +1,7 @@ Locales['en'] = { ['mechanic'] = 'mechanic', - ['drive_to_indicated'] = '~y~Drive~s~ to the indicated location.', - ['mission_canceled'] = 'Mission ~r~canceled~s~', + ['drive_to_indicated'] = 'Drive to the indicated location.', + ['mission_canceled'] = 'Mission canceled', ['vehicle_list'] = 'vehicle List', ['work_wear'] = 'workwear', ['civ_wear'] = 'civilian clothes', @@ -12,10 +12,10 @@ Locales['en'] = { ['flat_bed'] = 'flatbed', ['tow_truck'] = 'tow Truck', ['service_full'] = 'service full: ', - ['open_actions'] = 'Press ~INPUT_CONTEXT~ to access the menu.', + ['open_actions'] = 'Press [E] to access the menu.', ['harvest'] = 'harvest', - ['harvest_menu'] = 'press ~INPUT_CONTEXT~ to access the harvest menu.', - ['not_experienced_enough'] = 'you are not ~r~experienced enough~s~ to perform this action.', + ['harvest_menu'] = 'press [E] to access the harvest menu.', + ['not_experienced_enough'] = 'you are not experienced enough to perform this action.', ['gas_can'] = 'gas Can', ['repair_tools'] = 'repair Tools', ['body_work_tools'] = 'bodywork Tools', @@ -23,7 +23,7 @@ Locales['en'] = { ['repair_kit'] = 'repair Kit', ['body_kit'] = 'body Kit', ['craft'] = 'craft', - ['craft_menu'] = 'press ~INPUT_CONTEXT~ to access the crafting menu.', + ['craft_menu'] = 'press [E] to access the crafting menu.', ['billing'] = 'billing', ['hijack'] = 'hijack', ['repair'] = 'repair', @@ -35,19 +35,19 @@ Locales['en'] = { ['no_players_nearby'] = 'there is no nearby player', ['no_vehicle_nearby'] = 'there is no nearby vehicle', ['inside_vehicle'] = 'you can\'t do this from inside the vehicle!', - ['vehicle_unlocked'] = 'the vehicle has been ~g~unlocked', - ['vehicle_repaired'] = 'the vehicle has been ~g~repaired', - ['vehicle_cleaned'] = 'the vehicle has been ~g~cleaned', - ['vehicle_impounded'] = 'the vehicle has been ~r~impounded', + ['vehicle_unlocked'] = 'the vehicle has been unlocked', + ['vehicle_repaired'] = 'the vehicle has been repaired', + ['vehicle_cleaned'] = 'the vehicle has been cleaned', + ['vehicle_impounded'] = 'the vehicle has been impounded', ['must_seat_driver'] = 'you must be in the driver seat!', - ['must_near'] = 'you must be ~r~near a vehicle~s~ to impound it.', - ['vehicle_success_attached'] = 'vehicle successfully ~b~attached~s~', + ['must_near'] = 'you must be near a vehicle to impound it.', + ['vehicle_success_attached'] = 'vehicle successfully attached', ['please_drop_off'] = 'please drop off the vehicle at the garage', - ['cant_attach_own_tt'] = '~r~you can\'t~s~ attach own tow truck', - ['no_veh_att'] = 'there is no ~r~vehicle~s~ to be attached', + ['cant_attach_own_tt'] = 'you can\'t attach own tow truck', + ['no_veh_att'] = 'there is no vehicle to be attached', ['not_right_veh'] = 'this is not the right vehicle', - ['veh_det_succ'] = 'vehicle successfully ~b~dettached~s~!', - ['imp_flatbed'] = '~r~Action impossible!~s~ You need a ~b~Flatbed~s~ to load a vehicle', + ['veh_det_succ'] = 'vehicle successfully dettached!', + ['imp_flatbed'] = 'Action impossible! You need a Flatbed to load a vehicle', ['objects'] = 'objects', ['roadcone'] = 'roadcone', ['toolbox'] = 'toolbox', @@ -55,31 +55,31 @@ Locales['en'] = { ['quantity'] = 'quantity', ['invalid_quantity'] = 'invalid quantity', ['inventory'] = 'inventory', - ['veh_unlocked'] = '~g~Vehicle Unlocked', - ['hijack_failed'] = '~r~Hijack Failed', - ['body_repaired'] = '~g~Body repaired', - ['veh_repaired'] = '~g~Vehicle Repaired', - ['veh_stored'] = 'press ~INPUT_CONTEXT~ to store the vehicle.', - ['press_remove_obj'] = 'press ~INPUT_CONTEXT~ to remove the object', - ['please_tow'] = 'please ~y~tow~s~ the vehicle', - ['wait_five'] = 'you must ~r~wait~s~ 5 mintes', + ['veh_unlocked'] = 'Vehicle Unlocked', + ['hijack_failed'] = 'Hijack Failed', + ['body_repaired'] = 'Body repaired', + ['veh_repaired'] = 'Vehicle Repaired', + ['veh_stored'] = 'press [E] to store the vehicle.', + ['press_remove_obj'] = 'press [E] to remove the object', + ['please_tow'] = 'please tow the vehicle', + ['wait_five'] = 'you must wait 5 mintes', ['must_in_flatbed'] = 'you must be in a flatbed to being the mission', ['mechanic_customer'] = 'mechanic Customer', - ['you_do_not_room'] = '~r~You do not have more room', - ['recovery_gas_can'] = '~b~Gas Can~s~ Retrieval...', - ['recovery_repair_tools'] = '~b~Repair Tools~s~ Retrieval...', - ['recovery_body_tools'] = '~b~Body Tools~s~ Retrieval...', - ['not_enough_gas_can'] = 'You do not ~r~have enough~s~ gas cans.', - ['assembling_blowtorch'] = 'Assembling ~b~Blowtorch~s~...', - ['not_enough_repair_tools'] = 'You do not ~r~have enough~s~ repair tools.', - ['assembling_repair_kit'] = 'Assembling ~b~Repair Kit~s~...', - ['not_enough_body_tools'] = 'You do not ~r~have enough~s~ body tools.', - ['assembling_body_kit'] = 'Assembling ~b~Body Kit~s~...', - ['your_comp_earned'] = 'your company has ~g~earned~s~ ~g~$', - ['you_used_blowtorch'] = 'you used a ~b~blowtorch', - ['you_used_repair_kit'] = 'you used a ~b~Repair Kit', - ['you_used_body_kit'] = 'you used a ~b~Body Kit', - ['have_withdrawn'] = 'you have withdrawn ~y~x%s~s~ ~b~%s~s~', - ['have_deposited'] = 'you have deposited ~y~x%s~s~ ~b~%s~s~', - ['player_cannot_hold'] = 'you do ~r~not~s~ have enough ~y~free space~s~ in your inventory!', + ['you_do_not_room'] = 'You do not have more room', + ['recovery_gas_can'] = 'Gas Can Retrieval...', + ['recovery_repair_tools'] = 'Repair Tools Retrieval...', + ['recovery_body_tools'] = 'Body Tools Retrieval...', + ['not_enough_gas_can'] = 'You do not have enough gas cans.', + ['assembling_blowtorch'] = 'Assembling Blowtorch...', + ['not_enough_repair_tools'] = 'You do not have enough repair tools.', + ['assembling_repair_kit'] = 'Assembling Repair Kit...', + ['not_enough_body_tools'] = 'You do not have enough body tools.', + ['assembling_body_kit'] = 'Assembling Body Kit...', + ['your_comp_earned'] = 'your company has earned $', + ['you_used_blowtorch'] = 'you used a blowtorch', + ['you_used_repair_kit'] = 'you used a Repair Kit', + ['you_used_body_kit'] = 'you used a Body Kit', + ['have_withdrawn'] = 'you have withdrawn x%s %s', + ['have_deposited'] = 'you have deposited x%s %s', + ['player_cannot_hold'] = 'you do not have enough free space in your inventory!', } diff --git a/[esx_addons]/esx_mechanicjob/server/main.lua b/[esx_addons]/esx_mechanicjob/server/main.lua index 9981d5f6..42246c33 100644 --- a/[esx_addons]/esx_mechanicjob/server/main.lua +++ b/[esx_addons]/esx_mechanicjob/server/main.lua @@ -12,9 +12,9 @@ local function Harvest(source) if PlayersHarvesting[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local GazBottle = xPlayer.hasItem('gazbottle') + local GazBottleQuantity = xPlayer.getInventoryItem('gazbottle').count - if GazBottle and GazBottle.count >= 5 then + if GazBottleQuantity >= 5 then TriggerClientEvent('esx:showNotification', source, _U('you_do_not_room')) else xPlayer.addInventoryItem('gazbottle', 1) @@ -44,9 +44,9 @@ local function Harvest2(source) if PlayersHarvesting2[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local FixToolQuantity = xPlayer.hasItem('fixtool') + local FixToolQuantity = xPlayer.getInventoryItem('fixtool').count - if FixToolQuantity and FixToolQuantity.count >= 5 then + if FixToolQuantity >= 5 then TriggerClientEvent('esx:showNotification', source, _U('you_do_not_room')) else xPlayer.addInventoryItem('fixtool', 1) @@ -107,9 +107,9 @@ local function Craft(source) if PlayersCrafting[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local GazBottleQuantity = xPlayer.hasItem('gazbottle') + local GazBottleQuantity = xPlayer.getInventoryItem('gazbottle').count - if not GazBottleQuantity then + if GazBottleQuantity <= 0 then TriggerClientEvent('esx:showNotification', source, _U('not_enough_gas_can')) else xPlayer.removeInventoryItem('gazbottle', 1) @@ -140,9 +140,9 @@ local function Craft2(source) if PlayersCrafting2[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local FixToolQuantity = xPlayer.hasItem('fixtool') + local FixToolQuantity = xPlayer.getInventoryItem('fixtool').count - if not FixToolQuantity then + if FixToolQuantity <= 0 then TriggerClientEvent('esx:showNotification', source, _U('not_enough_repair_tools')) else xPlayer.removeInventoryItem('fixtool', 1)