Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: localized functions and removed unused variables #14

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 29 additions & 34 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand All @@ -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)

Expand Down
11 changes: 5 additions & 6 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
fx_version 'adamant'

fx_version 'cerulean'
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'