Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. local PlayerData = {}
  2. ESX = nil
  3.  
  4. Citizen.CreateThread(function()
  5. while ESX == nil do
  6. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  7. Citizen.Wait(0)
  8. end
  9. end)
  10.  
  11. RegisterNetEvent('esx:playerLoaded')
  12. AddEventHandler('esx:playerLoaded', function(xPlayer)
  13. PlayerData = xPlayer
  14. end)
  15.  
  16. RegisterNetEvent('esx:setJob')
  17. AddEventHandler('esx:setJob', function(job)
  18. PlayerData.job = job
  19. end)
  20.  
  21. --- Ne Pas Editer!!!
  22. local holstered = true
  23.  
  24. -- ANIMATIONS DE LA RADIO --
  25.  
  26.  
  27. Citizen.CreateThread(function()
  28. while true do
  29. Wait( 0 )
  30.  
  31. local _source = source
  32. local ped = PlayerPedId()
  33. if PlayerData.job ~= nil and PlayerData.job.name == 'ambulance' and not IsEntityDead( ped ) then
  34. -- if DoesEntityExist( ped ) and not IsEntityDead( ped ) and CheckSkin(ped) then
  35. if not IsPauseMenuActive() then
  36. loadAnimDict( "random@arrests" )
  37. if IsControlJustReleased( 0, 246 ) then -- INPUT_CHARACTER_WHEEL (LEFT ALT)
  38. TriggerServerEvent("InteractSound_SV:PlayWithinDistance", 10, "off", 0.1)
  39. ClearPedTasks(ped)
  40. SetEnableHandcuffs(ped, false)
  41. else
  42. if IsControlJustPressed( 0, 246 ) and not IsPlayerFreeAiming(PlayerId()) then -- INPUT_CHARACTER_WHEEL (LEFT ALT)
  43. TriggerServerEvent("InteractSound_SV:PlayWithinDistance", 10, "on", 0.1)
  44. TaskPlayAnim(ped, "random@arrests", "generic_radio_enter", 8.0, 2.0, -1, 50, 2.0, 0, 0, 0 )
  45. SetEnableHandcuffs(ped, true)
  46. elseif IsControlJustPressed( 0, 246 ) and IsPlayerFreeAiming(PlayerId()) then -- INPUT_CHARACTER_WHEEL (LEFT ALT)
  47. TriggerServerEvent("InteractSound_SV:PlayWithinDistance", 10, "on", 0.1)
  48. TaskPlayAnim(ped, "random@arrests", "radio_chatter", 8.0, 2.0, -1, 50, 2.0, 0, 0, 0 )
  49. SetEnableHandcuffs(ped, true)
  50. end
  51. if IsEntityPlayingAnim(GetPlayerPed(PlayerId()), "random@arrests", "generic_radio_enter", 3) then
  52. DisableActions(ped)
  53. elseif IsEntityPlayingAnim(GetPlayerPed(PlayerId()), "random@arrests", "radio_chatter", 3) then
  54. DisableActions(ped)
  55. end
  56. end
  57. end
  58. end
  59. end
  60. end )
  61.  
  62. -- DO NOT REMOVE THESE! --
  63.  
  64. function CheckSkin(ped)
  65. for i = 1, #skins do
  66. if GetHashKey(skins[i]) == GetEntityModel(ped) then
  67. return true
  68. end
  69. end
  70. return false
  71. end
  72.  
  73. function CheckWeapon(ped)
  74. for i = 1, #weapons do
  75. if GetHashKey(weapons[i]) == GetSelectedPedWeapon(ped) then
  76. return true
  77. end
  78. end
  79. return false
  80. end
  81.  
  82. function DisableActions(ped)
  83. DisableControlAction(1, 140, true)
  84. DisableControlAction(1, 141, true)
  85. DisableControlAction(1, 142, true)
  86. DisableControlAction(1, 37, true) -- Disables INPUT_SELECT_WEAPON (TAB)
  87. DisablePlayerFiring(ped, true) -- Disable weapon firing
  88. end
  89.  
  90. function loadAnimDict( dict )
  91. while ( not HasAnimDictLoaded( dict ) ) do
  92. RequestAnimDict( dict )
  93. Citizen.Wait( 0 )
  94. end
  95. end
  96.  
  97. RegisterNetEvent('InteractSound_CL:PlayWithinDistance')
  98. AddEventHandler('InteractSound_CL:PlayWithinDistance', function(playerNetId, maxDistance, soundFile, soundVolume)
  99. local lCoords = GetEntityCoords(localVehId, false)
  100. local eCoords = GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(playerNetId)))
  101. local distIs = Vdist(lCoords.x, lCoords.y, lCoords.z, eCoords.x, eCoords.y, eCoords.z)
  102. local farSound
  103. if(distIs < maxDistance) then
  104. SendNUIMessage({
  105. transactionType = 'playSound',
  106. transactionFile = soundFile,
  107. transactionVolume = soundVolume
  108. })
  109. elseif distIs >= maxDistance and distIs < 15.0 then
  110. SendNUIMessage({
  111. transactionType = 'playSound',
  112. transactionFile = soundFile,
  113. transactionVolume = 0.15
  114. })
  115. elseif distIs >= 15.0 and distIs < 30.0 then
  116. SendNUIMessage({
  117. transactionType = 'playSound',
  118. transactionFile = soundFile,
  119. transactionVolume = 0.10
  120. })
  121. elseif distIs >= 30.0 and distIs < 50.0 then
  122. SendNUIMessage({
  123. transactionType = 'playSound',
  124. transactionFile = soundFile,
  125. transactionVolume = 0.05
  126. })
  127. end
  128. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement