Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local list = {
- BoneCountry = {
- {
- arrivalLocation = "Bone Country",
- model = "Andromada",
- incomeLevel = 4
- },
- {
- arrivalLocation = "Bone Country",
- model = "Shamal",
- incomeLevel = 2
- },
- {
- arrivalLocation = "Bone Country",
- model = "Dodo",
- incomeLevel = 1.5
- }
- },
- LosSantos = {
- {
- arrivalLocation = "Los Santos",
- model = "Andromada",
- incomeLevel = 4
- },
- {
- arrivalLocation = "Los Santos",
- model = "AT-400",
- incomeLevel = 3.5
- },
- {
- arrivalLocation = "Los Santos",
- model = "Shamal",
- incomeLevel = 2
- },
- {
- arrivalLocation = "Los Santos",
- model = "Dodo",
- incomeLevel = 1.5
- }
- },
- SanFierro = {
- {
- arrivalLocation = "San Fierro",
- model = "Andromada",
- incomeLevel = 4
- },
- {
- arrivalLocation = "San Fierro",
- model = "AT-400",
- incomeLevel = 3.5
- },
- {
- arrivalLocation = "San Fierro",
- model = "Shamal",
- incomeLevel = 2
- },
- {
- arrivalLocation = "San Fierro",
- model = "Dodo",
- incomeLevel = 1.5
- }
- },
- LasVenturas = {
- {
- arrivalLocation = "Las Venturas",
- model = "Andromada",
- incomeLevel = 4
- },
- {
- arrivalLocation = "Las Venturas",
- model = "AT-400",
- incomeLevel = 3.5
- },
- {
- arrivalLocation = "Las Venturas",
- model = "Shamal",
- incomeLevel = 2
- },
- {
- arrivalLocation = "Las Venturas",
- model = "Dodo",
- incomeLevel = 1.5
- }
- }
- }
- local arriveMarkerPositions = {
- BoneCountry = {
- Vector3(46.9, 2504, 15.5),
- Vector3(106.2, 2504, 15.5),
- Vector3(159.2, 2504, 15.5),
- Vector3(214.2, 2504, 15.5),
- Vector3(261.7, 2504, 15.5),
- Vector3(310.7, 2504, 15.5),
- Vector3(358.89, 2504, 15.5),
- Vector3(406, 2504, 15.5)
- },
- LosSantos = {
- Vector3(1468.6, -2592.6, 12.5),
- Vector3(1509.0, -2592.6, 12.5),
- Vector3(1568.8, -2592.6, 12.5),
- Vector3(1628.9, -2592.6, 12.5),
- Vector3(1717.5, -2592.6, 12.5),
- Vector3(1798.6, -2592.6, 12.5),
- Vector3(1890.5, -2592.6, 12.5),
- Vector3(1953.2, -2592.6, 12.5),
- Vector3(1953.2, -2592.6, 12.5)
- },
- SanFierro = {
- Vector3(-1086.5, 406.2, 14.1),
- Vector3(-1132.2, 360.399, 14.1),
- Vector3(-1177.5, 315.799, 14.1),
- Vector3(-1223.8, 269, 14.1),
- Vector3(-1282.4, 209.5, 14.1),
- Vector3(-1338.4, 154.2, 14.1),
- Vector3(-1403.9, 88.8, 14.1),
- Vector3(-1448.5, 44.2, 14.1),
- Vector3(-1494.8, -2.2, 14.1),
- Vector3(-1543.3, -50.6, 14.1),
- Vector3(-1588.2, -96.2, 14.1),
- Vector3(-1623.2, -130.2, 14.1),
- Vector3(-1653.8, -161.7, 14.1)
- },
- LasVenturas = {
- Vector3(1477.4, 1755.1, 10.8),
- Vector3(1477.4, 1691.2, 10.8),
- Vector3(1477.4, 1617.2, 10.8),
- Vector3(1477.4, 1553, 10.8),
- Vector3(1477.4, 1468, 10.8),
- Vector3(1477.4, 1392, 10.8),
- Vector3(1477.4, 1303.6, 10.8),
- Vector3(1443.2, 1260.6, 10.8)
- }
- }
- local positionNumber = 1
- local pilotTabElements = {}
- local startLocation
- local arriveLocation
- local model
- local income
- local arriveMarker
- local arriveBlip
- function createTabElements()
- local screenW, screenH = guiGetScreenSize()
- pilotTabElements.window =
- GuiWindow((screenW - 474) / 2, (screenH - 296) / 2, 474, 296, "Airport - Pilot Tab", false)
- pilotTabElements.window:setSizable(false)
- pilotTabElements.window:setMovable(false)
- pilotTabElements.gridList = GuiGridList(13, 28, 451, 212, false, pilotTabElements.window)
- pilotTabElements.gridList:addColumn("Arrive Location", 0.3)
- pilotTabElements.gridList:addColumn("Plane Model", 0.3)
- pilotTabElements.gridList:addColumn("Income", 0.3)
- pilotTabElements.closeButton = GuiButton(14, 250, 183, 32, "Close", false, pilotTabElements.window)
- pilotTabElements.startButton = GuiButton(207, 250, 257, 32, "Start", false, pilotTabElements.window)
- end
- function getIncome(location, incomeLevel)
- -- this gets an income based on the distance between the player and the arrive marker
- local playerPosition = getLocalPlayer():getPosition()
- local distance = getDistanceBetweenPoints3D(playerPosition, arriveMarkerPositions[location][1])
- distance = math.floor(distance)
- income = distance * incomeLevel
- income = math.random(income, income + 2000)
- return income
- end
- function createPilotTab(startMarkerLocation)
- startLocation = startMarkerLocation
- createTabElements()
- showCursor(true)
- for location, valueTables in pairs(list) do
- if location ~= startLocation then
- for _index, informations in pairs(valueTables) do
- if startLocation == "BoneCountry" then
- if informations["model"] ~= "AT-400" then
- pilotTabElements.gridList:addRow(
- informations["arrivalLocation"],
- informations["model"],
- getIncome(location, informations["incomeLevel"])
- )
- end
- else
- pilotTabElements.gridList:addRow(
- informations["arrivalLocation"],
- informations["model"],
- getIncome(location, informations["incomeLevel"])
- )
- end
- end
- end
- end
- addEventHandler("onClientGUIClick", pilotTabElements.closeButton, onCloseButtonClick, false)
- addEventHandler("onClientGUIClick", pilotTabElements.startButton, onStartButtonClick, false)
- end
- addEvent("create:pilotTab", true)
- addEventHandler("create:pilotTab", getRootElement(), createPilotTab)
- function onCloseButtonClick()
- pilotTabElements.window:destroy()
- pilotTabElements = {}
- showCursor(false)
- end
- function onStartButtonClick()
- local selectedRow, selectedColumn = pilotTabElements.gridList:getSelectedItem()
- if selectedRow ~= -1 and selectedColumn ~= -1 then
- arriveLocation = pilotTabElements.gridList:getItemText(selectedRow, selectedColumn)
- arriveLocation = arriveLocation:gsub(" ", "")
- model = pilotTabElements.gridList:getItemText(selectedRow, selectedColumn + 1)
- income = pilotTabElements.gridList:getItemText(selectedRow, selectedColumn + 2)
- pilotTabElements.window:destroy()
- pilotTabElements = {}
- triggerServerEvent("make:plane", getLocalPlayer(), startLocation, model)
- triggerEvent("start:flight", getLocalPlayer())
- showCursor(false)
- else
- return outputChatBox("Please specify a flight.", 255, 0, 0)
- end
- end
- function startFlight()
- arriveMarker = Marker(arriveMarkerPositions[arriveLocation][1])
- arriveBlip = Blip.createAttachedTo(arriveMarker)
- addEventHandler("stop:flight", getLocalPlayer(), stopFlight)
- addEventHandler("onClientMarkerHit", arriveMarker, onArriveMarkerHit)
- end
- addEvent("start:flight")
- addEventHandler("start:flight", getLocalPlayer(), startFlight)
- function stopFlight()
- arriveBlip:destroy()
- arriveMarker:destroy()
- local handler = getEventHandlers("stop:flight", getLocalPlayer())
- removeEventHandler("stop:flight", getLocalPlayer(), handler[1])
- end
- addEvent("stop:flight", true)
- function onArriveMarkerHit()
- if positionNumber == #arriveMarkerPositions[arriveLocation] then
- local handler = getEventHandlers("stop:flight", getLocalPlayer())
- removeEventHandler("stop:flight", getLocalPlayer(), handler[1])
- triggerServerEvent("give:salary", getLocalPlayer(), income)
- arriveBlip:destroy()
- arriveMarker:destroy()
- positionNumber = 1
- else
- positionNumber = positionNumber + 1
- arriveMarker:setPosition(arriveMarkerPositions[arriveLocation][positionNumber])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement