Advertisement
Filexdoj

server.lua

Mar 27th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.33 KB | None | 0 0
  1. local startMarkersPositions = {
  2.     LosSantos = Vector3(1591.5, -2283.6, -2.25),
  3.     BoneCountry = Vector3(423.8, 2536.5, 15.2),
  4.     SanFierro = Vector3(-1422.5, -286.6, 13.2),
  5.     LasVenturas = Vector3(1673.6, 1447.8, 9.8)
  6. }
  7. local planes = {}
  8. local startMarkers = {}
  9. local startMarkersBlips = {}
  10. local planeStartPositions = {
  11.     LosSantos = {
  12.         Andromada = {
  13.             xyz = Vector3(2017.7998, -2493.7998, 13.8),
  14.             rotation = Vector3(0, 0, 90)
  15.         },
  16.         AT400 = {
  17.             xyz = Vector3(2017.7998, -2493.7998, 13.8),
  18.             rotation = Vector3(0, 0, 90)
  19.         },
  20.         Shamal = {
  21.             xyz = Vector3(2017.7998, -2493.7998, 15),
  22.             rotation = Vector3(0, 0, 90)
  23.         },
  24.         Dodo = {
  25.             xyz = Vector3(2017.7998, -2493.7998, 15),
  26.             rotation = Vector3(0, 0, 90)
  27.         }
  28.     },
  29.     BoneCountry = {
  30.         Andromada = {
  31.             xyz = Vector3(414.62067, 2502.25415, 17),
  32.             rotation = Vector3(0, 0, 90)
  33.         },
  34.         Shamal = {
  35.             xyz = Vector3(414.62067, 2502.25415, 17),
  36.             rotation = Vector3(0, 0, 90)
  37.         },
  38.         Dodo = {
  39.             xyz = Vector3(414.62067, 2502.25415, 17),
  40.             rotation = Vector3(0, 0, 90)
  41.         }
  42.     },
  43.     LasVenturas = {
  44.         Andromada = {
  45.             xyz = Vector3(1423.1381, 1261.9676, 11.7),
  46.             rotation = Vector3(359, 359, 266)
  47.         },
  48.         AT400 = {
  49.             xyz = Vector3(1423.1381, 1261.9676, 11.7),
  50.             rotation = Vector3(359, 359, 266)
  51.         },
  52.         Shamal = {
  53.             xyz = Vector3(1423.1381, 1261.9676, 11.7),
  54.             rotation = Vector3(359, 359, 266)
  55.         },
  56.         Dodo = {
  57.             xyz = Vector3(1423.1381, 1261.9676, 11.7),
  58.             rotation = Vector3(359, 359, 266)
  59.         }
  60.     },
  61.     SanFierro = {}
  62. }
  63. for location, vector in pairs(startMarkersPositions) do
  64.     startMarkers[location] = Marker(vector, "cylinder", 1.3, 255, 255, 0, 200)
  65.     startMarkersBlips[location] = Blip.createAttachedTo(startMarkers[location], 5, 1)
  66. end
  67.  
  68. function onStartMarkerHit(hitMarker)
  69.     for location, marker in pairs(startMarkers) do
  70.         if marker == hitMarker then
  71.             triggerClientEvent("create:pilotTab", source, location)
  72.         end
  73.     end
  74. end
  75. addEventHandler("onPlayerMarkerHit", getRootElement(), onStartMarkerHit)
  76.  
  77. function createFlightPlane(startLocation, model)
  78.     local modelID = Vehicle.getModelFromName(model)
  79.     local position = planeStartPositions[startLocation][model]["xyz"]
  80.     local rotation = planeStartPositions[startLocation][model]["rotation"]
  81.     local plane = Vehicle(modelID, position, rotation)
  82.     planes[source:getName()] = plane
  83.     source:warpIntoVehicle(plane)
  84.     addEventHandler("onVehicleExit", plane, onPlayerLeaveOrDead)
  85.     addEventHandler("onPlayerWasted", source, onPlayerLeaveOrDead)
  86.     addEventHandler("give:salary", source, giveSalary)
  87. end
  88. addEvent("make:plane", true)
  89. addEventHandler("make:plane", getRootElement(), createFlightPlane)
  90.  
  91. function onPlayerLeaveOrDead(player)
  92.     if not isElement(player) then
  93.         player = source
  94.         local handler = getEventHandlers("onPlayerWasted", source)
  95.         removeEventHandler("onPlayerWasted", player, handler[1])
  96.         removeEventHandler("onVehicleExit", planes[player:getName()], handler[1])
  97.         removeEventHandler("give:salary", player, giveSalary)
  98.     else
  99.         local handler = getEventHandlers("onVehicleExit", source)
  100.         removeEventHandler("onVehicleExit", source, handler[1])
  101.         removeEventHandler("onPlayerWasted", player, handler[1])
  102.         removeEventHandler("give:salary", player, giveSalary)
  103.     end
  104.     planes[player:getName()]:destroy()
  105.     planes[player:getName()] = nil
  106.     triggerClientEvent("stop:flight", player)
  107.     outputChatBox("You have abondand the flight", player, 255, 0, 0)
  108. end
  109.  
  110. function giveSalary(income)
  111.     player = source
  112.     local handler = getEventHandlers("give:salary", player)
  113.     removeEventHandler("give:salary", player, handler[1])
  114.     removeEventHandler("onPlayerWasted", player,onPlayerLeaveOrDead)
  115.     removeEventHandler("onVehicleExit", planes[player:getName()], onPlayerLeaveOrDead)
  116.     player:giveMoney(tonumber(income))
  117.     planes[player:getName()]:destroy()
  118.     planes[player:getName()] = nil
  119. end
  120. addEvent("give:salary", true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement