vector3, fixes #18

This commit is contained in:
ElPumpo
2018-12-23 17:27:07 +01:00
parent a3f312e505
commit 20eb4f5a7e
2 changed files with 24 additions and 21 deletions
+19 -18
View File
@@ -2,10 +2,9 @@ local Keys = {
["ESC"] = 322, ["BACKSPACE"] = 177, ["E"] = 38, ["ENTER"] = 18, ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173
}
local menuIsShowed = false
local hasAlreadyEnteredMarker = false
local lastZone = nil
local isInJoblistingMarker = false
local menuIsShowed = false
local hasAlreadyEnteredMarker = false
local isInMarker = false
ESX = nil
@@ -17,13 +16,13 @@ Citizen.CreateThread(function()
end)
function ShowJobListingMenu()
ESX.TriggerServerCallback('esx_joblisting:getJobsList', function(data)
ESX.TriggerServerCallback('esx_joblisting:getJobsList', function(jobs)
local elements = {}
for i = 1, #data, 1 do
for i=1, #jobs, 1 do
table.insert(elements, {
label = data[i].label,
job = data[i].job
label = jobs[i].label,
job = jobs[i].job
})
end
@@ -51,9 +50,10 @@ Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
local coords = GetEntityCoords(PlayerPedId())
for i=1, #Config.Zones, 1 do
if GetDistanceBetweenCoords(coords, Config.Zones[i].x, Config.Zones[i].y, Config.Zones[i].z, true) < Config.DrawDistance then
DrawMarker(Config.MarkerType, Config.Zones[i].x, Config.Zones[i].y, Config.Zones[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.ZoneSize.x, Config.ZoneSize.y, Config.ZoneSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
if GetDistanceBetweenCoords(coords, Config.Zones[i], true) < Config.DrawDistance then
DrawMarker(Config.MarkerType, Config.Zones[i], 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.ZoneSize.x, Config.ZoneSize.y, Config.ZoneSize.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, false, false, false)
end
end
end
@@ -64,20 +64,21 @@ Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
local coords, currentZone = GetEntityCoords(PlayerPedId()), nil
local coords = GetEntityCoords(PlayerPedId())
isInMarker = false
for i=1, #Config.Zones, 1 do
if GetDistanceBetweenCoords(coords, Config.Zones[i].x, Config.Zones[i].y, Config.Zones[i].z, true) < (Config.ZoneSize.x / 2) then
isInJoblistingMarker = true
if GetDistanceBetweenCoords(coords, Config.Zones[i], true) < (Config.ZoneSize.x / 2) then
isInMarker = true
ESX.ShowHelpNotification(_U('access_job_center'))
end
end
if isInJoblistingMarker and not hasAlreadyEnteredMarker then
if isInMarker and not hasAlreadyEnteredMarker then
hasAlreadyEnteredMarker = true
end
if not isInJoblistingMarker and hasAlreadyEnteredMarker then
if not isInMarker and hasAlreadyEnteredMarker then
hasAlreadyEnteredMarker = false
TriggerEvent('esx_joblisting:hasExitedMarker')
end
@@ -87,7 +88,7 @@ end)
-- Create blips
Citizen.CreateThread(function()
for i=1, #Config.Zones, 1 do
local blip = AddBlipForCoord(Config.Zones[i].x, Config.Zones[i].y, Config.Zones[i].z)
local blip = AddBlipForCoord(Config.Zones[i])
SetBlipSprite (blip, 407)
SetBlipDisplay(blip, 4)
@@ -96,7 +97,7 @@ Citizen.CreateThread(function()
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(_U('job_center'))
AddTextComponentSubstringPlayerName(_U('job_center'))
EndTextCommandSetBlipName(blip)
end
end)
@@ -106,7 +107,7 @@ Citizen.CreateThread(function()
while true do
Citizen.Wait(10)
if IsControlJustReleased(0, Keys['E']) and isInJoblistingMarker and not menuIsShowed then
if IsControlJustReleased(0, Keys['E']) and isInMarker and not menuIsShowed then
ESX.UI.Menu.CloseAll()
ShowJobListingMenu()
end
+5 -3
View File
@@ -1,10 +1,12 @@
Config = {}
Config.DrawDistance = 100.0
Config.ZoneSize = {x = 3.0, y = 3.0, z = 2.0}
Config.ZoneSize = {x = 3.0, y = 3.0, z = 0.5}
Config.MarkerColor = {r = 100, g = 100, b = 204}
Config.MarkerType = 1
Config.Locale = 'en'
Config.Locale = 'fr'
Config.Zones = {
{x = -265.036, y = -963.630, z = 30.223}
vector3(-265.0, -963.6, 30.2)
}