Skip to content

Commit 83635b8

Browse files
committed
setPedArmor & warnings
1 parent 6b121ad commit 83635b8

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,9 +1486,9 @@ bool CStaticFunctionDefinitions::SetElementAlpha(CClientEntity& Entity, unsigned
14861486
return true;
14871487
}
14881488

1489-
bool CStaticFunctionDefinitions::SetElementHealth(CClientEntity& Entity, float fHealth)
1489+
bool CStaticFunctionDefinitions::SetElementHealth(lua_State* luaState, CClientEntity& Entity, float fHealth)
14901490
{
1491-
RUN_CHILDREN(SetElementHealth(**iter, fHealth))
1491+
RUN_CHILDREN(SetElementHealth(luaState, **iter, fHealth))
14921492

14931493
switch (Entity.GetType())
14941494
{
@@ -1498,7 +1498,10 @@ bool CStaticFunctionDefinitions::SetElementHealth(CClientEntity& Entity, float f
14981498
// Grab the model
14991499
CClientPed& Ped = static_cast<CClientPed&>(Entity);
15001500
if (Ped.IsLocalPlayer())
1501+
{
1502+
g_pClientGame->GetScriptDebugging()->LogWarning(luaState, "The client-side setElementHealth function for localPlayer is deprecated. Use the corresponding server-side function instead");
15011503
return false;
1504+
}
15021505

15031506
// If setting health to 0 for local player, clear stale damage data
15041507
// and set proper scripted death parameters for DoWastedCheck

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class CStaticFunctionDefinitions
9999
static bool DetachElements(CClientEntity& Entity, CClientEntity* pAttachedToEntity = NULL);
100100
static bool SetElementAttachedOffsets(CClientEntity& Entity, CVector& vecPosition, CVector& vecRotation);
101101
static bool SetElementAlpha(CClientEntity& Entity, unsigned char ucAlpha);
102-
static bool SetElementHealth(CClientEntity& Entity, float fHealth);
102+
static bool SetElementHealth(lua_State* luaState, CClientEntity& Entity, float fHealth);
103103
static bool SetElementModel(CClientEntity& Entity, unsigned short usModel);
104104
static bool SetElementCollisionsEnabled(CClientEntity& Entity, bool bEnabled);
105105
static bool SetElementCollidableWith(CClientEntity& Entity, CClientEntity& ThisEntity, bool bCanCollide);

Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2401,7 +2401,7 @@ int CLuaElementDefs::SetElementHealth(lua_State* luaVM)
24012401
// Verify the arguments
24022402
if (!argStream.HasErrors())
24032403
{
2404-
if (CStaticFunctionDefinitions::SetElementHealth(*pEntity, fHealth))
2404+
if (CStaticFunctionDefinitions::SetElementHealth(luaVM, *pEntity, fHealth))
24052405
{
24062406
lua_pushboolean(luaVM, true);
24072407
return 1;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,6 +2433,9 @@ bool CLuaPedDefs::SetPedArmor(CClientPed* const ped, const float armor)
24332433
if (armor > 100.0f)
24342434
throw std::invalid_argument("Armor must be less than or equal to 100");
24352435

2436+
if (ped->IsLocalPlayer())
2437+
throw LuaFunctionError("The client-side setPedArmor function for localPlayer is deprecated. Use the corresponding server-side function instead", true);
2438+
24362439
ped->SetArmor(armor);
24372440
return true;
24382441
}

0 commit comments

Comments
 (0)