Filexdoj

pilotServer.lua

Mar 23rd, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.22 KB | None | 0 0
  1. local startMarkerPositions = {}
  2. local startMarkers = {}
  3. local startMarkersBlips = {}
  4. local onVehicleLeaveOrWasted
  5.  
  6. startMarkerPositions["LosSantos"] = Vector3(1591.5, -2283.6, -2.25)
  7. startMarkerPositions["BoneCountry"] = Vector3(423.8, 2536.5, 15.2)
  8. startMarkerPositions["LasVenturas"] = Vector3(1673.6, 1447.8, 9.8)
  9. startMarkerPositions["SanFierro"] = Vector3(-1422.5, -286.6, 13.2)
  10.  
  11. for k, vector in pairs(startMarkerPositions) do
  12.     startMarkers[k] = Marker(vector, "cylinder", 1.3, 255, 255, 0, 200)
  13.     startMarkersBlips[k] = Blip.createAttachedTo(startMarkers[k], 5, 2, 255, 255, 0)
  14. end
  15.  
  16. local models = {
  17.     Andromada = 592,
  18.     AT400 = 577,
  19.     Shamal = 519,
  20.     Dodo = 593
  21. }
  22. local planePositions = {
  23.     LosSantos = {
  24.         Andromada = {x = 2017.7998, y = -2493.7998, z = 13.8, rx = 0, ry = 0, rz = 90},
  25.         AT400 = {x = 2017.7998, y = -2493.7998, z = 13.8, rx = 0, ry = 0, rz = 90},
  26.         Shamal = {x = 2017.7998, y = -2493.7998, z = 15, rx = 0, ry = 0, rz = 90},
  27.         Dodo = {x = 2017.7998, y = -2493.7998, z = 15, rx = 0, ry = 0, rz = 90}
  28.     },
  29.     BoneCountry = {
  30.         Andromada = {x = 414.62067, y = 2502.25415, z = 17, rx = 0, ry = 0, rz = 90},
  31.         Shamal = {x = 414.62067, y = 2502.25415, z = 17, rx = 0, ry = 0, rz = 90},
  32.         Dodo = {x = 414.62067, y = 2502.25415, z = 17, rx = 0, ry = 0, rz = 90}
  33.     },
  34.     LasVenturas = {
  35.         Andromada = {x = 1423.1381, y = 1261.9676, z = 11.7, rx = 359, ry = 359, rz = 266},
  36.         AT400 = {x = 1423.1381, y = 1261.9676, z = 11.7, rx = 359, ry = 359, rz = 266},
  37.         Shamal = {x = 1423.1381, y = 1261.9676, z = 11.7, rx = 359, ry = 359, rz = 266},
  38.         Dodo = {x = 1423.1381, y = 1261.9676, z = 11.7, rx = 359, ry = 359, rz = 266}
  39.     },
  40.     SanFierro = {}
  41. }
  42. function getDistance(vector1, vector2)
  43.     local distance = getDistanceBetweenPoints3D(vector1, vector2)
  44.     return distance
  45. end
  46. function createPanel(hitMarker)
  47.     for location, marker in pairs(startMarkers) do
  48.         if marker == hitMarker then
  49.             local distances = {}
  50.             for k, v in pairs(startMarkerPositions) do
  51.                 if k ~= location then
  52.                     distances[k] = getDistance(v, startMarkerPositions[location])
  53.                 end
  54.             end
  55.             triggerClientEvent("openPilotTab", source, location, distances)
  56.             distances = nil
  57.         end
  58.     end
  59. end
  60. addEventHandler("onPlayerMarkerHit", getRootElement(), createPanel)
  61.  
  62. function makeVehicle(player, model, location, arrivalLocation, income)
  63.     for _index, value in pairs(startMarkerPositions) do
  64.         startMarkers[_index]:setVisibleTo(player, false)
  65.         startMarkersBlips[_index]:setVisibleTo(player, false)
  66.     end
  67.     local position =
  68.         Vector3(
  69.         planePositions[location][model]["x"],
  70.         planePositions[location][model]["y"],
  71.         planePositions[location][model]["z"]
  72.     )
  73.     local rotation =
  74.         Vector3(
  75.         planePositions[location][model]["rx"],
  76.         planePositions[location][model]["ry"],
  77.         planePositions[location][model]["rz"]
  78.     )
  79.     local plane = Vehicle(models[model], position, rotation)
  80.     player:warpIntoVehicle(plane)
  81.     triggerClientEvent("start:job", player, arrivalLocation)
  82.  
  83.     function onVehicleLeaveOrWasted()
  84.         if plane then
  85.             plane:destroy()
  86.             triggerClientEvent("stop:mission", player)
  87.         end
  88.     end
  89.     addEventHandler("onVehicleExit", plane, onVehicleLeaveOrWasted)
  90.     addEventHandler("onPlayerWasted", player, onVehicleLeaveOrWasted)
  91.  
  92.     function givingsalary()
  93.         removeEventHandler("onVehicleExit", root, onVehicleLeaveOrWasted)
  94.         removeEventHandler("onPlayerWasted", root, onVehicleLeaveOrWasted)
  95.         plane:destroy()
  96.         outputChatBox("congratz")
  97.         player:giveMoney(tonumber(income))
  98.         player:setPosition(startMarkerPositions[arrivalLocation])
  99.     end
  100.     addEvent("getSalary", true)
  101.     addEventHandler("getSalary", player, givingsalary)
  102.  
  103.     addCommandHandler(
  104.         "takeme",
  105.         function()
  106.             setElementPosition(plane, 15.865191459656, 2504.4108886719, 16.951555252075)
  107.         end
  108.     )
  109. end
  110. addEvent("makePlane", true)
  111. addEventHandler("makePlane", getRootElement(), makeVehicle)
Advertisement
Add Comment
Please, Sign In to add comment