Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 57 additions & 70 deletions [esx_addons]/esx_mechanicjob/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ function StopNPCJob(cancel)

if cancel then
ESX.ShowNotification(TranslateCap('mission_canceled'), "error")
else
--TriggerServerEvent('esx_mechanicjob:onNPCJobCompleted')
end
end

Expand Down Expand Up @@ -175,22 +173,16 @@ function OpenMechanicActionsMenu()
end

function OpenMechanicHarvestMenu()
if Config.EnablePlayerManagement and ESX.PlayerData.job and ESX.PlayerData.job.grade_name ~= 'recrue' then
if Config.EnablePlayerManagement and ESX.PlayerData.job and ESX.PlayerData.job.grade ~= 0 then
local elements = {
{ unselectable = true, icon = "fas fa-gear", title = "Mechanic Harvest Menu" },
{ icon = "fas fa-gear", title = TranslateCap('gas_can'), value = 'gaz_bottle' },
{ icon = "fas fa-gear", title = TranslateCap('repair_tools'), value = 'fix_tool' },
{ icon = "fas fa-gear", title = TranslateCap('body_work_tools'), value = 'caro_tool' }
{ icon = "fas fa-gear", title = TranslateCap('gas_can'), value = 'gazbottle' },
{ icon = "fas fa-gear", title = TranslateCap('repair_tools'), value = 'fixtool' },
{ icon = "fas fa-gear", title = TranslateCap('body_work_tools'), value = 'carotool' }
}

ESX.OpenContext("right", elements, function(menu, element)
if element.value == 'gaz_bottle' then
TriggerServerEvent('esx_mechanicjob:startHarvest')
elseif element.value == 'fix_tool' then
TriggerServerEvent('esx_mechanicjob:startHarvest2')
elseif element.value == 'caro_tool' then
TriggerServerEvent('esx_mechanicjob:startHarvest3')
end
TriggerServerEvent('esx_mechanicjob:startHarvest', element.value)
end, function(menu)
CurrentAction = 'mechanic_harvest_menu'
CurrentActionMsg = TranslateCap('harvest_menu')
Expand All @@ -202,22 +194,16 @@ function OpenMechanicHarvestMenu()
end

function OpenMechanicCraftMenu()
if Config.EnablePlayerManagement and ESX.PlayerData.job and ESX.PlayerData.job.grade_name ~= 'recrue' then
if Config.EnablePlayerManagement and ESX.PlayerData.job and ESX.PlayerData.job.grade ~= 0 then
local elements = {
{ unselectable = true, icon = "fas fa-gear", title = "Mechanic Craft Menu" },
{ icon = "fas fa-gear", title = TranslateCap('blowtorch'), value = 'blow_pipe' },
{ icon = "fas fa-gear", title = TranslateCap('repair_kit'), value = 'fix_kit' },
{ icon = "fas fa-gear", title = TranslateCap('body_kit'), value = 'caro_kit' }
{ icon = "fas fa-gear", title = TranslateCap('blowtorch'), value = 'blowpipe' },
{ icon = "fas fa-gear", title = TranslateCap('repair_kit'), value = 'fixkit' },
{ icon = "fas fa-gear", title = TranslateCap('body_kit'), value = 'carokit' }
}

ESX.OpenContext("right", elements, function(menu, element)
if element.value == 'blow_pipe' then
TriggerServerEvent('esx_mechanicjob:startCraft')
elseif element.value == 'fix_kit' then
TriggerServerEvent('esx_mechanicjob:startCraft2')
elseif element.value == 'caro_kit' then
TriggerServerEvent('esx_mechanicjob:startCraft3')
end
TriggerServerEvent('esx_mechanicjob:startCraft', element.value)
end, function(menu)
CurrentAction = 'mechanic_craft_menu'
CurrentActionMsg = TranslateCap('craft_menu')
Expand Down Expand Up @@ -261,15 +247,14 @@ function OpenMobileMechanicActionsMenu()
ESX.ShowNotification(TranslateCap('no_players_nearby'), "error")
else
ESX.CloseContext()
TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_mechanic',
TranslateCap('mechanic'), amount)
TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_mechanic', TranslateCap('mechanic'), amount)
end
end
end)
elseif element.value == "hijack_vehicle" then
local playerPed = PlayerPedId()
local vehicle = ESX.Game.GetVehicleInDirection()
local coords = GetEntityCoords(playerPed)
local coords = GetEntityCoords(playerPed)
local vehicle, distance = ESX.Game.GetClosestVehicle(coords)

if IsPedSittingInAnyVehicle(playerPed) then
ESX.ShowNotification(TranslateCap('inside_vehicle'))
Expand All @@ -294,8 +279,8 @@ function OpenMobileMechanicActionsMenu()
end
elseif element.value == "fix_vehicle" then
local playerPed = PlayerPedId()
local vehicle = ESX.Game.GetVehicleInDirection()
local coords = GetEntityCoords(playerPed)
local vehicle, distance = ESX.Game.GetClosestVehicle(coords)

if IsPedSittingInAnyVehicle(playerPed) then
ESX.ShowNotification(TranslateCap('inside_vehicle'))
Expand All @@ -322,8 +307,8 @@ function OpenMobileMechanicActionsMenu()
end
elseif element.value == "clean_vehicle" then
local playerPed = PlayerPedId()
local vehicle = ESX.Game.GetVehicleInDirection()
local coords = GetEntityCoords(playerPed)
local vehicle, distance = ESX.Game.GetClosestVehicle(coords)

if IsPedSittingInAnyVehicle(playerPed) then
ESX.ShowNotification(TranslateCap('inside_vehicle'))
Expand All @@ -347,6 +332,7 @@ function OpenMobileMechanicActionsMenu()
end
elseif element.value == "del_vehicle" then
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)

if IsPedSittingInAnyVehicle(playerPed) then
local vehicle = GetVehiclePedIsIn(playerPed, false)
Expand All @@ -358,7 +344,7 @@ function OpenMobileMechanicActionsMenu()
ESX.ShowNotification(TranslateCap('must_seat_driver'))
end
else
local vehicle = ESX.Game.GetVehicleInDirection()
local vehicle, distance = ESX.Game.GetClosestVehicle(coords)

if DoesEntityExist(vehicle) then
ESX.ShowNotification(TranslateCap('vehicle_impounded'))
Expand All @@ -369,13 +355,15 @@ function OpenMobileMechanicActionsMenu()
end
elseif element.value == "dep_vehicle" then
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)

local vehicle = GetVehiclePedIsIn(playerPed, true)

local towmodel = `flatbed`
local isVehicleTow = IsVehicleModel(vehicle, towmodel)

if isVehicleTow then
local targetVehicle = ESX.Game.GetVehicleInDirection()
local vehicle, distance = ESX.Game.GetClosestVehicle(coords)

if CurrentlyTowedVehicle == nil then
if targetVehicle ~= 0 then
Expand Down Expand Up @@ -452,15 +440,9 @@ function OpenMobileMechanicActionsMenu()
local model = elementObj.value
local coords = GetEntityCoords(playerPed)
local forward = GetEntityForwardVector(playerPed)
local x, y, z = table.unpack(coords + forward * 1.0)

if model == 'prop_roadcone02a' then
z = z - 2.0
elseif model == 'prop_toolchest_01' then
z = z - 2.0
end
local spawn = coords + forward * 1.0

