From bd1be5e9538c90e61998ad4c71d268da65fabee1 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Sun, 13 Apr 2025 19:07:02 +0100 Subject: [PATCH] add function to get animal anim table for that ped --- shared/isAnimal.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/shared/isAnimal.lua b/shared/isAnimal.lua index f99c118..7c99525 100644 --- a/shared/isAnimal.lua +++ b/shared/isAnimal.lua @@ -188,7 +188,33 @@ if not isServer() then end return animalModels end + + --- Compiles and returns a table of animal animations for the ped model. + --- + --- Iterates through every category in AnimalPeds and collects all anims. + --- + --- @return table table A table containing all current model anims. + --- + ---@usage + --- ```lua + --- local getAnim = getAnimalAnims(ped) + --- playAnim(getAnim.sitDict, getAnim.sitAnim, -1, 1) + --- ``` + function getAnimalAnims(ped) + local model = GetEntityModel(ped) + local animalTable = {} + for _, animalCategory in pairs(AnimalPeds) do + for k, v in pairs(animalCategory) do + if k == model then + animalTable = v + break + end + end + end + return animalTable + end end + ------------------------------------------------------------- -- Animal Models Data -------------------------------------------------------------