Advertisement
Guest User

Untitled

a guest
Sep 7th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.76 KB | None | 0 0
  1. ESX = nil
  2. local PlayerData = {}
  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. key_to_teleport = 38
  22.  
  23. positions = {
  24. --[[
  25. {{Teleport1 X, Teleport1 Y, Teleport1 Z, Teleport1 Heading}, {Teleport2 X, Teleport 2Y, Teleport 2Z, Teleport2 Heading}, {Red, Green, Blue}, "Text for Teleport"}
  26. ]]
  27. {{-1507.59, -3017.18, -79.24-0.95, 266.11}, {456.8, -986.36, 26.67-0.95, 147.27},{0, 0, 95}, "Garaget"},
  28. {{-1518.6, -2978.41, -80.85-0.95, 266.11}, {463.23, -1019.46, 27.84-0.95, 92.27},{0, 0, 95}, "Garaget"},
  29. }
  30.  
  31. -----------------------------------------------------------------------------
  32. -------------------------DO NOT EDIT BELOW THIS LINE-------------------------
  33. -----------------------------------------------------------------------------
  34.  
  35. local player = GetPlayerPed(-1)
  36.  
  37. Citizen.CreateThread(function ()
  38. while true do
  39. Citizen.Wait(5)
  40. local player = GetPlayerPed(-1)
  41. local playerLoc = GetEntityCoords(player)
  42. local KeyAmmount = 0
  43. local inventory = ESX.GetPlayerData()["inventory"]
  44. local message = "En person har fΓΆrsΓΆkt ta sig in i erat garage!"
  45.  
  46. for i=1, #inventory, 1 do
  47. if inventory[i].name == 'policecard' then
  48. KeyAmmount = inventory[i].count
  49. end
  50. end
  51.  
  52. for _,location in ipairs(positions) do
  53. teleport_text = location[4]
  54. loc1 = {
  55. x=location[1][1],
  56. y=location[1][2],
  57. z=location[1][3],
  58. heading=location[1][4]
  59. }
  60. loc2 = {
  61. x=location[2][1],
  62. y=location[2][2],
  63. z=location[2][3],
  64. heading=location[2][4]
  65. }
  66. Red = location[3][1]
  67. Green = location[3][2]
  68. Blue = location[3][3]
  69.  
  70. DrawMarker(27, loc1.x, loc1.y, loc1.z, 0, 0, 0, 0, 0, 0, 1.501, 1.5001, 0.5001, Red, Green, Blue, 200, 0, 0, 0, 0)
  71. DrawMarker(27, loc2.x, loc2.y, loc2.z, 0, 0, 0, 0, 0, 0, 1.501, 1.5001, 0.5001, Red, Green, Blue, 200, 0, 0, 0, 0)
  72.  
  73. if CheckPos(playerLoc.x, playerLoc.y, playerLoc.z, loc1.x, loc1.y, loc1.z, 2) then
  74. alert(teleport_text)
  75.  
  76. if IsControlJustReleased(1, key_to_teleport) then
  77. if IsPedInAnyVehicle(player, true) then
  78. SetEntityCoords(GetVehiclePedIsUsing(player), loc2.x, loc2.y, loc2.z)
  79. SetEntityHeading(GetVehiclePedIsUsing(player), loc2.heading)
  80. else
  81. SetEntityCoords(player, loc2.x, loc2.y, loc2.z)
  82. SetEntityHeading(player, loc2.heading)
  83. end
  84. end
  85.  
  86. elseif CheckPos(playerLoc.x, playerLoc.y, playerLoc.z, loc2.x, loc2.y, loc2.z, 2) then
  87. alert(teleport_text)
  88.  
  89. if IsControlJustReleased(1, key_to_teleport) then
  90. if KeyAmmount > 0 then
  91. if IsPedInAnyVehicle(player, true) then
  92. SetEntityCoords(GetVehiclePedIsUsing(player), loc1.x, loc1.y, loc1.z)
  93. SetEntityHeading(GetVehiclePedIsUsing(player), loc1.heading)
  94. else
  95. SetEntityCoords(player, loc1.x, loc1.y, loc1.z)
  96. SetEntityHeading(player, loc1.heading)
  97. end
  98. else
  99. sendNotification('Du har ingen polisnyckel! Kriminella svin.', 'error', 1700)
  100. TriggerServerEvent('esx_phone:send', 'police', message, true, false)
  101.  
  102. end
  103. end
  104. end
  105. end
  106. end
  107. end)
  108.  
  109. function CheckPos(x, y, z, cx, cy, cz, radius)
  110. local t1 = x - cx
  111. local t12 = t1^2
  112.  
  113. local t2 = y-cy
  114. local t21 = t2^2
  115.  
  116. local t3 = z - cz
  117. local t31 = t3^2
  118.  
  119. return (t12 + t21 + t31) <= radius^2
  120. end
  121.  
  122. function alert(msg)
  123. SetTextComponentFormat("STRING")
  124. AddTextComponentString(msg)
  125. DisplayHelpTextFromStringLabel(0,0,1,-1)
  126. end
  127.  
  128. function sendNotification(message, messageType, messageTimeout)
  129. TriggerEvent("pNotify:SendNotification", {
  130. text = message,
  131. type = messageType,
  132. queue = "chris",
  133. timeout = messageTimeout,
  134. layout = "bottomCenter"
  135. })
  136. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement