Added minimum distance, customer in backseat, cleanup and pretty markers

This commit is contained in:
ElPumpo
2019-01-10 14:07:11 +01:00
parent 3960dd3a78
commit ecf7ac586e
3 changed files with 61 additions and 61 deletions
+40 -45
View File
@@ -538,49 +538,33 @@ Citizen.CreateThread(function()
SetBlipAsShortRange(blip, true) SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING") BeginTextCommandSetBlipName("STRING")
AddTextComponentString(_U('blip_taxi')) AddTextComponentSubstringPlayerName(_U('blip_taxi'))
EndTextCommandSetBlipName(blip) EndTextCommandSetBlipName(blip)
end) end)
-- Display markers -- Enter / Exit marker events, and draw markers
Citizen.CreateThread(function() Citizen.CreateThread(function()
while true do while true do
Citizen.Wait(0) Citizen.Wait(0)
if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'taxi' then if ESX.PlayerData.job and ESX.PlayerData.job.name == 'taxi' then
local coords = GetEntityCoords(PlayerPedId()) local coords = GetEntityCoords(PlayerPedId())
local isInMarker, currentZone = false
for k,v in pairs(Config.Zones) do 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 local distance = GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true)
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)
if v.Type ~= -1 and distance < 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.0, v.Size.x, v.Size.y, v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, false, 2, v.Rotate, nil, nil, false)
end end
end
else
Citizen.Wait(500)
end
end
end)
-- Enter / Exit marker events if distance < v.Size.x then
Citizen.CreateThread(function() isInMarker, currentZone = true, k
while true do
Citizen.Wait(0)
if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'taxi' then
local coords = GetEntityCoords(PlayerPedId())
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
end end
if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then
HasAlreadyEnteredMarker = true HasAlreadyEnteredMarker, LastZone = true, currentZone
LastZone = currentZone
TriggerEvent('esx_taxijob:hasEnteredMarker', currentZone) TriggerEvent('esx_taxijob:hasEnteredMarker', currentZone)
end end
@@ -589,7 +573,7 @@ Citizen.CreateThread(function()
TriggerEvent('esx_taxijob:hasExitedMarker', LastZone) TriggerEvent('esx_taxijob:hasExitedMarker', LastZone)
end end
else else
Citizen.Wait(500) Citizen.Wait(1000)
end end
end end
end) end)
@@ -618,14 +602,14 @@ Citizen.CreateThread(function()
if CurrentCustomer ~= nil then if CurrentCustomer ~= nil then
CurrentCustomerBlip = AddBlipForEntity(CurrentCustomer) CurrentCustomerBlip = AddBlipForEntity(CurrentCustomer)
SetBlipAsFriendly(CurrentCustomerBlip, 1) SetBlipAsFriendly(CurrentCustomerBlip, true)
SetBlipColour(CurrentCustomerBlip, 2) SetBlipColour(CurrentCustomerBlip, 2)
SetBlipCategory(CurrentCustomerBlip, 3) SetBlipCategory(CurrentCustomerBlip, 3)
SetBlipRoute(CurrentCustomerBlip, true) SetBlipRoute(CurrentCustomerBlip, true)
SetEntityAsMissionEntity(CurrentCustomer, true, false) SetEntityAsMissionEntity(CurrentCustomer, true, false)
ClearPedTasksImmediately(CurrentCustomer) ClearPedTasksImmediately(CurrentCustomer)
SetBlockingOfNonTemporaryEvents(CurrentCustomer, 1) SetBlockingOfNonTemporaryEvents(CurrentCustomer, true)
local standTime = GetRandomIntInRange(60000, 180000) local standTime = GetRandomIntInRange(60000, 180000)
TaskStandStill(CurrentCustomer, standTime) TaskStandStill(CurrentCustomer, standTime)
@@ -682,13 +666,21 @@ Citizen.CreateThread(function()
CurrentCustomer, CurrentCustomerBlip, DestinationBlip, IsNearCustomer, CustomerIsEnteringVehicle, CustomerEnteredVehicle, TargetCoords = nil, nil, nil, false, false, false, nil CurrentCustomer, CurrentCustomerBlip, DestinationBlip, IsNearCustomer, CustomerIsEnteringVehicle, CustomerEnteredVehicle, TargetCoords = nil, nil, nil, false, false, false, nil
end end
if TargetCoords ~= nil then if TargetCoords then
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) DrawMarker(36, TargetCoords.x, TargetCoords.y, TargetCoords.z + 1.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 234, 223, 72, 155, false, false, 2, true, nil, nil, false)
end end
else else
RemoveBlip(CurrentCustomerBlip) RemoveBlip(CurrentCustomerBlip)
CurrentCustomerBlip = nil CurrentCustomerBlip = nil
TargetCoords = Config.JobLocations[GetRandomIntInRange(1, #Config.JobLocations)] TargetCoords = Config.JobLocations[GetRandomIntInRange(1, #Config.JobLocations)]
local distance = GetDistanceBetweenCoords(playerCoords, TargetCoords.x, TargetCoords.y, TargetCoords.z, true)
while distance < Config.MinimumDistance do
Citizen.Wait(5)
TargetCoords = Config.JobLocations[GetRandomIntInRange(1, #Config.JobLocations)]
distance = GetDistanceBetweenCoords(playerCoords, TargetCoords.x, TargetCoords.y, TargetCoords.z, true)
end
local street = table.pack(GetStreetNameAtCoord(TargetCoords.x, TargetCoords.y, TargetCoords.z)) local street = table.pack(GetStreetNameAtCoord(TargetCoords.x, TargetCoords.y, TargetCoords.z))
local msg = nil local msg = nil
@@ -704,17 +696,17 @@ Citizen.CreateThread(function()
DestinationBlip = AddBlipForCoord(TargetCoords.x, TargetCoords.y, TargetCoords.z) DestinationBlip = AddBlipForCoord(TargetCoords.x, TargetCoords.y, TargetCoords.z)
BeginTextCommandSetBlipName("STRING") BeginTextCommandSetBlipName("STRING")
AddTextComponentString("Destination") AddTextComponentSubstringPlayerName("Destination")
EndTextCommandSetBlipName(blip) EndTextCommandSetBlipName(blip)
SetBlipRoute(DestinationBlip, true) SetBlipRoute(DestinationBlip, true)
CustomerEnteredVehicle = true CustomerEnteredVehicle = true
end end
else else
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) DrawMarker(36, customerCoords.x, customerCoords.y, customerCoords.z + 1.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 234, 223, 72, 155, false, false, 2, true, nil, nil, false)
if not CustomerEnteredVehicle then if not CustomerEnteredVehicle then
if customerDistance <= 30.0 then if customerDistance <= 40.0 then
if not IsNearCustomer then if not IsNearCustomer then
ESX.ShowNotification(_U('close_to_client')) ESX.ShowNotification(_U('close_to_client'))
@@ -723,20 +715,23 @@ Citizen.CreateThread(function()
end end
if customerDistance <= 100.0 then if customerDistance <= 20.0 then
if not CustomerIsEnteringVehicle then if not CustomerIsEnteringVehicle then
ClearPedTasksImmediately(CurrentCustomer) ClearPedTasksImmediately(CurrentCustomer)
local seat = 0 local maxSeats, freeSeat = GetVehicleMaxNumberOfPassengers(vehicle)
for i=4, 0, 1 do
if IsVehicleSeatFree(vehicle, seat) then for i=maxSeats - 1, 0, -1 do
seat = i if IsVehicleSeatFree(vehicle, i) then
freeSeat = i
break break
end end
end end
TaskEnterVehicle(CurrentCustomer, vehicle, -1, seat, 2.0, 1) if freeSeat then
CustomerIsEnteringVehicle = true TaskEnterVehicle(CurrentCustomer, vehicle, -1, freeSeat, 2.0, 0)
CustomerIsEnteringVehicle = true
end
end end
end end
end end
@@ -756,10 +751,10 @@ Citizen.CreateThread(function()
while true do while true do
Citizen.Wait(0) Citizen.Wait(0)
if CurrentAction ~= nil then if CurrentAction and not IsDead then
ESX.ShowHelpNotification(CurrentActionMsg) ESX.ShowHelpNotification(CurrentActionMsg)
if IsControlJustReleased(0, Keys['E']) and ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'taxi' then if IsControlJustReleased(0, Keys['E']) and ESX.PlayerData.job and ESX.PlayerData.job.name == 'taxi' then
if CurrentAction == 'taxi_actions_menu' then if CurrentAction == 'taxi_actions_menu' then
OpenTaxiActionsMenu() OpenTaxiActionsMenu()
elseif CurrentAction == 'cloakroom' then elseif CurrentAction == 'cloakroom' then
@@ -774,7 +769,7 @@ Citizen.CreateThread(function()
end end
end end
if IsControlJustReleased(0, Keys['F6']) and GetLastInputMethod(2) and not IsDead and Config.EnablePlayerManagement and ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'taxi' then if IsControlJustReleased(0, Keys['F6']) and IsInputDisabled(0) and not IsDead and Config.EnablePlayerManagement and ESX.PlayerData.job and ESX.PlayerData.job.name == 'taxi' then
OpenMobileTaxiActionsMenu() OpenMobileTaxiActionsMenu()
end end
end end
+19 -14
View File
@@ -1,10 +1,15 @@
Config = {} Config = {}
Config.DrawDistance = 100.0 Config.DrawDistance = 100.0
Config.NPCJobEarnings = {min = 15, max = 40}
Config.NPCJobEarnings = {min = 300, max = 600}
Config.MinimumDistance = 3000 -- Minimum NPC job destination distance from the pickup in GTA units, a higher number prevents nearby destionations.
Config.MaxInService = -1 Config.MaxInService = -1
Config.EnablePlayerManagement = false Config.EnablePlayerManagement = false
Config.EnableSocietyOwnedVehicles = false Config.EnableSocietyOwnedVehicles = false
Config.Locale = 'en'
Config.Locale = 'fr'
Config.AuthorizedVehicles = { Config.AuthorizedVehicles = {
@@ -18,38 +23,38 @@ Config.AuthorizedVehicles = {
Config.Zones = { Config.Zones = {
VehicleSpawner = { VehicleSpawner = {
Pos = {x = 915.039, y = -162.187, z = 73.684}, Pos = {x = 915.039, y = -162.187, z = 74.5},
Size = {x = 1.5, y = 1.5, z = 1.0}, Size = {x = 1.0, y = 1.0, z = 1.0},
Color = {r = 204, g = 204, b = 0}, Color = {r = 204, g = 204, b = 0},
Type = 1 Type = 36, Rotate = true
}, },
VehicleSpawnPoint = { VehicleSpawnPoint = {
Pos = {x = 911.108, y = -177.867, z = 74.283}, Pos = {x = 911.108, y = -177.867, z = 74.283},
Size = {x = 1.5, y = 1.5, z = 1.0}, Size = {x = 1.5, y = 1.5, z = 1.0},
Type = -1, Type = -1, Rotate = false,
Heading = 225.0 Heading = 225.0
}, },
VehicleDeleter = { VehicleDeleter = {
Pos = {x = 908.317, y = -183.070, z = 73.201}, Pos = {x = 908.317, y = -183.070, z = 73.201},
Size = {x = 3.0, y = 3.0, z = 1.0}, Size = {x = 3.0, y = 3.0, z = 0.25},
Color = {r = 255, g = 0, b = 0}, Color = {r = 255, g = 0, b = 0},
Type = 1 Type = 1, Rotate = false
}, },
TaxiActions = { TaxiActions = {
Pos = {x = 903.32, y = -170.55, z = 73.00}, Pos = {x = 903.32, y = -170.55, z = 74.0},
Size = {x = 1.5, y = 1.5, z = 1.0}, Size = {x = 1.0, y = 1.0, z = 1.0},
Color = {r = 204, g = 204, b = 0}, Color = {r = 204, g = 204, b = 0},
Type = 1 Type = 20, Rotate = true
}, },
Cloakroom = { Cloakroom = {
Pos = {x = 894.88, y = -180.23, z = 73.50}, Pos = {x = 894.88, y = -180.23, z = 74.5},
Size = {x = 1.5, y = 1.5, z = 1.0}, Size = {x = 1.0, y = 1.0, z = 1.0},
Color = {r = 204, g = 204, b = 0}, Color = {r = 204, g = 204, b = 0},
Type = 1 Type = 21, Rotate = true
} }
} }
+2 -2
View File
@@ -1,12 +1,12 @@
Locales['en'] = { Locales['en'] = {
-- cloakroom -- cloakroom
['cloakroom_menu'] = 'cloakroom', ['cloakroom_menu'] = 'cloakroom',
['cloakroom_prompt'] = 'press ~INPUT_CONTEXT~ to open the ~y~cloakroom~s~.', ['cloakroom_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Cloakroom~s~.',
['wear_citizen'] = 'citizen wear', ['wear_citizen'] = 'citizen wear',
['wear_work'] = 'taxi wear', ['wear_work'] = 'taxi wear',
-- garage -- garage
['spawner_prompt'] = 'press ~INPUT_CONTEXT~ to open the ~y~garage~s~.', ['spawner_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Garage~s~.',
['store_veh'] = 'press ~INPUT_CONTEXT~ to store the vehicle', ['store_veh'] = 'press ~INPUT_CONTEXT~ to store the vehicle',
['spawn_veh'] = 'spawn vehicle', ['spawn_veh'] = 'spawn vehicle',
['spawnpoint_blocked'] = 'there is a vehicle blocking the spawnpoint!', ['spawnpoint_blocked'] = 'there is a vehicle blocking the spawnpoint!',