Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Client side
- function procent(time, time2)
- showPro = true
- TimeLeft = 0
- repeat
- TimeLeft = TimeLeft + 1
- Citizen.Wait(time)
- until(TimeLeft == time2)
- showPro = false
- end
- function DrawText3D(x, y, z, text, scale)
- local onScreen, _x, _y = World3dToScreen2d(x, y, z)
- local pX, pY, pZ = table.unpack(GetGameplayCamCoords())
- SetTextScale(scale, scale)
- SetTextFont(4)
- SetTextProportional(1)
- SetTextEntry("STRING")
- SetTextCentre(1)
- SetTextColour(255, 255, 255, 255)
- SetTextOutline()
- AddTextComponentString(text)
- DrawText(_x, _y)
- local factor = (string.len(text)) / 270
- DrawRect(_x, _y + 0.015, 0.005 + factor, 0.03, 31, 31, 31, 155)
- end
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(6)
- if showPro == true then
- local playerPed = PlayerPedId()
- local coords = GetEntityCoords(playerPed)
- DrawText3D(coords.x, coords.y, coords.z, TimeLeft .. '~g~%', 0.4)
- end
- end
- end)
- RegisterNetEvent('base:onUse')
- AddEventHandler('base:onUse', function()
- local playerPed = GetPlayerPed(-1)
- local coords = GetEntityCoords(playerPed)
- if IsAnyVehicleNearPoint(coords.x, coords.y, coords.z, 5.0) then
- local vehicle = nil
- if IsPedInAnyVehicle(playerPed, false) then
- vehicle = GetVehiclePedIsIn(playerPed, false)
- else
- vehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 5.0, 0, 71)
- end
- if DoesEntityExist(vehicle) then
- lockpicking = false
- ---print(lockpicking)
- randi = math.random(1, 10)
- if randi < 5 then
- RequestAnimDict("missheistfbisetup1")
- while (not HasAnimDictLoaded("missheistfbisetup1")) do
- Citizen.Wait(0)
- end
- FreezeEntityPosition(GetPlayerPed(-1), true)
- TaskPlayAnim(GetPlayerPed(-1), "missheistfbisetup1" ,"hassle_intro_loop_f" ,8.0, -8.0, -1, 1, 0, false, false, false )
- Wait(5000)
- procent(100, 69)
- TriggerServerEvent('base:removeKit')
- ESX.ShowNotification('Lockpick failed')
- ClearPedTasksImmediately(playerPed)
- FreezeEntityPosition(GetPlayerPed(-1), false)
- end
- if randi > 5 then
- RequestAnimDict("missheistfbisetup1")
- while (not HasAnimDictLoaded("missheistfbisetup1")) do
- Citizen.Wait(0)
- end
- FreezeEntityPosition(GetPlayerPed(-1), true)
- TaskPlayAnim(GetPlayerPed(-1), "missheistfbisetup1" ,"hassle_intro_loop_f" ,8.0, -8.0, -1, 1, 0, false, false, false )
- if useInteractSound then
- TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'lockpick', 0.7)
- end
- Citizen.CreateThread(function()
- ThreadID = GetIdOfThisThread()
- CurrentAction = 'lockpick'
- Citizen.Wait(22 * 1000)
- if CurrentAction ~= nil then
- procent(100, 100)
- SetVehicleDoorsLocked(vehicle, 1)
- SetVehicleDoorsLockedForAllPlayers(vehicle, false)
- ClearPedTasksImmediately(playerPed)
- FreezeEntityPosition(GetPlayerPed(-1), false)
- ESX.ShowNotification('You have unlocked the car')
- end
- CurrentAction = nil
- --TerminateThisThread()
- end)
- end
- end
- Citizen.CreateThread(function()
- Citizen.Wait(0)
- if CurrentAction ~= nil then
- SetTextComponentFormat('STRING')
- AddTextComponentString("~g~[X]~w~ To abort lockpicking")
- DisplayHelpTextFromStringLabel(0, 0, 1, -1)
- if IsControlJustReleased(0, Keys["X"]) then
- TerminateThread(ThreadID)
- ESX.ShowNotification("You have aborted the lockpicking")
- CurrentAction = nil
- end
- end
- end)
- end
- end)
- RegisterNetEvent('base:Lockpick')
- AddEventHandler('base:Lockpick', function(xPlayer)
- lockpicking = true
- Citizen.Wait(100)
- lockpicking = false
- end)
- -- Server Side
- ESX.RegisterUsableItem('lockpick', function(source)
- local _source = source
- local xPlayer = ESX.GetPlayerFromId(_source)
- TriggerClientEvent('base:Lockpick', _source)
- TriggerClientEvent('base:onUse', _source)
- end)
- RegisterNetEvent('base:removeKit')
- AddEventHandler('base:removeKit', function()
- local _source = source
- local xPlayer = ESX.GetPlayerFromId(_source)
- xPlayer.removeInventoryItem('lockpick', 1)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement