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)
+49 -55
View File
@@ -21,9 +21,9 @@ Config.ShopsBlips = {
},
Mask = {
Pos = {
{ x = -1338.129, y = -1278.200, z = 3.872 },
vector3(-1338.1, -1278.2, 3.8),
},
Blip = { sprite = 362, color = 2 }
Blip = {sprite = 362, color = 2}
},
Helmet = {
Pos = nil,
@@ -38,66 +38,60 @@ Config.ShopsBlips = {
Config.Zones = {
Ears = {
Pos = {
{x= 80.374, y= -1389.493, z= 28.406},
{x= -709.426, y= -153.829, z= 36.535},
{x= -163.093, y= -302.038, z= 38.853},
{x= 420.787, y= -809.654, z= 28.611},
{x= -817.070, y= -1075.96, z= 10.448},
{x= -1451.300, y= -238.254, z= 48.929},
{x= -0.756, y= 6513.685, z= 30.997},
{x= 123.431, y= -208.060, z= 53.677},
{x= 1687.318, y= 4827.685, z= 41.183},
{x= 622.806, y= 2749.221, z= 41.208},
{x= 1200.085, y= 2705.428, z= 37.342},
{x= -1199.959, y= -782.534, z= 16.452},
{x= -3171.867, y= 1059.632, z= 19.983},
{x= -1095.670, y= 2709.245, z= 18.227},
}
},
vector3(80.3, -1389.4, 28.4),
vector3(-163.0, -302.0, 38.8),
vector3(-163.0,-302.0, 38.8),
vector3(420.7, -809.6, 28.6),
vector3(-817.0, -1075.9, 10.4),
vector3(-1451.3, -238.2, 48.9),
vector3(-0.7, 6513.6, 30.9),
vector3(123.4, -208.0, 53.6),
vector3(1687.3, 4827.6, 41.1),
vector3(622.8, 2749.2, 41.2),
vector3(1200.0, 2705.4, 37.3),
vector3(-1199.9, -782.5, 16.4),
vector3(-3171.8, 1059.6, 19.9),
vector3(-1095.6, 2709.2, 18.2),
}},
Mask = {
Pos = {
{x = -1338.129, y = -1278.200, z = 3.872},
}
},
vector3(-1338.1, -1278.2, 3.8),
}},
Helmet = {
Pos = {
{x= 81.576, y= -1400.602, z= 28.406},
{x= -705.845, y= -159.015, z= 36.535},
{x= -161.349, y= -295.774, z= 38.853},
{x= 419.319, y= -800.647, z= 28.611},
{x= -824.362, y= -1081.741, z= 10.448},
{x= -1454.888, y= -242.911, z= 48.931},
{x= 4.770, y= 6520.935, z= 30.997},
{x= 121.071, y= -223.266, z= 53.377},
{x= 1689.648, y= 4818.805, z= 41.183},
{x= 613.971, y= 2749.978, z= 41.208},
{x= 1189.513, y= 2703.947, z= 37.342},
{x= -1204.025, y= -774.439, z= 16.452},
{x= -3164.280, y= 1054.705, z= 19.983},
{x= -1103.125, y= 2700.599, z= 18.227},
}
},
vector3(81.5, -1400.6, 28.4),
vector3(-705.8, -159.0, 36.5),
vector3(-161.3, -295.7, 38.8),
vector3(419.3, -800.6, 28.6),
vector3(-824.3, -1081.7, 10.4),
vector3(-1454.8, -242.9, 48.9),
vector3(4.7, 6520.9, 30.9),
vector3(121.0, -223.2, 53.3),
vector3(1689.6, 4818.8, 41.1),
vector3(613.9, 2749.9, 41.2),
vector3(1189.5, 2703.9, 37.3),
vector3(-1204.0, -774.4, 16.4),
vector3(-3164.2, 1054.7, 19.9),
vector3(-1103.1, 2700.5, 18.2),
}},
Glasses = {
Pos = {
{x= 75.287, y= -1391.131, z= 28.406},
{x= -713.102, y= -160.116, z= 36.535},
{x= -156.171, y= -300.547, z= 38.853},
{x= 425.478, y= -807.866, z= 28.611},
{x= -820.853, y= -1072.940, z= 10.448},
{x= -1458.052, y= -236.783, z= 48.918},
{x= 3.587, y= 6511.585, z= 30.997},
{x= 131.335, y= -212.336, z= 53.677},
{x= 1694.936, y= 4820.837, z= 41.183},
{x= 613.972, y= 2768.814, z= 41.208},
{x= 1198.678, y= 2711.011, z= 37.342},
{x= -1188.227, y= -764.594, z= 16.452},
{x= -3173.192, y= 1038.228, z= 19.983},
{x= -1100.494, y= 2712.481, z= 18.227},
}
}
vector3(75.2, -1391.1, 28.4),
vector3(-713.1, -160.1, 36.5),
vector3(-156.1, -300.5, 38.8),
vector3(425.4, -807.8, 28.6),
vector3(-820.8, -1072.9, 10.4),
vector3(-1458.0, -236.7, 48.9),
vector3(3.5, 6511.5, 30.9),
vector3(131.3, -212.3, 53.6),
vector3(1694.9, 4820.8, 41.1),
vector3(613.9, 2768.8, 41.2),
vector3(1198.6, 2711.0, 37.3),
vector3(-1188.2, -764.5, 16.4),
vector3(-3173.1, 1038.2, 19.9),
vector3(-1100.4, 2712.4, 18.2),
}}
}
+1 -1
View File
@@ -43,5 +43,5 @@ end)
ESX.RegisterServerCallback('esx_accessories:checkMoney', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
cb(xPlayer.get('money') >= Config.Price)
cb(xPlayer.getMoney() >= Config.Price)
end)