From 681c030883b1f8866315d6d7a3ed9eb68c2b85e0 Mon Sep 17 00:00:00 2001 From: Mirow Date: Fri, 26 Jul 2024 08:21:55 +0200 Subject: [PATCH] refactor: localized functions and removed unused variables --- client/main.lua | 63 +++++++++++++++++++++++-------------------------- fxmanifest.lua | 9 ++++--- 2 files changed, 33 insertions(+), 39 deletions(-) diff --git a/client/main.lua b/client/main.lua index 08f4be4..e50edd4 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,54 +1,31 @@ -local inAnim = false - -function startAttitude(lib, anim) +local function startAttitude(lib, anim) ESX.Streaming.RequestAnimSet(lib, function() - SetPedMovementClipset(ESX.PlayerData.ped, anim, true) + SetPedMovementClipset(ESX.PlayerData.ped, anim, 1) end) end -function startAnim(lib, anim) +local function startAnim(lib, anim) ESX.Streaming.RequestAnimDict(lib, function() TaskPlayAnim(ESX.PlayerData.ped, lib, anim, 8.0, -8.0, -1, 0, 0.0, false, false, false) RemoveAnimDict(lib) end) end -function startScenario(anim) +local function startScenario(anim) TaskStartScenarioInPlace(ESX.PlayerData.ped, anim, 0, false) end -function OpenAnimationsMenu() - local elements = { - {unselectable = true, icon = "fas fa-smile", title = "Animations"} - } - - for i=1, #Config.Animations, 1 do - elements[#elements+1] = { - icon = "fas fa-smile", - title = Config.Animations[i].label, - value = Config.Animations[i].name - } - end - - ESX.OpenContext("right", elements, function(menu,element) - OpenAnimationsSubMenu(element.value) - end) -end - -function OpenAnimationsSubMenu(menu) - local title = nil +local function openAnimationsSubMenu(menu) local elements = {} - for i=1, #Config.Animations, 1 do + for i = 1, #Config.Animations, 1 do elements = { - {unselectable = true, icon = "fas fa-smile", title = Config.Animations[i].label} + { unselectable = true, icon = "fas fa-smile", title = Config.Animations[i].label } } if Config.Animations[i].name == menu then - title = Config.Animations[i].label - - for j=1, #Config.Animations[i].items, 1 do - elements[#elements+1] = { + for j = 1, #Config.Animations[i].items, 1 do + elements[#elements + 1] = { icon = "fas fa-smile", title = Config.Animations[i].items[j].label, type = Config.Animations[i].items[j].type, @@ -59,7 +36,7 @@ function OpenAnimationsSubMenu(menu) end end - ESX.OpenContext("right", elements, function(menu,element) + ESX.OpenContext("right", elements, function(_, element) local type = element.type local lib = element.value.lib local anim = element.value.anim @@ -74,10 +51,28 @@ function OpenAnimationsSubMenu(menu) end) end +local function openAnimationsMenu() + local elements = { + { unselectable = true, icon = "fas fa-smile", title = "Animations" } + } + + for i = 1, #Config.Animations, 1 do + elements[#elements + 1] = { + icon = "fas fa-smile", + title = Config.Animations[i].label, + value = Config.Animations[i].name + } + end + + ESX.OpenContext("right", elements, function(_, element) + openAnimationsSubMenu(element.value) + end) +end + -- Key Controls RegisterCommand('animmenu', function() if not ESX.PlayerData.dead then - OpenAnimationsMenu() + openAnimationsMenu() end end, false) diff --git a/fxmanifest.lua b/fxmanifest.lua index 15935ab..5c562e0 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -1,15 +1,14 @@ fx_version 'adamant' - game 'gta5' - -description 'Allows Players to play animations' lua54 'yes' +description 'Allows Players to play animations' version '1.0' + +dependency 'es_extended' + client_scripts { '@es_extended/imports.lua', 'config.lua', 'client/main.lua' } - -dependency 'es_extended'