Advertisement
Filexdoj

pilot

Mar 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.83 KB | None | 0 0
  1. local screenW, screenH = guiGetScreenSize()
  2. -- gui elements coordinates
  3. local dimensions = {
  4.     window = {
  5.         floatX = (screenW - 474) / 2,
  6.         floatY = (screenH - 296) / 2,
  7.         width = 474,
  8.         height = 296
  9.     },
  10.     gridList = {
  11.         floatX = 13,
  12.         floatY = 28,
  13.         width = 451,
  14.         height = 212
  15.     },
  16.     closeButton = {
  17.         floatX = 14,
  18.         floatY = 250,
  19.         width = 183,
  20.         height = 32
  21.     },
  22.     startButton = {
  23.         floatX = 207,
  24.         floatY = 250,
  25.         width = 257,
  26.         height = 32
  27.     }
  28. }
  29. -- the grid list items
  30. local list = {
  31.     BC = {
  32.         {
  33.             "Bone Country",
  34.             "Andromada",
  35.             "10.000$ - 20.000$"
  36.         },
  37.         {
  38.             "Bone Country",
  39.             "AT-400",
  40.             "8.000$ - 16.000$"
  41.         },
  42.         {
  43.             "Bone Country",
  44.             "Shamal",
  45.             "6.000$ - 12.000$"
  46.         },
  47.         {
  48.             "Bone Country",
  49.             "Dodo",
  50.             "4.000$ - 8.000$"
  51.         }
  52.     },
  53.     LS = {
  54.         {
  55.             "Los Santos",
  56.             "Andromada",
  57.             "10.000$ - 20.000$"
  58.         },
  59.         {
  60.             "Los Santos",
  61.             "AT-400",
  62.             "8.000$ - 16.000$"
  63.         },
  64.         {
  65.             "Los Santos",
  66.             "Shamal",
  67.             "6.000$ - 12.000$"
  68.         },
  69.         {
  70.             "Los Santos",
  71.             "Dodo",
  72.             "4.000$ - 8.000$"
  73.         }
  74.     },
  75.     SF = {
  76.         {
  77.             "San Fierro",
  78.             "Andromada",
  79.             "10.000$ - 20.000$"
  80.         },
  81.         {
  82.             "San Fierro",
  83.             "AT-400",
  84.             "8.000$ - 16.000$"
  85.         },
  86.         {
  87.             "San Fierro",
  88.             "Shamal",
  89.             "6.000$ - 12.000$"
  90.         },
  91.         {
  92.             "San Fierro",
  93.             "Dodo",
  94.             "4.000$ - 8.000$"
  95.         }
  96.     },
  97.     LV = {
  98.         {
  99.             "Las Venturas",
  100.             "Andromada",
  101.             "10.000$ - 20.000$"
  102.         },
  103.         {
  104.             "Las Venturas",
  105.             "AT-400",
  106.             "8.000$ - 16.000$"
  107.         },
  108.         {
  109.             "Las Venturas",
  110.             "Shamal",
  111.             "6.000$ - 12.000$"
  112.         },
  113.         {
  114.             "Las Venturas",
  115.             "Dodo",
  116.             "4.000$ - 8.000$"
  117.         }
  118.     }
  119. }
  120. -- something to do later
  121. local arriveMarkers = {
  122.     BC = {},
  123.     LS = {},
  124.     SF = {},
  125.     LV = {}
  126. }
  127. -- main function
  128. function pilotTab(location)
  129.     showCursor(true)
  130.     local window =
  131.         GuiWindow(
  132.         dimensions.window["floatX"],
  133.         dimensions.window["floatY"],
  134.         dimensions.window["width"],
  135.         dimensions.window["height"],
  136.         "Los Santos Airport - Pilot Tab",
  137.         false
  138.     )
  139.     window:setSizable(false)
  140.     window:setMovable(false)
  141.  
  142.     local gridList =
  143.         GuiGridList(
  144.         dimensions.gridList["floatX"],
  145.         dimensions.gridList["floatY"],
  146.         dimensions.gridList["width"],
  147.         dimensions.gridList["height"],
  148.         false,
  149.         window
  150.     )
  151.     gridList:addColumn("Arrive Location", 0.3)
  152.     gridList:addColumn("Plane Model", 0.3)
  153.     gridList:addColumn("Income", 0.3)
  154.     local closeButton =
  155.         GuiButton(
  156.         dimensions.closeButton["floatX"],
  157.         dimensions.closeButton["floatY"],
  158.         dimensions.closeButton["width"],
  159.         dimensions.closeButton["height"],
  160.         "Close",
  161.         false,
  162.         window
  163.     )
  164.     local startButton =
  165.         GuiButton(
  166.         dimensions.startButton["floatX"],
  167.         dimensions.startButton["floatY"],
  168.         dimensions.startButton["width"],
  169.         dimensions.startButton["height"],
  170.         "Start",
  171.         false,
  172.         window
  173.     )
  174.     for k, v in pairs(list) do
  175.         if k ~= location then
  176.             for k2, v2 in ipairs(v) do
  177.                 gridList:addRow(v2[1], v2[2], v2[3])
  178.             end
  179.         end
  180.     end
  181.     function onCloseButtonClick()
  182.         window:destroy()
  183.         showCursor(false)
  184.     end
  185.     addEventHandler("onClientGUIClick", closeButton, onCloseButtonClick, false)
  186.  
  187.     function onStartButtonClick()
  188.         local selectedRow, selectedColumn = gridList:getSelectedItem()
  189.         if selectedRow ~= -1 and selectedColumn ~= -1 then
  190.             window:destroy()
  191.             showCursor(false)
  192.             local arrivalLocation = gridList:getItemText(selectedRow, selectedColumn)
  193.             local planeModel = gridList:getItemText( selectedRow, selectedColumn + 1)
  194.             local income = gridList:getItemText( selectedRow, selectedColumn + 2)
  195.             iprint(arrivalLocation, planeModel, income)
  196.         end
  197.     end
  198.     addEventHandler("onClientGUIClick", startButton, onStartButtonClick, false)
  199. end
  200. addEvent("openPilotTab", true)
  201. addEventHandler("openPilotTab", getRootElement(), pilotTab)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement