Skip to content

Commit 7b31f09

Browse files
committed
Add getPedAnimation for serverside too
1 parent 3c26865 commit 7b31f09

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ void CLuaPedDefs::LoadFunctions()
6767
{"removePedFromVehicle", RemovePedFromVehicle},
6868
{"setPedDoingGangDriveby", SetPedDoingGangDriveby},
6969
{"setPedAnimation", ArgumentParserWarn<false, SetPedAnimation>},
70+
{"getPedAnimation", ArgumentParserWarn<false, GetPedAnimation>},
7071
{"setPedAnimationProgress", SetPedAnimationProgress},
7172
{"setPedAnimationSpeed", SetPedAnimationSpeed},
7273
{"setPedOnFire", SetPedOnFire},
@@ -148,6 +149,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
148149
lua_classfunction(luaVM, "setWeaponSlot", "setPedWeaponSlot");
149150
lua_classfunction(luaVM, "setWalkingStyle", "setPedWalkingStyle");
150151
lua_classfunction(luaVM, "setAnimation", "setPedAnimation");
152+
lua_classfunction(luaVM, "getAnimation", "getPedAnimation");
151153
lua_classfunction(luaVM, "setAnimationProgress", "setPedAnimationProgress");
152154
lua_classfunction(luaVM, "setAnimationSpeed", "setPedAnimationSpeed");
153155
lua_classfunction(luaVM, "setWearingJetpack", "setPedWearingJetpack"); // introduced in 1.5.5-9.13846
@@ -424,6 +426,26 @@ bool CLuaPedDefs::SetPedAnimation(CElement* pPed, std::optional<std::variant<std
424426
return CStaticFunctionDefinitions::SetPedAnimation(pPed, animBlockName, animationName, time.value_or(-1), blendTime.value_or(250), loop.value_or(true), updatePosition.value_or(true), interruptable.value_or(true), freezeLastFrame.value_or(true), restoreTask.value_or(false));
425427
}
426428

429+
std::variant<bool, CLuaMultiReturn<std::string, std::string, int, bool, bool, bool, bool, int, bool>> CLuaPedDefs::GetPedAnimation(CPed* pPed)
430+
{
431+
const SPlayerAnimData& animData = pPed->GetAnimationData();
432+
433+
if (!animData.IsAnimating())
434+
return false;
435+
436+
return CLuaMultiReturn<std::string, std::string, int, bool, bool, bool, bool, int, bool>(
437+
animData.blockName,
438+
animData.animName,
439+
animData.time,
440+
animData.loop,
441+
animData.updatePosition,
442+
animData.interruptable,
443+
animData.freezeLastFrame,
444+
animData.blendTime,
445+
animData.taskToBeRestoredOnAnimEnd
446+
);
447+
}
448+
427449
int CLuaPedDefs::SetPedAnimationProgress(lua_State* luaVM)
428450
{
429451
CElement* pElement;

Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#pragma once
1313
#include "CLuaDefs.h"
14+
#include <lua/CLuaMultiReturn.h>
1415

1516
class CLuaPedDefs : public CLuaDefs
1617
{
@@ -73,6 +74,7 @@ class CLuaPedDefs : public CLuaDefs
7374
LUA_DECLARE(RemovePedFromVehicle);
7475
LUA_DECLARE(SetPedDoingGangDriveby);
7576
static bool SetPedAnimation(CElement* pPed, std::optional<std::variant<std::string, std::monostate, bool>> blockName, std::optional<std::variant<std::string, std::monostate, bool>> animName, std::optional<int> time, std::optional<bool> loop, std::optional<bool> updatePosition, std::optional<bool> interruptable, std::optional<bool> freezeLastFrame, std::optional<int> blendTime, std::optional<bool> restoreTask);
77+
static std::variant<bool, CLuaMultiReturn<std::string, std::string, int, bool, bool, bool, bool, int, bool>> GetPedAnimation(CPed* pPed);
7678
LUA_DECLARE(SetPedAnimationProgress);
7779
LUA_DECLARE(SetPedAnimationSpeed);
7880
LUA_DECLARE(SetPedWeaponSlot);

0 commit comments

Comments
 (0)