Advertisement
Guest User

lockpicking

a guest
Sep 20th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. -- Client side
  2.  
  3. function procent(time, time2)
  4. showPro = true
  5. TimeLeft = 0
  6. repeat
  7. TimeLeft = TimeLeft + 1
  8. Citizen.Wait(time)
  9. until(TimeLeft == time2)
  10. showPro = false
  11. end
  12.  
  13. function DrawText3D(x, y, z, text, scale)
  14. local onScreen, _x, _y = World3dToScreen2d(x, y, z)
  15. local pX, pY, pZ = table.unpack(GetGameplayCamCoords())
  16. SetTextScale(scale, scale)
  17. SetTextFont(4)
  18. SetTextProportional(1)
  19. SetTextEntry("STRING")
  20. SetTextCentre(1)
  21. SetTextColour(255, 255, 255, 255)
  22. SetTextOutline()
  23. AddTextComponentString(text)
  24. DrawText(_x, _y)
  25. local factor = (string.len(text)) / 270
  26. DrawRect(_x, _y + 0.015, 0.005 + factor, 0.03, 31, 31, 31, 155)
  27. end
  28.  
  29. Citizen.CreateThread(function()
  30. while true do
  31. Citizen.Wait(6)
  32. if showPro == true then
  33. local playerPed = PlayerPedId()
  34. local coords = GetEntityCoords(playerPed)
  35. DrawText3D(coords.x, coords.y, coords.z, TimeLeft .. '~g~%', 0.4)
  36. end
  37. end
  38. end)
  39.  
  40. RegisterNetEvent('base:onUse')
  41. AddEventHandler('base:onUse', function()
  42. local playerPed = GetPlayerPed(-1)
  43. local coords = GetEntityCoords(playerPed)
  44. if IsAnyVehicleNearPoint(coords.x, coords.y, coords.z, 5.0) then
  45. local vehicle = nil
  46.  
  47. if IsPedInAnyVehicle(playerPed, false) then
  48. vehicle = GetVehiclePedIsIn(playerPed, false)
  49. else
  50. vehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 5.0, 0, 71)
  51. end
  52.  
  53. if DoesEntityExist(vehicle) then
  54. lockpicking = false
  55. ---print(lockpicking)
  56. randi = math.random(1, 10)
  57. if randi < 5 then
  58. RequestAnimDict("missheistfbisetup1")
  59. while (not HasAnimDictLoaded("missheistfbisetup1")) do
  60. Citizen.Wait(0)
  61. end
  62. FreezeEntityPosition(GetPlayerPed(-1), true)
  63. TaskPlayAnim(GetPlayerPed(-1), "missheistfbisetup1" ,"hassle_intro_loop_f" ,8.0, -8.0, -1, 1, 0, false, false, false )
  64. Wait(5000)
  65. procent(100, 69)
  66. TriggerServerEvent('base:removeKit')
  67. ESX.ShowNotification('Lockpick failed')
  68. ClearPedTasksImmediately(playerPed)
  69. FreezeEntityPosition(GetPlayerPed(-1), false)
  70. end
  71. if randi > 5 then
  72. RequestAnimDict("missheistfbisetup1")
  73. while (not HasAnimDictLoaded("missheistfbisetup1")) do
  74. Citizen.Wait(0)
  75. end
  76. FreezeEntityPosition(GetPlayerPed(-1), true)
  77. TaskPlayAnim(GetPlayerPed(-1), "missheistfbisetup1" ,"hassle_intro_loop_f" ,8.0, -8.0, -1, 1, 0, false, false, false )
  78. if useInteractSound then
  79. TriggerServerEvent('InteractSound_SV:PlayWithinDistance', 3.0, 'lockpick', 0.7)
  80. end
  81.  
  82. Citizen.CreateThread(function()
  83. ThreadID = GetIdOfThisThread()
  84. CurrentAction = 'lockpick'
  85.  
  86. Citizen.Wait(22 * 1000)
  87.  
  88. if CurrentAction ~= nil then
  89. procent(100, 100)
  90. SetVehicleDoorsLocked(vehicle, 1)
  91. SetVehicleDoorsLockedForAllPlayers(vehicle, false)
  92. ClearPedTasksImmediately(playerPed)
  93. FreezeEntityPosition(GetPlayerPed(-1), false)
  94.  
  95. ESX.ShowNotification('You have unlocked the car')
  96. end
  97.  
  98.  
  99. CurrentAction = nil
  100. --TerminateThisThread()
  101. end)
  102. end
  103. end
  104.  
  105. Citizen.CreateThread(function()
  106. Citizen.Wait(0)
  107.  
  108. if CurrentAction ~= nil then
  109. SetTextComponentFormat('STRING')
  110. AddTextComponentString("~g~[X]~w~ To abort lockpicking")
  111. DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  112.  
  113. if IsControlJustReleased(0, Keys["X"]) then
  114. TerminateThread(ThreadID)
  115. ESX.ShowNotification("You have aborted the lockpicking")
  116. CurrentAction = nil
  117. end
  118. end
  119.  
  120. end)
  121. end
  122. end)
  123.  
  124. RegisterNetEvent('base:Lockpick')
  125. AddEventHandler('base:Lockpick', function(xPlayer)
  126. lockpicking = true
  127. Citizen.Wait(100)
  128. lockpicking = false
  129. end)
  130.  
  131. -- Server Side
  132. ESX.RegisterUsableItem('lockpick', function(source)
  133. local _source = source
  134. local xPlayer = ESX.GetPlayerFromId(_source)
  135. TriggerClientEvent('base:Lockpick', _source)
  136. TriggerClientEvent('base:onUse', _source)
  137. end)
  138.  
  139. RegisterNetEvent('base:removeKit')
  140. AddEventHandler('base:removeKit', function()
  141. local _source = source
  142. local xPlayer = ESX.GetPlayerFromId(_source)
  143. xPlayer.removeInventoryItem('lockpick', 1)
  144. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement