Support for newest ESX + Minor cleanup (#29)

* Support for newest ESX

* Minor cleanup

* Moved all coords to vector3 types

* Moved all coords to vector3 types
This commit is contained in:
rex2630
2020-02-26 13:46:39 +01:00
committed by GitHub
parent 3e52e7ece0
commit 6a0e69e9a1
3 changed files with 67 additions and 86 deletions
+17 -30
View File
@@ -1,10 +1,7 @@
ESX = nil
local HasAlreadyEnteredMarker = false
local LastZone = nil
local CurrentAction = nil
local CurrentActionMsg = ''
local CurrentActionData = {}
local isDead = false
ESX = nil
local HasAlreadyEnteredMarker, isDead = false, false
local LastZone, CurrentAction, CurrentActionMsg
local CurrentActionData = {}
Citizen.CreateThread(function()
while ESX == nil do
@@ -14,8 +11,7 @@ Citizen.CreateThread(function()
end)
function OpenAccessoryMenu()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'set_unset_accessory',
{
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'set_unset_accessory', {
title = _U('set_unset'),
align = 'top-left',
elements = {
@@ -23,11 +19,9 @@ function OpenAccessoryMenu()
{label = _U('ears'), value = 'Ears'},
{label = _U('mask'), value = 'Mask'},
{label = _U('glasses'), value = 'Glasses'}
}
}, function(data, menu)
}}, function(data, menu)
menu.close()
SetUnsetAccessory(data.current.value)
end, function(data, menu)
menu.close()
end)
@@ -59,7 +53,6 @@ function SetUnsetAccessory(accessory)
else
ESX.ShowNotification(_U('no_' .. _accessory))
end
end, accessory)
end
@@ -68,20 +61,18 @@ function OpenShopMenu(accessory)
local restrict = {}
restrict = { _accessory .. '_1', _accessory .. '_2' }
TriggerEvent('esx_skin:openRestrictedMenu', function(data, menu)
menu.close()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm',
{
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', {
title = _U('valid_purchase'),
align = 'top-left',
elements = {
{label = _U('no'), value = 'no'},
{label = _U('yes', ESX.Math.GroupDigits(Config.Price)), value = 'yes'}
}
}, function(data, menu)
}}, function(data, menu)
menu.close()
if data.current.value == 'yes' then
ESX.TriggerServerCallback('esx_accessories:checkMoney', function(hasEnoughMoney)
@@ -122,7 +113,6 @@ function OpenShopMenu(accessory)
CurrentAction = 'shop_menu'
CurrentActionMsg = _U('press_access')
CurrentActionData = {}
end)
end, function(data, menu)
menu.close()
@@ -156,7 +146,7 @@ Citizen.CreateThread(function()
for k,v in pairs(Config.ShopsBlips) do
if v.Pos ~= nil then
for i=1, #v.Pos, 1 do
local blip = AddBlipForCoord(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z)
local blip = AddBlipForCoord(v.Pos[i])
SetBlipSprite (blip, v.Blip.sprite)
SetBlipDisplay(blip, 4)
@@ -179,25 +169,24 @@ Citizen.CreateThread(function()
local coords = GetEntityCoords(PlayerPedId())
for k,v in pairs(Config.Zones) do
for i = 1, #v.Pos, 1 do
if(Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.DrawDistance) then
DrawMarker(Config.Type, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false)
if(Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos[i], true) < Config.DrawDistance) then
DrawMarker(Config.Type, v.Pos[i], 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Size.x, Config.Size.y, Config.Size.z, Config.Color.r, Config.Color.g, Config.Color.b, 100, false, true, 2, false, false, false, false)
end
end
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(200)
local coords = GetEntityCoords(PlayerPedId())
local isInMarker = false
local coords = GetEntityCoords(PlayerPedId())
local isInMarker = false
local currentZone = nil
for k,v in pairs(Config.Zones) do
for i = 1, #v.Pos, 1 do
if GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.Size.x then
if GetDistanceBetweenCoords(coords, v.Pos[i], true) < Config.Size.x then
isInMarker = true
currentZone = k
end
@@ -214,7 +203,6 @@ Citizen.CreateThread(function()
HasAlreadyEnteredMarker = false
TriggerEvent('esx_accessories:hasExitedMarker', LastZone)
end
end
end)
@@ -223,14 +211,14 @@ Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if CurrentAction ~= nil then
if CurrentAction then
ESX.ShowHelpNotification(CurrentActionMsg)
if IsControlJustReleased(0, 38) and CurrentActionData.accessory then
OpenShopMenu(CurrentActionData.accessory)
CurrentAction = nil
end
elseif CurrentAction == nil and not Config.EnableControls then
elseif CurrentAction and not Config.EnableControls then
Citizen.Wait(500)
end
@@ -239,6 +227,5 @@ Citizen.CreateThread(function()
OpenAccessoryMenu()
end
end
end
end)