Advertisement
Guest User

handcuff

a guest
Jan 18th, 2018
1,450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. function GetPlayers()
  2. local players = {}
  3.  
  4. for i = 0, 31 do
  5. if NetworkIsPlayerActive(i) then
  6. table.insert(players, i)
  7. end
  8. end
  9.  
  10. return players
  11. end
  12.  
  13. unction GetClosestPlayer()
  14. local players = GetPlayers()
  15. local closestDistance = -1
  16. local closestPlayer = -1
  17. local ply = GetPlayerPed(-1)
  18. local plyCoords = GetEntityCoords(ply, 0)
  19.  
  20. for index,value in ipairs(players) do
  21. local target = GetPlayerPed(value)
  22. if(target ~= ply) then
  23. local targetCoords = GetEntityCoords(GetPlayerPed(value), 0)
  24. local distance = Vdist(targetCoords["x"], targetCoords["y"], targetCoords["z"], plyCoords["x"], plyCoords["y"], plyCoords["z"])
  25. if(closestDistance == -1 or closestDistance > distance) then
  26. closestPlayer = value
  27. closestDistance = distance
  28. end
  29. end
  30. end
  31. return closestPlayer, closestDistance
  32. end
  33.  
  34. –HandCuff start
  35.  
  36. local handcuffconfig = {
  37. model = “prop_cs_cuffs_01”,
  38. handcuffs = nil
  39. }
  40.  
  41. –[[ HANDCUFF SCRIPT ]]–
  42. RegisterNetEvent(“Handcuff”)
  43. AddEventHandler(“Handcuff”, function()
  44. local lPed = GetPlayerPed(-1)
  45. if DoesEntityExist(lPed) then
  46. if IsEntityPlayingAnim(lPed, “mp_arresting”, “idle”, 3) then
  47. –DetachEntity(handcuffconfig.handcuffs, 0, 0)
  48. –DeleteEntity(handcuffconfig.handcuffs)
  49. –handcuffconfig.handcuffs = nil
  50. ClearPedSecondaryTask(lPed)
  51. SetEnableHandcuffs(lPed, false)
  52. SetCurrentPedWeapon(lPed, GetHashKey(“WEAPON_UNARMED”), true)
  53. else
  54. RequestAnimDict(“mp_arresting”)
  55. while not HasAnimDictLoaded(“mp_arresting”) do
  56. Citizen.Wait(100)
  57. end
  58.  
  59. --RequestModel(GetHashKey(handcuffconfig.model))
  60. --while not HasModelLoaded(GetHashKey(handcuffconfig.model)) do
  61. --Citizen.Wait(100)
  62. --end
  63.  
  64. --local plyCoords = GetEntityCoords(GetPlayerPed(PlayerId()), false)
  65. --handcuffconfig.handcuffs = CreateObject(GetHashKey(handcuffconfig.model), plyCoords.x, plyCoords.y, plyCoords.z, 1, 1, 1)
  66.  
  67. --AttachEntityToEntity(handcuffconfig.handcuffs, GetPlayerPed(PlayerId()), GetPedBoneIndex(GetPlayerPed(PlayerId()), 60309), 0.0, 0.05, 0.0, 0.0, 0.0, 80.0, 1, 0, 0, 0, 0, 1)
  68.  
  69. TaskPlayAnim(lPed, "mp_arresting", "idle", 8.0, -8, -1, 49, 0, 0, 0, 0)
  70. SetEnableHandcuffs(lPed, true)
  71. SetCurrentPedWeapon(lPed, GetHashKey("WEAPON_UNARMED"), true)
  72. end
  73. end
  74. end)
  75.  
  76. –Handcuff end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement