TheHooker

Untitled

Jan 18th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.71 KB | None | 0 0
  1. local beginningMarker = {
  2.     {x = 2518.23706, y = -2270.74927, z = -0.55000},
  3.     {x = 2698.90576, y = -2310.06494, z = -0.55000},
  4.     {x = 2309.20703, y = -2417.13794, z = -0.55000},
  5.     {x = 2351.62012, y = -2522.45435, z = -0.55000},
  6.     {x = 2614.61987, y = -2479.15967, z = -0.55000},
  7.     {x = 2730.23950, y = -2587.99219, z = -0.55000}
  8. }
  9.  
  10.  
  11. local isMissionActive = false
  12. local timers = {}
  13.  
  14. function enableStartMissionOption(plr, seat)
  15.     if (plr ~= localPlayer) then
  16.         return false
  17.     end
  18.     if (getElementMode(source) ~= 430 or seat ~= 0) then
  19.         return false
  20.     end
  21.     if (getElementData(plr, "o") ~= "Police Officer") then
  22.         return false
  23.     end
  24.     exports.CIThelp:modTextBar("boatMission", "Press N to start the Predator Mission.")
  25.     bindKey(plr, "N", "down", startBoatMission)
  26. end
  27.  
  28. function startBoatMission()
  29.     local veh = getPedOccupiedVehicle(localPlayer)
  30.     local seat = getPedOccupiedVehicleSeat(localPlayer)
  31.     if (not veh or seat ~= 0) then
  32.         return false
  33.     end
  34.     if (isMissionActive) then
  35.         return false
  36.     end
  37.     unbindKey("N", "down", startBoatMission)
  38.     isMissionActive = true
  39.     local pos = beginningMarker[math.random(1,#beginningMarker)]
  40.     firstMarker = createMarker(pos.x, pos.y, pos.z, "cylinder", 6, 0, 0, 210)
  41.     firstBlip = createBlip(pos.x, pos.y, pos.z, 43)
  42.     addEventHandler("onClientMarkerHit", firstMarker, missionStarting)
  43.     timers["distanceCheck"] = setTimer(checkDistance ,1000, 0, veh)  
  44.  
  45.     addEventHandler("onClientPlayerWasted", localPlayer, failMission)
  46.     addEventHandler("onClientPlayerResign", localPlayer, failMission)
  47.     addEventHandler("onClientElementDestroy", veh, failMission)
  48. end
  49.  
  50. function checkDistance(veh)
  51.     if (not veh or not isElement(veh)) then
  52.         failMission()
  53.         return false
  54.     end
  55.     local px, py, pz = getElementPosition(localPlayer)
  56.     local vx, vy, vz = getElementPosition(veh)
  57.     if (getDistanceBetweenPoints2D(px, py, vx, vy) > 100) then
  58.         failMission("dist")
  59.         return true
  60.     end
  61. end
  62. addEventHandler("onClientVehicleEnter", root, enableStartMissionOption)
  63.  
  64. function missionStarting()
  65.     local veh = getPedOccupiedVehicle(localPlayer)
  66.     setElementSpeed(veh, 1, 0)
  67.     outputChatBox("Some drug smugglers are escaping with tons of drugs, stop them before they escape!", 0, 0, 110)
  68.     destroyElement(firstMarker)
  69.     destroyElement(firstBlip)
  70.     firstMarker = nil
  71.     firstBlip = nil
  72.     firstBoat = createVehicle(446, x, y, z)
  73.     firstBoatPed1 = exports.CITpeds:newPed(15, 0, 0, 0)
  74.     firstBoatPed2 = exports.CITpeds:newPed(22, x, y, z)
  75.     exports.CITpeds:pedOptions(firstBoatPed2, 5, 31)
  76.     attachElements(firstBoatPed2, firstBoat)
  77.     warpPedIntoVehicle(firstBoatPed1, firstBoat)
  78.     setPedControlState(firstBoatPed1, "accelerate", true)
  79.     tick1 = getTickCount()
  80.     if (getElementHealth(firstBoat) <= 0 and getElementHealth(firstBoatPed2) <= 0) then
  81.         removePedFromVehicle(firstBoatPed1)
  82.         setElementPosition(firstBoatPed1, x, y, z)
  83.         exports.CITpeds:pedOptions(firstBoatPed1, 5, 31)
  84.     else
  85.         return false
  86.     end
  87.     if (getElementHealth(firstBoatPed1) <= 0) then
  88.         drugCrate1 = createMarker(x, y, z, "cylinder", 1, 0, 0, 255)
  89.         outputChatBox("You killed the drug smugglers, remove the drugs from the crate", 0, 255, 0)
  90.     end
  91.     addEventHandler("onClientMarkerHit", drugCrate1, workFirstDrugCrate)
  92. end
  93.  
  94. function workFirstDrugCrate()
  95.     destroyElement(drugCrate1)
  96.     drugCrate1 = nil
  97.     outputChatBox("You have got the drugs, but there are still more drug smugglers, stop them!", 0, 0, 160)
  98. end
  99.  
  100. function turnFirstBoat()
  101.     if (getTickCount - tick1 >= 6000) then
  102.         setPedControlState(firstBoatPed1, "vehicle_left", true)
  103.         tick2 = getTickCount()
  104.     end
  105. end
Add Comment
Please, Sign In to add comment