diff --git a/server-data/resources/[esx_addons]/esx_drivingschooljob/client/main.lua b/server-data/resources/[esx_addons]/esx_drivingschooljob/client/main.lua index 1f968bf4f..7f65e7fbd 100644 --- a/server-data/resources/[esx_addons]/esx_drivingschooljob/client/main.lua +++ b/server-data/resources/[esx_addons]/esx_drivingschooljob/client/main.lua @@ -10,29 +10,19 @@ local Keys = { ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 } -local PlayerData = {} -local GUI = {} + local HasAlreadyEnteredMarker = false local LastZone = nil local CurrentAction = nil local CurrentActionMsg = '' local CurrentActionData = {} -local TargetCoords = nil -local Blips = {} local Licenses = {} local CurrentTest = nil -local CurrentTestType = nil - +local GUI = {} ESX = nil GUI.Time = 0 -CreateThread(function() - ESX = exports["es_extended"]:getSharedObject() - while ESX.GetPlayerData().job == nil do - Wait(10) - end - ESX.PlayerData = ESX.GetPlayerData() -end) +ESX = exports["es_extended"]:getSharedObject() function OpenDrivingSchoolMenu() ESX.UI.Menu.CloseAll() @@ -48,16 +38,16 @@ function OpenDrivingSchoolMenu() if data.current.value == 'give' then local elements = { - {label = _U('traffic_give'), value = 'trg'}} + {label = _U('traffic_give'), value = 'trg'}} if ESX.PlayerData.job.grade_name == 'examiner' then table.insert(elements, {label = _U('car_give'), value = 'carg'}) end - + if ESX.PlayerData.job.grade_name == 'examiner' then table.insert(elements, {label = _U('motor_give'), value = 'motg'}) end - + if ESX.PlayerData.job.grade_name == 'examiner' then table.insert(elements, {label = _U('truck_give'), value = 'truckg'}) end @@ -93,11 +83,11 @@ elseif data.current.value == 'remove' then if ESX.PlayerData.job.grade_name == 'carinstr' or ESX.PlayerData.job.grade_name == 'examiner' then table.insert(elements, {label = _U('car_remove'), value = 'carr'}) end - + if ESX.PlayerData.job.grade_name == 'motorinstr' or ESX.PlayerData.job.grade_name == 'examiner' then table.insert(elements, {label = _U('motor_remove'), value = 'motr'}) end - + if ESX.PlayerData.job.grade_name == 'truckinstr' or ESX.PlayerData.job.grade_name == 'examiner' then table.insert(elements, {label = _U('truck_remove'), value = 'truckrr'}) end @@ -124,13 +114,13 @@ ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'remove', { else ESX.ShowNotification(_U('no_players_nearby')) end - end, function(data2, menu2) + end, function(_, menu2) menu2.close() end) elseif data.current.value == 'bill' then OpenBillingMenu() end -end, function(data, menu) +end, function(_, menu) menu.close() end) end @@ -140,7 +130,7 @@ function OpenBillingMenu() ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'bil', { title = 'billing_amount' }, function(data, menu) - + local amount = tonumber(data.value) local player, distance = ESX.Game.GetClosestPlayer() @@ -155,7 +145,7 @@ function OpenBillingMenu() else ESX.ShowNotification(_U('no_players_nearby')) end - end, function(data, menu) + end, function(_, menu) menu.close() end) end @@ -206,7 +196,7 @@ function OpenDMVSchoolMenu() label = (('%s: %s'):format(_U('theory_test'), _U('school_item', ESX.Math.GroupDigits(Config.TheoryPrice)))), value = 'theory_test' }) - + end ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'dmvschool_actions', { @@ -218,7 +208,7 @@ function OpenDMVSchoolMenu() menu.close() StartTheoryTest() end - end, function(data, menu) + end, function(_, menu) menu.close() CurrentAction = 'theory_menu' @@ -227,19 +217,19 @@ function OpenDMVSchoolMenu() end) end -RegisterNUICallback('question', function(data, cb) +RegisterNUICallback('question', function(_, cb) SendNUIMessage({ openSection = 'question' }) cb() end) -RegisterNUICallback('close', function(data, cb) +RegisterNUICallback('close', function(_, cb) StopTheoryTest(true) cb() end) -RegisterNUICallback('kick', function(data, cb) +RegisterNUICallback('kick', function(_, cb) StopTheoryTest(false) cb() end) @@ -257,13 +247,12 @@ function OpenDrivingActionsMenu() end ESX.UI.Menu.CloseAll() - ESX.UI.Menu.Open( - 'default', GetCurrentResourceName(), 'driving_actions', + ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'driving_actions', { title = _U('vehicle_list'), elements = elements }, - function(data, menu) + function(data) if data.current.value == 'vehicle_list' then if Config.EnableSocietyOwnedVehicles then @@ -276,8 +265,7 @@ function OpenDrivingActionsMenu() table.insert(elements, {label = GetDisplayNameFromVehicleModel(vehicles[i].model) .. ' [' .. vehicles[i].plate .. ']', value = vehicles[i]}) end - ESX.UI.Menu.Open( - 'default', GetCurrentResourceName(), 'vehicle_spawner', + ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner', { title = _U('service_vehicle'), align = 'top-left', @@ -312,15 +300,15 @@ function OpenDrivingActionsMenu() {label = 'Motor', value = 'sanchez'}, {label = 'Truck', value = 'mule'} } - + if ESX.PlayerData.job.grade_name == 'carinstr' then table.insert(elements, {label = _U('car'), value = 'issi2'}) end - + if ESX.PlayerData.job.grade_name == 'motorinstr' then table.insert(elements, {label = _U('motor'), value = 'esskey'}) end - + if ESX.PlayerData.job.grade_name == 'truckinstr' then table.insert(elements, {label = _U('truck'), value = 'packer'}) end @@ -479,7 +467,7 @@ CreateThread(function() local coords = GetEntityCoords(GetPlayerPed(-1)) local isInMarker = false local currentZone = nil - + if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'driving' then local coords = GetEntityCoords(GetPlayerPed(-1)) local isInMarker = false @@ -499,7 +487,7 @@ CreateThread(function() HasAlreadyEnteredMarker = false TriggerEvent('esx_drivingschooljob:hasExitedMarker', LastZone) end - else + else for a,v in pairs(Config.Theory) do if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x) then isInMarker = true @@ -549,7 +537,7 @@ CreateThread(function() SetTextComponentFormat('STRING') AddTextComponentString(CurrentActionMsg) DisplayHelpTextFromStringLabel(0, 0, 1, -1) - + if IsControlJustReleased(0, 206) then if CurrentAction == 'theory_menu' then OpenDMVSchoolMenu() @@ -561,7 +549,6 @@ CreateThread(function() if CurrentAction == 'driving_actions_menu' then OpenDrivingActionsMenu() end - if CurrentAction == 'delete_vehicle' then @@ -590,8 +577,6 @@ CreateThread(function() if IsControlJustReleased(0, Keys['F6']) and ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'driving' then OpenDrivingSchoolMenu() - else - --Citizen.Wait(100) - end + end end end) \ No newline at end of file