Skip to content

Commit

Permalink
Update v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PickleModifications authored Dec 1, 2022
1 parent 45f029a commit 7d17372
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 28 deletions.
5 changes: 0 additions & 5 deletions bridge/esx/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ function RemoveItem(source, name, amount)
end
end

function CanCarryItem(source, name, amount)
local xPlayer = ESX.GetPlayerFromId(source)
return xPlayer.canCarryItem(name, amount)
end

function RegisterUsableItem(...)
ESX.RegisterUsableItem(...)
end
Expand Down
6 changes: 1 addition & 5 deletions bridge/qb/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,12 @@ function RemoveItem(source, name, amount)
end
end

function CanCarryItem(source, name, amount)
return true -- No function for this.
end

function RegisterUsableItem(...)
QBCore.Functions.CreateUseableItem(...)
end

function PermissionCheck(source, perm)
local job = QBCore.Functions.GetPlayer(source).job
local job = QBCore.Functions.GetPlayer(source).PlayerData.job
if (perm == "flight") then
return (job.name == "airport")
elseif (perm == "pilot_mission") then
Expand Down
11 changes: 11 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Config = {}

Config.Debug = true

Config.MissionCommand = true

Config.Blips = {}

Config.Tracker = {
Expand Down Expand Up @@ -117,6 +119,15 @@ Config.Missions = {
}
}

Config.MissionTypes = {
Passenger = {
Model = `shamal`
},
Delivery = {
Model = `titan`
}
}

Config.Airports = {
{
AirportTitle = "LSIA Airport",
Expand Down
70 changes: 65 additions & 5 deletions modules/airports/client.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,49 @@
local Interact = false
Interact = false

function StartNPCFlight(index)
function StartNPCFlight(from, index)
ServerCallback("pickle_airport:startNPCFlight", function(result)
if (result) then
local Plane = nil
local airport_cfg = Config.Airports[from]
local cfg = Config.Airports[index]
local coords = cfg.Locations.Boarding
local ped = PlayerPedId()
DoScreenFadeOut(1000)
Wait(1400)
local data = Flight
local start, finish, board = airport_cfg.Locations.Flight, cfg.Locations.Flight, cfg.Locations.Boarding

start, finish = vec3(start.x, start.y, 1700.0), vec3(finish.x, finish.y, 1700.0)

SetEntityCoords(ped, start.x, start.y, start.z)

Wait(100)

local heading = GetHeadingFromVector_2d(start.x - finish.x, start.y - finish.y)
local ped = CreateNPC(`g_m_m_armboss_01`, start.x, start.y, start.z, 0.0, true, true)

Plane = CreateVeh(`luxor`, start.x, start.y, start.z, heading - 180.0, false, true)

TaskWarpPedIntoVehicle(ped, Plane, -1)
TaskWarpPedIntoVehicle(PlayerPedId(), Plane, 1)

Wait(100)
DoScreenFadeIn(1000)

local percent = 0
while percent < 1.0 do
percent = percent + 0.0005
local coords = lerp(start, finish, percent)
SetEntityCoords(Plane, coords.x, coords.y, coords.z)
DisableControlAction(1, 75, 1)
Wait(0)
end
FreezeEntityPosition(Plane, true)
DoScreenFadeOut(1000)
Wait(1500)
SetEntityCoords(ped, coords.x, coords.y, coords.z)
DeleteEntity(Plane)
SetEntityCoords(PlayerPedId(), board.x, board.y, board.z)

Wait(100)
DoScreenFadeIn(1000)
else
Expand Down Expand Up @@ -125,6 +160,31 @@ function OpenSpawnMenu(index)
lib.showMenu(menu_id)
end

function ShowHangarMenu(index)
local menu_id = "airport_hangar_menu"
local options = {
{label = "Aircraft Spawner", description = ""},
{label = "Mission Selector", description = ""},
}
lib.registerMenu({
id = menu_id,
title = 'Hangar',
position = 'top-left',
onClose = function(keyPressed)
Interact = false
end,
options = options
}, function(selected, scrollIndex, args)
if (selected == 1) then
OpenSpawnMenu(index)
elseif (selected == 2) then
OpenMissionMenu(index)
end
end)

lib.showMenu(menu_id)
end

function OpenNPCMenu(index)
local menu_id = "airport_npc_menu"
local options = {}
Expand All @@ -143,7 +203,7 @@ function OpenNPCMenu(index)
end,
options = options
}, function(selected, scrollIndex, args)
StartNPCFlight(options[selected].index)
StartNPCFlight(index, options[selected].index)
end)
lib.showMenu(menu_id)
end
Expand Down Expand Up @@ -200,7 +260,7 @@ function InteractAirport(index, key)
DeleteEntity(vehicle)
Interact = false
else
OpenSpawnMenu(index)
ShowHangarMenu(index)
end
end
end
Expand Down
78 changes: 65 additions & 13 deletions modules/missions/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,35 @@ function StopMission()
SetMissionBlip()
end

function StartMission(lastIndex, vehicle)
local vehicle = vehicle or GetCurrentAircraft()
if not vehicle then
ShowNotification("You cannot start a mission without being in a aircraft.")
elseif MissionIndex == nil then
local index = GetRandomInt(1, #Config.Missions.Sequences, lastIndex)
function StartMission(Type)
local vehicle = (Config.MissionCommand and GetCurrentAircraft() or nil)
if MissionIndex == nil then
if not vehicle then
if (Type and Config.MissionTypes[Type]) then
local model = Config.MissionTypes[Type].Model
local coords, heading = GetEntityCoords(PlayerPedId()), GetEntityHeading(PlayerPedId())
vehicle = CreateVeh(model, coords.x, coords.y, coords.z, heading, true, true)
TaskWarpPedIntoVehicle(PlayerPedId(), vehicle, -1)
Wait(100)
else
ShowNotification("You cannot start a mission without being in a aircraft.")
return
end
end
local index = GetRandomInt(1, #Config.Missions.Sequences)
if Type then
for i=1, 10 do
if Config.Missions.Sequences[index].Type ~= Type then
index = GetRandomInt(1, #Config.Missions.Sequences)
else
break
end
end
if Config.Missions.Sequences[index].Type ~= Type then
ShowNotification("There are no missions for this category.")
return
end
end
MissionIndex = index
MissionAircraft = vehicle
local mission = Config.Missions.Sequences[MissionIndex]
Expand Down Expand Up @@ -269,10 +292,39 @@ function StartMission(lastIndex, vehicle)
end
end

RegisterCommand("pilotmission", function()
if (PermissionCheck("pilot_mission")) then
StartMission()
else
ShowNotification(U.permission_denied)
end
end)
function OpenMissionMenu(index)
local menu_id = "airport_mission_menu"
local options = {
{label = "Passenger Flights", description = ""},
{label = "Package Delivery", description = ""},
}
lib.registerMenu({
id = menu_id,
title = 'Aircraft Spawner',
position = 'top-left',
onClose = function(keyPressed)
Interact = false
end,
options = options
}, function(selected, scrollIndex, args)
Interact = false
if (selected == 1) then
StartMission("Passenger")
elseif (selected == 2) then
StartMission("Delivery")
end
end)

lib.showMenu(menu_id)
end

if Config.MissionCommand then
RegisterCommand("pilotmission", function()
if (PermissionCheck("pilot_mission")) then
StartMission()
else
ShowNotification(U.permission_denied)
end
end)
end

0 comments on commit 7d17372

Please sign in to comment.