diff --git a/[esx_addons]/esx_holdup/client/main.lua b/[esx_addons]/esx_holdup/client/main.lua index ac49e234..d9d0e0d5 100644 --- a/[esx_addons]/esx_holdup/client/main.lua +++ b/[esx_addons]/esx_holdup/client/main.lua @@ -1,18 +1,19 @@ local holdingUp = false -local store = "" +local store = '' local blipRobbery = nil -function drawTxt(x,y, width, height, scale, text, r,g,b,a, outline) +function DrawTxt(x,y, width, height, scale, text, r, g, b, a, outline) SetTextFont(0) SetTextScale(scale, scale) SetTextColour(r, g, b, a) SetTextDropshadow(0, 0, 0, 0,255) SetTextDropShadow() - if outline then SetTextOutline() end - + if outline then + SetTextOutline() + end BeginTextCommandDisplayText('STRING') AddTextComponentSubstringPlayerName(text) - EndTextCommandDisplayText(x - width/2, y - height/2 + 0.005) + EndTextCommandDisplayText(x - width / 2, y - height / 2 + 0.005) end RegisterNetEvent('esx_holdup:currentlyRobbing') @@ -27,12 +28,10 @@ end) RegisterNetEvent('esx_holdup:setBlip') AddEventHandler('esx_holdup:setBlip', function(position) - blipRobbery = AddBlipForCoord(position.x, position.y, position.z) - + blipRobbery = AddBlipForCoord(position) SetBlipSprite(blipRobbery, 161) SetBlipScale(blipRobbery, 2.0) SetBlipColour(blipRobbery, 3) - PulseBlip(blipRobbery) end) @@ -51,33 +50,29 @@ end) RegisterNetEvent('esx_holdup:startTimer') AddEventHandler('esx_holdup:startTimer', function() local timer = Stores[store].secondsRemaining - Citizen.CreateThread(function() while timer > 0 and holdingUp do Citizen.Wait(1000) - if timer > 0 then timer = timer - 1 end end end) - Citizen.CreateThread(function() while holdingUp do - Citizen.Wait(0) - drawTxt(0.66, 1.44, 1.0, 1.0, 0.4, _U('robbery_timer', timer), 255, 255, 255, 255) + Citizen.Wait(1) + DrawTxt(0.66, 1.44, 1.0, 1.0, 0.4, _U('robbery_timer', timer), 255, 255, 255, 255) end end) end) Citizen.CreateThread(function() for k,v in pairs(Stores) do - local blip = AddBlipForCoord(v.position.x, v.position.y, v.position.z) + local blip = AddBlipForCoord(v.position) SetBlipSprite(blip, 156) SetBlipScale(blip, 0.8) SetBlipAsShortRange(blip, true) - - BeginTextCommandSetBlipName("STRING") + BeginTextCommandSetBlipName('STRING') AddTextComponentString(_U('shop_robbery')) EndTextCommandSetBlipName(blip) end @@ -86,19 +81,15 @@ end) Citizen.CreateThread(function() while true do Citizen.Wait(1) - local playerPos = GetEntityCoords(PlayerPedId(), true) - + local playerPos, letSleep = GetEntityCoords(PlayerPedId()), true for k,v in pairs(Stores) do - local storePos = v.position - local distance = Vdist(playerPos.x, playerPos.y, playerPos.z, storePos.x, storePos.y, storePos.z) - + local distance = #(playerPos - v.position) if distance < Config.Marker.DrawDistance then if not holdingUp then - DrawMarker(Config.Marker.Type, storePos.x, storePos.y, storePos.z - 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Marker.x, Config.Marker.y, Config.Marker.z, Config.Marker.r, Config.Marker.g, Config.Marker.b, Config.Marker.a, false, false, 2, false, false, false, false) - + letSleep = false + DrawMarker(Config.Marker.Type, v.position, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Config.Marker.x, Config.Marker.y, Config.Marker.z, Config.Marker.r, Config.Marker.g, Config.Marker.b, Config.Marker.a, false, false, 2, false, false, false, false) if distance < 0.5 then ESX.ShowHelpNotification(_U('press_to_rob', v.nameOfStore)) - if IsControlJustReleased(0, 38) then if IsPedArmed(PlayerPedId(), 4) then TriggerServerEvent('esx_holdup:robberyStarted', k) @@ -108,14 +99,17 @@ Citizen.CreateThread(function() end end end + break end end - if holdingUp then - local storePos = Stores[store].position - if Vdist(playerPos.x, playerPos.y, playerPos.z, storePos.x, storePos.y, storePos.z) > Config.MaxDistance then + letSleep = false + if #(playerPos - Stores[store].position) > Config.MaxDistance then TriggerServerEvent('esx_holdup:tooFar', store) end end + if letSleep then + Citizen.Wait(500) + end end end)