ESX.Game.SpawnObject(model, { x = x, y = y, z = z }, function(obj)
ESX.Game.SpawnObject(model, spawn, function(obj)
SetEntityHeading(obj, GetEntityHeading(playerPed))
PlaceObjectOnGroundProperly(obj)
end)
Expand Down Expand Up @@ -690,7 +672,7 @@ AddEventHandler('esx_mechanicjob:hasEnteredMarker', function(zone)
end
end

if zone ~= 'VehicleSpawnPoint' then
if zone ~= 'VehicleSpawnPoint' and CurrentActionMsg ~= '' then
ESX.TextUI(CurrentActionMsg)
end
end)
Expand All @@ -700,14 +682,9 @@ AddEventHandler('esx_mechanicjob:hasExitedMarker', function(zone)
NPCTargetDeleterZone = false
elseif zone == 'Craft' then
TriggerServerEvent('esx_mechanicjob:stopCraft')
TriggerServerEvent('esx_mechanicjob:stopCraft2')
TriggerServerEvent('esx_mechanicjob:stopCraft3')
elseif zone == 'Garage' then
TriggerServerEvent('esx_mechanicjob:stopHarvest')
TriggerServerEvent('esx_mechanicjob:stopHarvest2')
TriggerServerEvent('esx_mechanicjob:stopHarvest3')
end

CurrentAction = nil
ESX.CloseContext()
ESX.HideUI()
Expand All @@ -731,19 +708,6 @@ AddEventHandler('esx_mechanicjob:hasExitedEntityZone', function(entity)
ESX.HideUI()
end)

RegisterNetEvent('esx_phone:loaded')
AddEventHandler('esx_phone:loaded', function(phoneNumber, contacts)
local specialContact = {
name = TranslateCap('mechanic'),
number = 'mechanic',
base64Icon =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBAJqcGAAAA4BJREFUWIXtll9oU3cUx7/nJA02aSSlFouWMnXVB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7N6zqZicVT2WNLyVSehESaBhxnOALfMeYX+K/S2yv7wmMAlvwyuR7FxQUyf0fgc/jztfkJr7XeGgC8BJJgWNV8ImT+AAAAAElFTkSuQmCC'
}

TriggerEvent('esx_phone:addSpecialContact', specialContact.name, specialContact.number, specialContact.base64Icon)
end)

-- Pop NPC mission vehicle when inside area
CreateThread(function()
while true do
local Sleep = 1500
Expand Down Expand Up @@ -779,7 +743,6 @@ CreateThread(function()
end
end)

-- Create Blips
CreateThread(function()
local blip = AddBlipForCoord(Config.Zones.MechanicActions.Pos.x, Config.Zones.MechanicActions.Pos.y,
Config.Zones.MechanicActions.Pos.z)
Expand All @@ -795,7 +758,21 @@ CreateThread(function()
EndTextCommandSetBlipName(blip)
end)

-- Display markers
CreateThread(function()
local blip = AddBlipForCoord(Config.Zones.VehicleDeleter.Pos.x, Config.Zones.VehicleDeleter.Pos.y,
Config.Zones.VehicleDeleter.Pos.z)

SetBlipSprite(blip, 446)
SetBlipDisplay(blip, 4)
SetBlipScale(blip, 1.0)
SetBlipColour(blip, 3)
SetBlipAsShortRange(blip, true)

BeginTextCommandSetBlipName('STRING')
AddTextComponentSubstringPlayerName('Vehicle Storage')
EndTextCommandSetBlipName(blip)
end)

CreateThread(function()
while true do
local Sleep = 2000
Expand All @@ -806,18 +783,27 @@ 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, true, true, 2, true, nil, nil, false)
letSleep = false
if k == 'VehicleDeleter' then
local playerPed = PlayerPedId()
if IsPedInAnyVehicle(playerPed, false) 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, true, true, 2, true, nil, nil, false)
letSleep = false
end
else
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, true, true, 2, true, nil, nil, false)
letSleep = false
end
end
end
end
Wait(Sleep)
end
end)

-- Enter / Exit marker events
CreateThread(function()
while true do
local Sleep = 500
Expand Down Expand Up @@ -893,7 +879,6 @@ CreateThread(function()
end
end)

-- Key Controls
CreateThread(function()
while true do
local sleep = 500
Expand All @@ -912,12 +897,15 @@ CreateThread(function()
TriggerServerEvent('esx_society:putVehicleInGarage', 'mechanic', vehicleProps)
else
local entityModel = GetEntityModel(CurrentActionData.vehicle)

if entityModel == `flatbed` or entityModel == `towtruck2` or entityModel == `slamvan3` then
TriggerServerEvent('esx_service:disableService', 'mechanic')
end
end
ESX.Game.DeleteVehicle(CurrentActionData.vehicle)
CurrentAction = nil
CurrentActionMsg = ''
CurrentActionData = {}
ESX.HideUI()
elseif CurrentAction == 'remove_entity' then
DeleteEntity(CurrentActionData.entity)
end
Expand All @@ -928,14 +916,13 @@ CreateThread(function()
Wait(sleep)
end
end)

RegisterCommand('mechanicMenu', function()
if ESX.PlayerData.job and ESX.PlayerData.job.name == 'mechanic' then
OpenMobileMechanicActionsMenu()
end
end, false)



RegisterCommand('mechanicjob', function()
local playerPed = PlayerPedId()
if ESX.PlayerData.job and ESX.PlayerData.job.name == 'mechanic' then
Expand Down
20 changes: 10 additions & 10 deletions [esx_addons]/esx_mechanicjob/esx_mechanicjob.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ INSERT INTO `jobs` (name, label) VALUES
;

INSERT INTO `job_grades` (job_name, grade, name, label, salary, skin_male, skin_female) VALUES
('mechanic',0,'recrue','Recrue',12,'{}','{}'),
('mechanic',0,'recrue','Recruit',12,'{}','{}'),
('mechanic',1,'novice','Novice',24,'{}','{}'),
('mechanic',2,'experimente','Experimente',36,'{}','{}'),
('mechanic',3,'chief',"Chef d\'équipe",48,'{}','{}'),
('mechanic',4,'boss','Patron',0,'{}','{}')
('mechanic',2,'experimente','Experienced',36,'{}','{}'),
('mechanic',3,'chief','Leader',48,'{}','{}'),
('mechanic',4,'boss','Boss',0,'{}','{}')
;

INSERT INTO `items` (name, label, weight) VALUES
('gazbottle', 'bouteille de gaz', 2),
('fixtool', 'outils réparation', 2),
('carotool', 'outils carosserie', 2),
('blowpipe', 'Chalumeaux', 2),
('fixkit', 'Kit réparation', 3),
('carokit', 'Kit carosserie', 3)
('gazbottle', 'Gas Bottle', 2),
('fixtool', 'Repair Tools', 2),
('carotool', 'Body Tools', 2),
('blowpipe', 'Blowtorch', 2),
('fixkit', 'Repair Kit', 3),
('carokit', 'Body Kit', 3)
;
2 changes: 2 additions & 0 deletions [esx_addons]/esx_mechanicjob/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ server_scripts {
'@es_extended/locale.lua',
'locales/*.lua',
'config.lua',
'server/callbacks.lua',
'server/usables.lua',
'server/main.lua'
}

Expand Down
18 changes: 9 additions & 9 deletions [esx_addons]/esx_mechanicjob/locales/de.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ Locales['de'] = {
['must_in_flatbed'] = 'Du musst dafür in einem Abschleppwagen sitzen',
['mechanic_customer'] = 'Mechaniker Kunde',
['you_do_not_room'] = 'Du hast nicht genügend Platz',
['recovery_gas_can'] = 'Benzin Kanister wird abgerufen...',
['recovery_repair_tools'] = 'Reparierungstools werden abgerufen...',
['recovery_body_tools'] = 'Body Tools Abruf...',
['not_enough_gas_can'] = 'Du hast nicht genügend Benzinkanister.',
['assembling_blowtorch'] = 'Schweißbrenner wird angebracht...',
['not_enough_repair_tools'] = 'Du hast nicht genug Reparierungstools.',
['assembling_repair_kit'] = 'Zusammenbau des Reparatursatzes...',
['not_enough_body_tools'] = 'Du haben nicht genügend Bodytools.',
['assembling_body_kit'] = 'Zusammenbau des Bodykits...',
['recovery_gazbottle'] = 'Benzin Kanister wird abgerufen...',
['recovery_fixtool'] = 'Reparierungstools werden abgerufen...',
['recovery_carotool'] = 'Body Tools Abruf...',
['not_enough_gazbottle'] = 'Du hast nicht genügend Benzinkanister.',
['assembling_blowpipe'] = 'Schweißbrenner wird angebracht...',
['not_enough_fixtool'] = 'Du hast nicht genug Reparierungstools.',
['assembling_fixkit'] = 'Zusammenbau des Reparatursatzes...',
['not_enough_carotool'] = 'Du haben nicht genügend Bodytools.',
['assembling_carokit'] = 'Zusammenbau des Bodykits...',
['your_comp_earned'] = 'Deine Firma verdient €',
['you_used_blowtorch'] = 'Du nutzt einen Schweißbrenner',
['you_used_repair_kit'] = 'Du nutzt ein Reparierungskit',
Expand Down
18 changes: 9 additions & 9 deletions [esx_addons]/esx_mechanicjob/locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ Locales['en'] = {
['must_in_flatbed'] = 'you must be in a flatbed to being the mission',
['mechanic_customer'] = 'mechanic Customer',
['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...',
['recovery_gazbottle'] = 'Gas Can Retrieval...',
['recovery_fixtool'] = 'Repair Tools Retrieval...',
['recovery_carotool'] = 'Body Tools Retrieval...',
['not_enough_gazbottle'] = 'You do not have enough gas cans.',
['assembling_blowpipe'] = 'Assembling Blowtorch...',
['not_enough_fixtool'] = 'You do not have enough repair tools.',
['assembling_fixkit'] = 'Assembling Repair Kit...',
['not_enough_carotool'] = 'You do not have enough body tools.',
['assembling_carokit'] = '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',
Expand Down
Loading
Loading