mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 17:28:53 +00:00
756 lines
21 KiB
Lua
756 lines
21 KiB
Lua
local Keys = {
|
|
["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
|
|
["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
|
|
["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
|
|
["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
|
|
["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
|
|
["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
|
|
["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
|
|
["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
|
|
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
|
|
}
|
|
|
|
ESX = nil
|
|
local PlayerData = {}
|
|
local GUI = {}
|
|
GUI.Time = 0
|
|
local HasAlreadyEnteredMarker = false
|
|
local LastZone = nil
|
|
local CurrentAction = nil
|
|
local CurrentActionMsg = ''
|
|
local CurrentActionData = {}
|
|
local OnJob = false
|
|
local CurrentCustomer = nil
|
|
local CurrentCustomerBlip = nil
|
|
local DestinationBlip = nil
|
|
local IsNearCustomer = false
|
|
local CustomerIsEnteringVehicle = false
|
|
local CustomerEnteredVehicle = false
|
|
local TargetCoords = nil
|
|
|
|
Citizen.CreateThread(function()
|
|
while ESX == nil do
|
|
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
|
Citizen.Wait(0)
|
|
end
|
|
end)
|
|
|
|
function DrawSub(msg, time)
|
|
ClearPrints()
|
|
SetTextEntry_2("STRING")
|
|
AddTextComponentString(msg)
|
|
DrawSubtitleTimed(time, 1)
|
|
end
|
|
|
|
function ShowLoadingPromt(msg, time, type)
|
|
Citizen.CreateThread(function()
|
|
Citizen.Wait(0)
|
|
N_0xaba17d7ce615adbf("STRING")
|
|
AddTextComponentString(msg)
|
|
N_0xbd12f8228410d9b4(type)
|
|
Citizen.Wait(time)
|
|
N_0x10d373323e5b9c0d()
|
|
end)
|
|
end
|
|
|
|
function GetRandomPed()
|
|
|
|
local peds = {}
|
|
local handle, ped = FindFirstPed()
|
|
local success = nil
|
|
|
|
repeat
|
|
table.insert(peds, ped)
|
|
success, ped = FindNextPed(handle)
|
|
until not success
|
|
|
|
EndFindPed(handle)
|
|
|
|
if #peds > 0 then
|
|
return peds[GetRandomIntInRange(1, #peds)]
|
|
end
|
|
|
|
end
|
|
|
|
function ClearCurrentMission()
|
|
|
|
if DoesBlipExist(CurrentCustomerBlip) then
|
|
RemoveBlip(CurrentCustomerBlip)
|
|
end
|
|
|
|
if DoesBlipExist(DestinationBlip) then
|
|
RemoveBlip(DestinationBlip)
|
|
end
|
|
|
|
CurrentCustomer = nil
|
|
CurrentCustomerBlip = nil
|
|
DestinationBlip = nil
|
|
IsNearCustomer = false
|
|
CustomerIsEnteringVehicle = false
|
|
CustomerEnteredVehicle = false
|
|
TargetCoords = nil
|
|
|
|
end
|
|
|
|
function StartTaxiJob()
|
|
|
|
ShowLoadingPromt('Prise de service : Taxi/Uber', 5000, 3)
|
|
ClearCurrentMission()
|
|
|
|
OnJob = true
|
|
|
|
end
|
|
|
|
function StopTaxiJob()
|
|
|
|
local playerPed = GetPlayerPed(-1)
|
|
|
|
if IsPedInAnyVehicle(playerPed, false) and CurrentCustomer ~= nil then
|
|
local vehicle = GetVehiclePedIsIn(playerPed, false)
|
|
TaskLeaveVehicle(CurrentCustomer, vehicle, 0)
|
|
|
|
if CustomerEnteredVehicle then
|
|
TaskGoStraightToCoord(CurrentCustomer, TargetCoords.x, TargetCoords.y, TargetCoords.z, 1.0, -1, 0.0, 0.0)
|
|
end
|
|
|
|
end
|
|
|
|
ClearCurrentMission()
|
|
|
|
OnJob = false
|
|
|
|
DrawSub('Mission terminée', 5000)
|
|
|
|
end
|
|
|
|
function OpenTaxiActionsMenu()
|
|
|
|
local elements = {
|
|
{label = 'Sortir Véhicule', value = 'spawn_vehicle'}
|
|
}
|
|
|
|
if Config.EnablePlayerManagement and PlayerData.job ~= nil and PlayerData.job.grade_name == 'boss' then
|
|
table.insert(elements, {label = 'Retirer argent société', value = 'withdraw_society_money'})
|
|
table.insert(elements, {label = 'Déposer argent ', value = 'deposit_money'})
|
|
table.insert(elements, {label = 'Blanchir argent', value = 'wash_money'})
|
|
end
|
|
|
|
ESX.UI.Menu.CloseAll()
|
|
|
|
ESX.UI.Menu.Open(
|
|
'default', GetCurrentResourceName(), 'taxi_actions',
|
|
{
|
|
title = 'Taxi',
|
|
elements = elements
|
|
},
|
|
function(data, menu)
|
|
|
|
if data.current.value == 'spawn_vehicle' then
|
|
|
|
menu.close()
|
|
|
|
if Config.MaxInService == -1 then
|
|
|
|
local playerPed = GetPlayerPed(-1)
|
|
local coords = Config.Zones.VehicleSpawnPoint.Pos
|
|
|
|
ESX.Game.SpawnVehicle('taxi', coords, 225.0, function(vehicle)
|
|
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
|
|
end)
|
|
|
|
else
|
|
|
|
ESX.TriggerServerCallback('esx_service:enableService', function(canTakeService, maxInService, inServiceCount)
|
|
|
|
if canTakeService then
|
|
|
|
local playerPed = GetPlayerPed(-1)
|
|
local coords = Config.Zones.VehicleSpawnPoint.Pos
|
|
|
|
ESX.Game.SpawnVehicle('taxi', coords, 225.0, function(vehicle)
|
|
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
|
|
end)
|
|
|
|
else
|
|
|
|
ESX.ShowNotification('Service complet : ' .. inServiceCount .. '/' .. maxInService)
|
|
|
|
end
|
|
|
|
end, 'taxi')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if data.current.value == 'withdraw_society_money' then
|
|
|
|
ESX.UI.Menu.Open(
|
|
'dialog', GetCurrentResourceName(), 'withdraw_society_money_amount',
|
|
{
|
|
title = 'Montant du retrait'
|
|
},
|
|
function(data, menu)
|
|
|
|
local amount = tonumber(data.value)
|
|
|
|
if amount == nil then
|
|
ESX.ShowNotification('Montant invalide')
|
|
else
|
|
menu.close()
|
|
TriggerServerEvent('esx_society:withdrawMoney', 'taxi', amount)
|
|
end
|
|
|
|
end,
|
|
function(data, menu)
|
|
menu.close()
|
|
end
|
|
)
|
|
|
|
end
|
|
|
|
if data.current.value == 'deposit_money' then
|
|
|
|
ESX.UI.Menu.Open(
|
|
'dialog', GetCurrentResourceName(), 'deposit_money_amount',
|
|
{
|
|
title = 'Montant du dépôt'
|
|
},
|
|
function(data, menu)
|
|
|
|
local amount = tonumber(data.value)
|
|
|
|
if amount == nil then
|
|
ESX.ShowNotification('Montant invalide')
|
|
else
|
|
menu.close()
|
|
TriggerServerEvent('esx_society:depositMoney', 'taxi', amount)
|
|
end
|
|
|
|
end,
|
|
function(data, menu)
|
|
menu.close()
|
|
end
|
|
)
|
|
|
|
end
|
|
|
|
if data.current.value == 'wash_money' then
|
|
|
|
ESX.UI.Menu.Open(
|
|
'dialog', GetCurrentResourceName(), 'wash_money_amount',
|
|
{
|
|
title = 'Montant à blanchir'
|
|
},
|
|
function(data, menu)
|
|
|
|
local amount = tonumber(data.value)
|
|
|
|
if amount == nil then
|
|
ESX.ShowNotification('Montant invalide')
|
|
else
|
|
menu.close()
|
|
TriggerServerEvent('esx_society:washMoney', 'taxi', amount)
|
|
end
|
|
|
|
end,
|
|
function(data, menu)
|
|
menu.close()
|
|
end
|
|
)
|
|
|
|
end
|
|
|
|
end,
|
|
function(data, menu)
|
|
|
|
menu.close()
|
|
|
|
CurrentAction = 'taxi_actions_menu'
|
|
CurrentActionMsg = 'Appuez sur ~INPUT_CONTEXT~ pour accéder au menu'
|
|
CurrentActionData = {}
|
|
|
|
end
|
|
)
|
|
|
|
end
|
|
|
|
function OpenMobileTaxiActionsMenu()
|
|
|
|
ESX.UI.Menu.CloseAll()
|
|
|
|
ESX.UI.Menu.Open(
|
|
'default', GetCurrentResourceName(), 'mobile_taxi_actions',
|
|
{
|
|
title = 'Taxi',
|
|
elements = {
|
|
{label = 'Facuration', value = 'billing'}
|
|
}
|
|
},
|
|
function(data, menu)
|
|
|
|
if data.current.value == 'billing' then
|
|
|
|
ESX.UI.Menu.Open(
|
|
'dialog', GetCurrentResourceName(), 'billing',
|
|
{
|
|
title = 'Montant de la facture'
|
|
},
|
|
function(data, menu)
|
|
|
|
local amount = tonumber(data.value)
|
|
|
|
if amount == nil then
|
|
ESX.ShowNotification('Montant invalide')
|
|
else
|
|
|
|
menu.close()
|
|
|
|
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
|
|
|
|
if closestPlayer == -1 or closestDistance > 3.0 then
|
|
ESX.ShowNotification('Aucun joueur à proximité')
|
|
else
|
|
TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_taxi', 'Taxi', amount)
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
function(data, menu)
|
|
menu.close()
|
|
end
|
|
)
|
|
|
|
end
|
|
|
|
end,
|
|
function(data, menu)
|
|
menu.close()
|
|
end
|
|
)
|
|
|
|
end
|
|
|
|
RegisterNetEvent('esx:playerLoaded')
|
|
AddEventHandler('esx:playerLoaded', function(xPlayer)
|
|
PlayerData = xPlayer
|
|
end)
|
|
|
|
RegisterNetEvent('esx:setJob')
|
|
AddEventHandler('esx:setJob', function(job)
|
|
PlayerData.job = job
|
|
end)
|
|
|
|
AddEventHandler('esx_taxijob:hasEnteredMarker', function(zone)
|
|
|
|
if zone == 'TaxiActions' then
|
|
CurrentAction = 'taxi_actions_menu'
|
|
CurrentActionMsg = 'Appuez sur ~INPUT_CONTEXT~ pour accéder au menu'
|
|
CurrentActionData = {}
|
|
end
|
|
|
|
if zone == 'VehicleDeleter' then
|
|
|
|
local playerPed = GetPlayerPed(-1)
|
|
|
|
if IsPedInAnyVehicle(playerPed, false) then
|
|
CurrentAction = 'delete_vehicle'
|
|
CurrentActionMsg = 'Appuez sur ~INPUT_CONTEXT~ pour ranger le véhicule'
|
|
CurrentActionData = {}
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
AddEventHandler('esx_taxijob:hasExitedMarker', function(zone)
|
|
CurrentAction = nil
|
|
end)
|
|
|
|
RegisterNetEvent('esx_phone:loaded')
|
|
AddEventHandler('esx_phone:loaded', function(phoneNumber, contacts)
|
|
|
|
local specialContact = {
|
|
name = 'Taxi',
|
|
number = 'taxi',
|
|
base64Icon = 'data:image/png;base64,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',
|
|
}
|
|
|
|
TriggerEvent('esx_phone:addSpecialContact', specialContact.name, specialContact.number, specialContact.base64Icon)
|
|
|
|
end)
|
|
|
|
-- Create Blips
|
|
Citizen.CreateThread(function()
|
|
|
|
local blip = AddBlipForCoord(Config.Zones.TaxiActions.Pos.x, Config.Zones.TaxiActions.Pos.y, Config.Zones.TaxiActions.Pos.z)
|
|
|
|
SetBlipSprite (blip, 198)
|
|
SetBlipDisplay(blip, 4)
|
|
SetBlipScale (blip, 1.0)
|
|
SetBlipColour (blip, 5)
|
|
SetBlipAsShortRange(blip, true)
|
|
|
|
BeginTextCommandSetBlipName("STRING")
|
|
AddTextComponentString("Taxi")
|
|
EndTextCommandSetBlipName(blip)
|
|
|
|
end)
|
|
|
|
-- Display markers
|
|
Citizen.CreateThread(function()
|
|
while true do
|
|
|
|
Wait(0)
|
|
|
|
if PlayerData.job ~= nil and PlayerData.job.name == 'taxi' then
|
|
|
|
local coords = GetEntityCoords(GetPlayerPed(-1))
|
|
|
|
for k,v in pairs(Config.Zones) do
|
|
if(v.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then
|
|
DrawMarker(v.Type, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, true, 2, false, false, false, false)
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end)
|
|
|
|
-- Enter / Exit marker events
|
|
Citizen.CreateThread(function()
|
|
while true do
|
|
|
|
Wait(0)
|
|
|
|
if PlayerData.job ~= nil and PlayerData.job.name == 'taxi' then
|
|
|
|
local coords = GetEntityCoords(GetPlayerPed(-1))
|
|
local isInMarker = false
|
|
local currentZone = nil
|
|
|
|
for k,v in pairs(Config.Zones) do
|
|
if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x) then
|
|
isInMarker = true
|
|
currentZone = k
|
|
end
|
|
end
|
|
|
|
if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then
|
|
HasAlreadyEnteredMarker = true
|
|
LastZone = currentZone
|
|
TriggerEvent('esx_taxijob:hasEnteredMarker', currentZone)
|
|
end
|
|
|
|
if not isInMarker and HasAlreadyEnteredMarker then
|
|
HasAlreadyEnteredMarker = false
|
|
TriggerEvent('esx_taxijob:hasExitedMarker', LastZone)
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end)
|
|
|
|
-- Taxi Job
|
|
Citizen.CreateThread(function()
|
|
|
|
while true do
|
|
|
|
Citizen.Wait(0)
|
|
|
|
local playerPed = GetPlayerPed(-1)
|
|
|
|
if OnJob then
|
|
|
|
if CurrentCustomer == nil then
|
|
|
|
DrawSub('Conduisez à la recherche de ~y~passagers', 5000)
|
|
|
|
if IsPedInAnyVehicle(playerPed, false) and GetEntitySpeed(playerPed) > 0 then
|
|
|
|
local waitUntil = GetGameTimer() + GetRandomIntInRange(1000, 120000)
|
|
|
|
while OnJob and waitUntil > GetGameTimer() do
|
|
Citizen.Wait(0)
|
|
end
|
|
|
|
if OnJob and IsPedInAnyVehicle(playerPed, false) and GetEntitySpeed(playerPed) > 0 then
|
|
|
|
while CurrentCustomer == nil do
|
|
|
|
local ped = GetRandomPed()
|
|
|
|
if IsPedHuman(ped) and IsPedWalking(ped) then
|
|
CurrentCustomer = ped
|
|
end
|
|
|
|
end
|
|
|
|
CurrentCustomerBlip = AddBlipForEntity(CurrentCustomer)
|
|
|
|
SetBlipAsFriendly(CurrentCustomerBlip, 1)
|
|
SetBlipColour(CurrentCustomerBlip, 2)
|
|
SetBlipCategory(CurrentCustomerBlip, 3)
|
|
SetBlipRoute(CurrentCustomerBlip, true)
|
|
|
|
SetEntityAsMissionEntity(CurrentCustomer, true)
|
|
ClearPedTasksImmediately(CurrentCustomer)
|
|
SetBlockingOfNonTemporaryEvents(CurrentCustomer, 1)
|
|
|
|
local standTime = GetRandomIntInRange(60000, 180000)
|
|
|
|
TaskStandStill(CurrentCustomer, standTime)
|
|
|
|
ESX.ShowNotification('Vous avez ~g~trouvé~s~ un client, conduisez jusqu\'à ce dernier')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if IsPedFatallyInjured(CurrentCustomer) then
|
|
|
|
ESX.ShowNotification('Votre client est ~r~inconscient~w~. Cherchez-en un autre.')
|
|
|
|
if DoesBlipExist(CurrentCustomerBlip) then
|
|
RemoveBlip(CurrentCustomerBlip)
|
|
end
|
|
|
|
if DoesBlipExist(DestinationBlip) then
|
|
RemoveBlip(DestinationBlip)
|
|
end
|
|
|
|
SetEntityAsMissionEntity(CurrentCustomer, false)
|
|
|
|
CurrentCustomer = nil
|
|
CurrentCustomerBlip = nil
|
|
DestinationBlip = nil
|
|
IsNearCustomer = false
|
|
CustomerIsEnteringVehicle = false
|
|
CustomerEnteredVehicle = false
|
|
TargetCoords = nil
|
|
|
|
end
|
|
|
|
if IsPedInAnyVehicle(playerPed, false) then
|
|
|
|
local vehicle = GetVehiclePedIsIn(playerPed, false)
|
|
local playerCoords = GetEntityCoords(playerPed)
|
|
local customerCoords = GetEntityCoords(CurrentCustomer)
|
|
local customerDistance = GetDistanceBetweenCoords(playerCoords.x, playerCoords.y, playerCoords.z, customerCoords.x, customerCoords.y, customerCoords.z)
|
|
|
|
if IsPedSittingInVehicle(CurrentCustomer, vehicle) then
|
|
|
|
if CustomerEnteredVehicle then
|
|
|
|
local targetDistance = GetDistanceBetweenCoords(playerCoords.x, playerCoords.y, playerCoords.z, TargetCoords.x, TargetCoords.y, TargetCoords.z)
|
|
|
|
if targetDistance <= 10.0 then
|
|
|
|
TaskLeaveVehicle(CurrentCustomer, vehicle, 0)
|
|
|
|
ESX.ShowNotification('Vous êtes ~g~arrivé~s~ à destination')
|
|
|
|
TaskGoStraightToCoord(CurrentCustomer, TargetCoords.x, TargetCoords.y, TargetCoords.z, 1.0, -1, 0.0, 0.0)
|
|
SetEntityAsMissionEntity(CurrentCustomer, false)
|
|
|
|
TriggerServerEvent('esx_taxijob:success')
|
|
|
|
RemoveBlip(DestinationBlip)
|
|
|
|
CurrentCustomer = nil
|
|
CurrentCustomerBlip = nil
|
|
DestinationBlip = nil
|
|
IsNearCustomer = false
|
|
CustomerIsEnteringVehicle = false
|
|
CustomerEnteredVehicle = false
|
|
TargetCoords = nil
|
|
|
|
end
|
|
|
|
DrawMarker(1, TargetCoords.x, TargetCoords.y, TargetCoords.z - 1.0, 0, 0, 0, 0, 0, 0, 4.0, 4.0, 2.0, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
|
|
|
|
else
|
|
|
|
RemoveBlip(CurrentCustomerBlip)
|
|
|
|
CurrentCustomerBlip = nil
|
|
|
|
TargetCoords = Config.JobLocations[GetRandomIntInRange(1, #Config.JobLocations)]
|
|
|
|
local street = table.pack(GetStreetNameAtCoord(TargetCoords.x, TargetCoords.y, TargetCoords.z))
|
|
local msg = nil
|
|
|
|
if street[2] ~= 0 and street[2] ~= nil then
|
|
msg = string.format("~w~Emmenez-moi à~y~ %s~w~, près de~y~ %s", GetStreetNameFromHashKey(street[1]),GetStreetNameFromHashKey(street[2]))
|
|
else
|
|
msg = string.format("~w~Emmenez-moi à~y~ %s", GetStreetNameFromHashKey(street[1]))
|
|
end
|
|
|
|
ESX.ShowNotification(msg)
|
|
|
|
DestinationBlip = AddBlipForCoord(TargetCoords.x, TargetCoords.y, TargetCoords.z)
|
|
|
|
BeginTextCommandSetBlipName("STRING")
|
|
AddTextComponentString("Destination")
|
|
EndTextCommandSetBlipName(blip)
|
|
|
|
SetBlipRoute(DestinationBlip, true)
|
|
|
|
CustomerEnteredVehicle = true
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if not CustomerIsEnteringVehicle then
|
|
DrawMarker(1, customerCoords.x, customerCoords.y, customerCoords.z - 1.0, 0, 0, 0, 0, 0, 0, 4.0, 4.0, 2.0, 178, 236, 93, 155, 0, 0, 2, 0, 0, 0, 0)
|
|
end
|
|
|
|
if not CustomerEnteredVehicle then
|
|
|
|
if customerDistance <= 30.0 then
|
|
|
|
if not IsNearCustomer then
|
|
ESX.ShowNotification('Vous êtes à proximité du client, approchez-vous de lui')
|
|
IsNearCustomer = true
|
|
end
|
|
|
|
end
|
|
|
|
if customerDistance <= 10.0 then
|
|
|
|
if not CustomerIsEnteringVehicle then
|
|
|
|
ClearPedTasksImmediately(CurrentCustomer)
|
|
|
|
local seat = 0
|
|
|
|
for i=4, 0, 1 do
|
|
if IsVehicleSeatFree(vehicle, seat) then
|
|
seat = i
|
|
break
|
|
end
|
|
end
|
|
|
|
TaskEnterVehicle(CurrentCustomer, vehicle, -1, seat, 2.0, 1)
|
|
|
|
CustomerIsEnteringVehicle = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
DrawSub('Veuillez remonter dans votre véhicule pour continuer la mission', 5000)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end)
|
|
|
|
-- Key Controls
|
|
Citizen.CreateThread(function()
|
|
while true do
|
|
|
|
Citizen.Wait(0)
|
|
|
|
if CurrentAction ~= nil then
|
|
|
|
SetTextComponentFormat('STRING')
|
|
AddTextComponentString(CurrentActionMsg)
|
|
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
|
|
|
|
if IsControlPressed(0, Keys['E']) and PlayerData.job ~= nil and PlayerData.job.name == 'taxi' and (GetGameTimer() - GUI.Time) > 300 then
|
|
|
|
if CurrentAction == 'taxi_actions_menu' then
|
|
OpenTaxiActionsMenu()
|
|
end
|
|
|
|
if CurrentAction == 'delete_vehicle' then
|
|
|
|
local playerPed = GetPlayerPed(-1)
|
|
local vehicle = GetVehiclePedIsIn(playerPed, false)
|
|
|
|
if GetEntityModel(vehicle) == GetHashKey('taxi') then
|
|
|
|
if Config.MaxInService ~= -1 then
|
|
TriggerServerEvent('esx_service:disableService', 'taxi')
|
|
end
|
|
|
|
DeleteVehicle(vehicle)
|
|
else
|
|
ESX.ShowNotification('Vous ne pouvez ranger que les taxi')
|
|
end
|
|
|
|
end
|
|
|
|
CurrentAction = nil
|
|
GUI.Time = GetGameTimer()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if IsControlPressed(0, Keys['F6']) and Config.EnablePlayerManagement and (GetGameTimer() - GUI.Time) > 150 then
|
|
OpenMobileTaxiActionsMenu()
|
|
GUI.Time = GetGameTimer()
|
|
end
|
|
|
|
if IsControlPressed(0, Keys['DELETE']) and (GetGameTimer() - GUI.Time) > 150 then
|
|
|
|
if OnJob then
|
|
StopTaxiJob()
|
|
else
|
|
|
|
if PlayerData.job ~= nil and PlayerData.job.name == 'taxi' then
|
|
|
|
local playerPed = GetPlayerPed(-1)
|
|
|
|
if IsPedInAnyVehicle(playerPed, false) then
|
|
|
|
local vehicle = GetVehiclePedIsIn(playerPed, false)
|
|
|
|
if PlayerData.job.grade >= 3 then
|
|
StartTaxiJob()
|
|
else
|
|
if GetEntityModel(vehicle) == GetHashKey('taxi') then
|
|
StartTaxiJob()
|
|
else
|
|
ESX.ShowNotification('Vous devez être dans un taxi pour commencer la mission')
|
|
end
|
|
end
|
|
|
|
else
|
|
|
|
if PlayerData.job.grade >= 3 then
|
|
ESX.ShowNotification('Vous devez être dans un véhicule pour commencer la mission')
|
|
else
|
|
ESX.ShowNotification('Vous devez être dans un taxi pour commencer la mission')
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
GUI.Time = GetGameTimer()
|
|
|
|
end
|
|
|
|
end
|
|
end) |