1

I am new to scripting in lua, but I try to fix an existing script. It's a script that can be used in FiveM. It is used to impound vehicles. This is the code: Line 1: local currentTask = {}

Starting at line 852:

852     elseif action == 'impound' then
853     
854         -- is the script busy?
855         if CurrentTask.Busy then
856             return
857         end
858
859         ESX.ShowHelpNotification(_U('impound_prompt'))
860                     
861         TaskStartScenarioInPlace(playerPed, 'CDE_HUMAN_MEDIC_TEND_TO_DEAD', 0, true)
862         
863         CurrentTask.Busy = true
864         CurrentTask.Task = ESX.SetTimeout(10000, function()
865             ClearPedTasks(playerPed)
866             ImpoundVehicle(vehicle)
867             Citizen.Wait(100) -- sleep the entire script to let stuff sink back to reality
868         end)
869         
870         -- keep track of that vehicle!
871         Citizen.CreateThread(function()
872             while CurrentTask.Busy do
873                 Citizen.Wait(1000)
874             
875                 vehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 3.0, 0, 71)
876                 if not DoesEntityExist(vehicle) and CurrentTask.Busy then
877                     ESX.ShowNotification(_U('impound_canceled_moved'))
878                     ESX.ClearTimeout(CurrentTask.Task)
879                     ClearPedTasks(playerPed)
880                     CurrentTask.Busy = false
881                     break
882                 end
883             end
884         end)
885     end
886 else
887     ESX.ShowNotification(_U('no_vehicles_nearby'))
888 end
889
890 end, function(data2, menu2)
891     menu2.close()
892 end)

I tried commenting lines 855, 856 and 857. But then I get the same error on line 864

  • please don't include line numbers like that - it means the code can't be read or copy/paste and run/checked. In future please include the error message, verbatim, and just indicate in the code block which line is the line mentioned in the error message. – AD7six Dec 09 '22 at 09:49
  • 3
    also delete your post if it was just a typo instead of writing an answer. it is of no value – Piglet Dec 09 '22 at 10:44

1 Answers1

1

I found the error, at line one, it was called "currentTask", but in the rest of the script it was called "CurrentTask" with a capitol C!