Minor cleanup

Co-Authored-By: danishrp <danishrp@users.noreply.github.com>
This commit is contained in:
ElPumpo
2019-09-18 18:39:36 +02:00
parent 96f9dab2a8
commit cceee68ca7
+35 -43
View File
@@ -1,21 +1,9 @@
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 Vehicles = {}
local PlayerData = {}
local lsMenuIsShowed = false
local isInLSMarker = false
local myCar = {}
ESX = nil
local Vehicles = {}
local PlayerData = {}
local lsMenuIsShowed = false
local isInLSMarker = false
local myCar = {}
Citizen.CreateThread(function()
while ESX == nil do
@@ -27,6 +15,7 @@ end)
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
PlayerData = xPlayer
ESX.TriggerServerCallback('esx_lscustom:getVehiclesPrices', function(vehicles)
Vehicles = vehicles
end)
@@ -83,16 +72,16 @@ function OpenLSMenu(elems, menuName, menuTitle, parent)
if isRimMod then
price = math.floor(vehiclePrice * data.current.price / 100)
TriggerServerEvent("esx_lscustom:buyMod", price)
TriggerServerEvent('esx_lscustom:buyMod', price)
elseif v.modType == 11 or v.modType == 12 or v.modType == 13 or v.modType == 15 or v.modType == 16 then
price = math.floor(vehiclePrice * v.price[data.current.modNum + 1] / 100)
TriggerServerEvent("esx_lscustom:buyMod", price)
TriggerServerEvent('esx_lscustom:buyMod', price)
elseif v.modType == 17 then
price = math.floor(vehiclePrice * v.price[1] / 100)
TriggerServerEvent("esx_lscustom:buyMod", price)
TriggerServerEvent('esx_lscustom:buyMod', price)
else
price = math.floor(vehiclePrice * v.price / 100)
TriggerServerEvent("esx_lscustom:buyMod", price)
TriggerServerEvent('esx_lscustom:buyMod', price)
end
end
@@ -128,10 +117,10 @@ end
function UpdateMods(data)
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if data.modType ~= nil then
if data.modType then
local props = {}
if data.wheelType ~= nil then
if data.wheelType then
props['wheels'] = data.wheelType
ESX.Game.SetVehicleProperties(vehicle, props)
props = {}
@@ -199,7 +188,7 @@ function GetAction(data)
menuTitle = v.label
parent = v.parent
if v.modType ~= nil then
if v.modType then
if v.modType == 22 then
table.insert(elements, {label = " " .. _U('by_default'), modType = k, modNum = false})
@@ -283,7 +272,7 @@ function GetAction(data)
local modCount = GetNumVehicleMods(vehicle, v.modType)
for j = 0, modCount, 1 do
local modName = GetModTextLabel(vehicle, v.modType, j)
if modName ~= nil then
if modName then
local _label = ''
if j == currentMods.modFrontWheels then
_label = GetLabelText(modName) .. ' - <span style="color:cornflowerblue;">'.. _U('installed') ..'</span>'
@@ -321,7 +310,7 @@ function GetAction(data)
local modCount = GetNumVehicleMods(vehicle, v.modType) -- BODYPARTS
for j = 0, modCount, 1 do
local modName = GetModTextLabel(vehicle, v.modType, j)
if modName ~= nil then
if modName then
local _label = ''
if j == currentMods[k] then
_label = GetLabelText(modName) .. ' - <span style="color:cornflowerblue;">'.. _U('installed') ..'</span>'
@@ -369,11 +358,13 @@ end
Citizen.CreateThread(function()
for k,v in pairs(Config.Zones) do
local blip = AddBlipForCoord(v.Pos.x, v.Pos.y, v.Pos.z)
SetBlipSprite(blip, 72)
SetBlipScale(blip, 0.8)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(v.Name)
BeginTextCommandSetBlipName('STRING')
AddTextComponentSubstringPlayerName(v.Name)
EndTextCommandSetBlipName(blip)
end
end)
@@ -383,12 +374,12 @@ Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = PlayerPedId()
if IsPedInAnyVehicle(playerPed, false) then
local coords = GetEntityCoords(PlayerPedId())
local currentZone = nil
local zone = nil
local lastZone = nil
if (PlayerData.job ~= nil and PlayerData.job.name == 'mechanic') or Config.IsMechanicJobOnly == false then
local coords = GetEntityCoords(PlayerPedId())
local currentZone, zone, lastZone
if (PlayerData.job and PlayerData.job.name == 'mechanic') or not Config.IsMechanicJobOnly then
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
isInLSMarker = true
@@ -400,8 +391,8 @@ Citizen.CreateThread(function()
end
end
if IsControlJustReleased(0, Keys['E']) and not lsMenuIsShowed and isInLSMarker then
if (PlayerData.job ~= nil and PlayerData.job.name == 'mechanic') or Config.IsMechanicJobOnly == false then
if IsControlJustReleased(0, 38) and not lsMenuIsShowed and isInLSMarker then
if (PlayerData.job and PlayerData.job.name == 'mechanic') or not Config.IsMechanicJobOnly then
lsMenuIsShowed = true
local vehicle = GetVehiclePedIsIn(playerPed, false)
@@ -429,14 +420,15 @@ end)
-- Prevent Free Tunning Bug
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
Citizen.Wait(0)
if lsMenuIsShowed then
DisableControlAction(2, Keys['F1'], true)
DisableControlAction(2, Keys['F2'], true)
DisableControlAction(2, Keys['F3'], true)
DisableControlAction(2, Keys['F6'], true)
DisableControlAction(2, Keys['F7'], true)
DisableControlAction(2, Keys['F'], true)
DisableControlAction(2, 288, true)
DisableControlAction(2, 289, true)
DisableControlAction(2, 170, true)
DisableControlAction(2, 167, true)
DisableControlAction(2, 168, true)
DisableControlAction(2, 23, true)
DisableControlAction(0, 75, true) -- Disable exit vehicle
DisableControlAction(27, 75, true) -- Disable exit vehicle
else