Advertisement
Guest User

Untitled

a guest
Oct 26th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.64 KB | None | 0 0
  1. --------------------------------------------------------------------------------------------------------------
  2. ------------First off, many thanks to @anders for help with the majority of this script. ---------------------
  3. ------------Also shout out to @setro for helping understand pNotify better. ---------------------
  4. --------------------------------------------------------------------------------------------------------------
  5. ------------To configure: Add/replace your own coords in the sectiong directly below. ---------------------
  6. ------------ Goto LINE 90 and change "50" to your desired SafeZone Radius. ---------------------
  7. ------------ Goto LINE 130 to edit the Marker( Holographic circle.) ---------------------
  8. --------------------------------------------------------------------------------------------------------------
  9. -- Place your own coords here!
  10. local zones = {
  11. { ['x'] = 225.18, ['y'] = -885.86, ['z'] = 30.5}
  12. }
  13.  
  14. local notifIn = false
  15. local notifOut = false
  16. local closestZone = 1
  17.  
  18.  
  19. --------------------------------------------------------------------------------------------------------------
  20. --------------------------------------------------------------------------------------------------------------
  21. ------- Creating Blips at the locations. --------------
  22. -------You can comment out this section if you dont want any blips showing the zones on the map.--------------
  23. --------------------------------------------------------------------------------------------------------------
  24. --------------------------------------------------------------------------------------------------------------
  25.  
  26. Citizen.CreateThread(function()
  27. while not NetworkIsPlayerActive(PlayerId()) do
  28. Citizen.Wait(0)
  29. end
  30.  
  31. for i = 1, #zones, 1 do
  32. local szBlip = AddBlipForCoord(zones[i].x, zones[i].y, zones[i].z)
  33. SetBlipAsShortRange(szBlip, true)
  34. SetBlipColour(szBlip, 2) --Change the blip color: https://gtaforums.com/topic/864881-all-blip-color-ids-pictured/
  35. SetBlipSprite(szBlip, 398) -- Change the blip itself: https://marekkraus.sk/gtav/blips/list.html
  36. BeginTextCommandSetBlipName("STRING")
  37. AddTextComponentString("SAFE ZONE") -- What it will say when you hover over the blip on your map.
  38. EndTextCommandSetBlipName(szBlip)
  39. end
  40. end)
  41.  
  42. --------------------------------------------------------------------------------------------------------------
  43. --------------------------------------------------------------------------------------------------------------
  44. ---------------- Getting your distance from any one of the locations --------------------------------------
  45. --------------------------------------------------------------------------------------------------------------
  46. --------------------------------------------------------------------------------------------------------------
  47.  
  48. Citizen.CreateThread(function()
  49. while not NetworkIsPlayerActive(PlayerId()) do
  50. Citizen.Wait(0)
  51. end
  52.  
  53. while true do
  54. local playerPed = GetPlayerPed(-1)
  55. local x, y, z = table.unpack(GetEntityCoords(playerPed, true))
  56. local minDistance = 100000
  57. for i = 1, #zones, 1 do
  58. dist = Vdist(zones[i].x, zones[i].y, zones[i].z, x, y, z)
  59. if dist < minDistance then
  60. minDistance = dist
  61. closestZone = i
  62. end
  63. end
  64. Citizen.Wait(15000)
  65. end
  66. end)
  67.  
  68. --------------------------------------------------------------------------------------------------------------
  69. --------------------------------------------------------------------------------------------------------------
  70. --------- Setting of friendly fire on and off, disabling your weapons, and sending pNoty -----------------
  71. --------------------------------------------------------------------------------------------------------------
  72. --------------------------------------------------------------------------------------------------------------
  73.  
  74. Citizen.CreateThread(function()
  75. while not NetworkIsPlayerActive(PlayerId()) do
  76. Citizen.Wait(0)
  77. end
  78.  
  79. while true do
  80. Citizen.Wait(0)
  81. local player = GetPlayerPed(-1)
  82. local x,y,z = table.unpack(GetEntityCoords(player, true))
  83. local dist = Vdist(zones[closestZone].x, zones[closestZone].y, zones[closestZone].z, x, y, z)
  84.  
  85. if dist <= 25.0 then --------------------------------------- Here you can change the RADIUS of the Safe Zone. Remember, whatever you put here will DOUBLE because
  86. DisableControlAction(0, 140, true) -- it is a sphere. So 50 will actually result in a diameter of 100. I assume it is meters. No clue to be honest.
  87. DisableControlAction(0, 141, true)
  88. DisableControlAction(0, 142, true)
  89. if not notifIn then
  90. NetworkSetFriendlyFireOption(false)
  91. ClearPlayerWantedLevel(PlayerId())
  92. SetCurrentPedWeapon(player,GetHashKey("WEAPON_UNARMED"),true)
  93. TriggerEvent("pNotify:SendNotification",{
  94. text = "<b style='color:#1E90FF'>You are in a SafeZone</b>",
  95. type = "success",
  96. timeout = (3000),
  97. layout = "bottomcenter",
  98. queue = "global"
  99. })
  100. notifIn = true
  101. notifOut = false
  102. end
  103. else
  104. if not notifOut then
  105. NetworkSetFriendlyFireOption(true)
  106. TriggerEvent("pNotify:SendNotification",{
  107. text = "<b style='color:#1E90FF'>You are in NO LONGER a SafeZone</b>",
  108. type = "error",
  109. timeout = (3000),
  110. layout = "bottomcenter",
  111. queue = "global"
  112. })
  113. notifOut = true
  114. notifIn = false
  115. end
  116. end
  117. if notifIn then
  118. DisableControlAction(2, 37, true) -- disable weapon wheel (Tab)
  119. DisablePlayerFiring(player,true) -- Disables firing all together if they somehow bypass inzone Mouse Disable
  120. DisableControlAction(0, 106, true) -- Disable in-game mouse controls
  121. if IsDisabledControlJustPressed(2, 37) then --if Tab is pressed, send error message
  122. SetCurrentPedWeapon(player,GetHashKey("WEAPON_UNARMED"),true) -- if tab is pressed it will set them to unarmed (this is to cover the vehicle glitch until I sort that all out)
  123. TriggerEvent("pNotify:SendNotification",{
  124. text = "<b style='color:#1E90FF'>You can not use weapons in a Safe Zone</b>",
  125. type = "error",
  126. timeout = (3000),
  127. layout = "bottomcenter",
  128. queue = "global"
  129. })
  130. end
  131. if IsDisabledControlJustPressed(0, 106) then --if LeftClick is pressed, send error message
  132. SetCurrentPedWeapon(player,GetHashKey("WEAPON_UNARMED"),true) -- If they click it will set them to unarmed
  133. TriggerEvent("pNotify:SendNotification",{
  134. text = "<b style='color:#1E90FF'>You can not do that in a Safe Zone</b>",
  135. type = "error",
  136. timeout = (3000),
  137. layout = "bottomcenter",
  138. queue = "global"
  139. })
  140. end
  141. end
  142.  
  143. end
  144. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement