Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local screenW, screenH = guiGetScreenSize()
- local dimensions = {
- window = {
- floatX = (screenW - 474) / 2,
- floatY = (screenH - 296) / 2,
- width = 474,
- height = 296
- },
- gridList = {
- floatX = 13,
- floatY = 28,
- width = 451,
- height = 212
- },
- closeButton = {
- floatX = 14,
- floatY = 250,
- width = 183,
- height = 32
- },
- startButton = {
- floatX = 207,
- floatY = 250,
- width = 257,
- height = 32
- }
- }
- function round(num, numDecimalPlaces)
- local mult = 10 ^ (numDecimalPlaces or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- local list = {
- BoneCountry = {
- {
- "Bone Country",
- "Andromada",
- 4
- },
- {
- "Bone Country",
- "AT400",
- 3.5
- },
- {
- "Bone Country",
- "Shamal",
- 2
- },
- {
- "Bone Country",
- "Dodo",
- 1.5
- }
- },
- LosSantos = {
- {
- "Los Santos",
- "Andromada",
- 4
- },
- {
- "Los Santos",
- "AT400",
- 3.5
- },
- {
- "Los Santos",
- "Shamal",
- 2
- },
- {
- "Los Santos",
- "Dodo",
- 1.5
- }
- },
- SanFierro = {
- {
- "San Fierro",
- "Andromada",
- 4
- },
- {
- "San Fierro",
- "AT400",
- 3.5
- },
- {
- "San Fierro",
- "Shamal",
- 2
- },
- {
- "San Fierro",
- "Dodo",
- 1.5
- }
- },
- LasVenturas = {
- {
- "Las Venturas",
- "Andromada",
- 4
- },
- {
- "Las Venturas",
- "AT400",
- 3.5
- },
- {
- "Las Venturas",
- "Shamal",
- 2
- },
- {
- "Las Venturas",
- "Dodo",
- 1.5
- }
- }
- }
- local arriveMarkerPositions = {
- BoneCountry = {
- {x = 46.9, y = 2504, z = 15.5},
- {x = 106.2, y = 2504, z = 15.5},
- {x = 159.2, y = 2504, z = 15.5},
- {x = 214.2, y = 2504, z = 15.5},
- {x = 261.7, y = 2504, z = 15.5},
- {x = 310.7, y = 2504, z = 15.5},
- {x = 358.89, y = 2504, z = 15.5},
- {x = 406, y = 2504, z = 15.5}
- },
- LosSantos = {
- {x = 1468.6, y = -2592.6, z = 12.5},
- {x = 1509.0, y = -2592.6, z = 12.5},
- {x = 1568.8, y = -2592.6, z = 12.5},
- {x = 1628.9, y = -2592.6, z = 12.5},
- {x = 1717.5, y = -2592.6, z = 12.5},
- {x = 1798.6, y = -2592.6, z = 12.5},
- {x = 1890.5, y = -2592.6, z = 12.5},
- {x = 1953.2, y = -2592.6, z = 12.5},
- {x = 1953.2, y = -2592.6, z = 12.5}
- },
- SanFierro = {
- {x = -1086.5, y = 406.2, z = 14.1},
- {x = -1132.2, y = 360.399, z = 14.1},
- {x = -1177.5, y = 315.799, z = 14.1},
- {x = -1223.8, y = 269, z = 14.1},
- {x = -1282.4, y = 209.5, z = 14.1},
- {x = -1338.4, y = 154.2, z = 14.1},
- {x = -1403.9, y = 88.8, z = 14.1},
- {x = -1448.5, y = 44.2, z = 14.1},
- {x = -1494.8, y = -2.2, z = 14.1},
- {x = -1543.3, y = -50.6, z = 14.1},
- {x = -1588.2, y = -96.2, z = 14.1},
- {x = -1623.2, y = -130.2, z = 14.1},
- {x = -1653.8, y = -161.7, z = 14.1}
- },
- LasVenturas = {
- {x = 1477.4, y = 1755.1, z = 10.8},
- {x = 1477.4, y = 1691.2, z = 10.8},
- {x = 1477.4, y = 1617.2, z = 10.8},
- {x = 1477.4, y = 1553, z = 10.8},
- {x = 1477.4, y = 1468, z = 10.8},
- {x = 1477.4, y = 1392, z = 10.8},
- {x = 1477.4, y = 1303.6, z = 10.8},
- {x = 1443.2, y = 1260.6, z = 10.8}
- }
- }
- function pilotTab(location, distances)
- showCursor(true)
- local window =
- GuiWindow(
- dimensions.window["floatX"],
- dimensions.window["floatY"],
- dimensions.window["width"],
- dimensions.window["height"],
- "Los Santos Airport - Pilot Tab",
- false
- )
- window:setSizable(false)
- window:setMovable(false)
- local gridList =
- GuiGridList(
- dimensions.gridList["floatX"],
- dimensions.gridList["floatY"],
- dimensions.gridList["width"],
- dimensions.gridList["height"],
- false,
- window
- )
- gridList:addColumn("Arrive Location", 0.3)
- gridList:addColumn("Plane Model", 0.3)
- gridList:addColumn("Income", 0.3)
- local closeButton =
- GuiButton(
- dimensions.closeButton["floatX"],
- dimensions.closeButton["floatY"],
- dimensions.closeButton["width"],
- dimensions.closeButton["height"],
- "Close",
- false,
- window
- )
- local startButton =
- GuiButton(
- dimensions.startButton["floatX"],
- dimensions.startButton["floatY"],
- dimensions.startButton["width"],
- dimensions.startButton["height"],
- "Start",
- false,
- window
- )
- for k, v in pairs(list) do
- if k ~= location then
- for k2, v2 in ipairs(v) do
- if location == "BoneCountry" then
- if v2[2] ~= "AT400" then
- gridList:addRow(v2[1], v2[2], round(v2[3] * distances[k]))
- end
- else
- gridList:addRow(v2[1], v2[2], round(v2[3] * distances[k]))
- end
- end
- end
- end
- function onCloseButtonClick()
- window:destroy()
- showCursor(false)
- end
- addEventHandler("onClientGUIClick", closeButton, onCloseButtonClick, false)
- function onStartButtonClick()
- local selectedRow, selectedColumn = gridList:getSelectedItem()
- if selectedRow ~= -1 and selectedColumn ~= -1 then
- showCursor(false)
- local arrivalLocation = gridList:getItemText(selectedRow, selectedColumn)
- arrivalLocation = arrivalLocation:gsub(" ", "")
- local planeModel = gridList:getItemText(selectedRow, selectedColumn + 1)
- local income = gridList:getItemText(selectedRow, selectedColumn + 2)
- triggerServerEvent(
- "makePlane",
- getRootElement(),
- getLocalPlayer(),
- planeModel,
- location,
- arrivalLocation,
- income
- )
- window:destroy()
- else
- return outputChatBox("Please Select a mission.", 255, 20, 20)
- end
- end
- addEventHandler("onClientGUIClick", startButton, onStartButtonClick, false)
- end
- addEvent("openPilotTab", true)
- addEventHandler("openPilotTab", getRootElement(), pilotTab)
- function startJob(arrivalLocation, income)
- local newPosition
- local i = 1
- local position =
- Vector3(
- arriveMarkerPositions[arrivalLocation][i]["x"],
- arriveMarkerPositions[arrivalLocation][i]["y"],
- arriveMarkerPositions[arrivalLocation][i]["z"]
- )
- local arriveMarker = Marker(position, "checkpoint", 10, 255, 255, 0, 200)
- local blip = Blip.createAttachedTo(arriveMarker)
- function stopMission()
- outputChatBox("You have abondand the mission", 255, 0, 0)
- arriveMarker:destroy()
- blip:destroy()
- i = nil
- end
- addEvent("stop:mission", true)
- addEventHandler("stop:mission", getRootElement(), stopMission)
- function onArriveMarkerHit()
- if i == #arriveMarkerPositions[arrivalLocation] then
- i = nil
- arriveMarker:destroy()
- blip:destroy()
- triggerServerEvent("getSalary", getRootElement(), income)
- else
- i = i + 1
- newPosition =
- Vector3(
- arriveMarkerPositions[arrivalLocation][i]["x"],
- arriveMarkerPositions[arrivalLocation][i]["y"],
- arriveMarkerPositions[arrivalLocation][i]["z"]
- )
- arriveMarker:setPosition(newPosition)
- end
- end
- addEventHandler("onClientMarkerHit", arriveMarker, onArriveMarkerHit)
- end
- addEvent("start:job", true)
- addEventHandler("start:job", getRootElement(), startJob)
- addCommandHandler(
- "vehposition",
- function()
- local veh = getLocalPlayer():getOccupiedVehicle()
- local x, y, z = getElementPosition(veh)
- iprint(x, y, z)
- local xr, yr, zr = getElementRotation(veh)
- iprint(x, y, z)
- outputChatBox("x =" .. x .. ", y =" .. y .. ", z =" .. z, 0, 200, 0)
- outputChatBox(", rx =" .. xr .. ", ry =" .. yr .. ", rz =" .. zr, 0, 200, 0)
- end
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement