diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp b/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp index 1d10a059162..c820dce259a 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp +++ b/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp @@ -67,6 +67,7 @@ void CLuaPedDefs::LoadFunctions() {"removePedFromVehicle", RemovePedFromVehicle}, {"setPedDoingGangDriveby", SetPedDoingGangDriveby}, {"setPedAnimation", ArgumentParserWarn}, + {"getPedAnimation", ArgumentParserWarn}, {"setPedAnimationProgress", SetPedAnimationProgress}, {"setPedAnimationSpeed", SetPedAnimationSpeed}, {"setPedOnFire", SetPedOnFire}, @@ -148,6 +149,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM) lua_classfunction(luaVM, "setWeaponSlot", "setPedWeaponSlot"); lua_classfunction(luaVM, "setWalkingStyle", "setPedWalkingStyle"); lua_classfunction(luaVM, "setAnimation", "setPedAnimation"); + lua_classfunction(luaVM, "getAnimation", "getPedAnimation"); lua_classfunction(luaVM, "setAnimationProgress", "setPedAnimationProgress"); lua_classfunction(luaVM, "setAnimationSpeed", "setPedAnimationSpeed"); lua_classfunction(luaVM, "setWearingJetpack", "setPedWearingJetpack"); // introduced in 1.5.5-9.13846 @@ -424,6 +426,26 @@ bool CLuaPedDefs::SetPedAnimation(CElement* pPed, std::optional> CLuaPedDefs::GetPedAnimation(CPed* pPed) +{ + const SPlayerAnimData& animData = pPed->GetAnimationData(); + + if (!animData.IsAnimating()) + return false; + + return CLuaMultiReturn( + animData.blockName, + animData.animName, + animData.time, + animData.loop, + animData.updatePosition, + animData.interruptable, + animData.freezeLastFrame, + animData.blendTime, + animData.taskToBeRestoredOnAnimEnd + ); +} + int CLuaPedDefs::SetPedAnimationProgress(lua_State* luaVM) { CElement* pElement; diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.h b/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.h index 407a052e217..f22a5378dbc 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.h +++ b/Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.h @@ -11,6 +11,7 @@ #pragma once #include "CLuaDefs.h" +#include class CLuaPedDefs : public CLuaDefs { @@ -73,6 +74,7 @@ class CLuaPedDefs : public CLuaDefs LUA_DECLARE(RemovePedFromVehicle); LUA_DECLARE(SetPedDoingGangDriveby); static bool SetPedAnimation(CElement* pPed, std::optional> blockName, std::optional> animName, std::optional time, std::optional loop, std::optional updatePosition, std::optional interruptable, std::optional freezeLastFrame, std::optional blendTime, std::optional restoreTask); + static std::variant> GetPedAnimation(CPed* pPed); LUA_DECLARE(SetPedAnimationProgress); LUA_DECLARE(SetPedAnimationSpeed); LUA_DECLARE(SetPedWeaponSlot);