Skip to content
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
23 changes: 6 additions & 17 deletions Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2306,18 +2306,18 @@ bool CStaticFunctionDefinitions::SetPedDoingGangDriveby(CClientEntity& Entity, b

bool CStaticFunctionDefinitions::SetPedFightingStyle(CClientEntity& Entity, unsigned char ucStyle)
{
// Is valid style?
if (ucStyle < 4 || ucStyle > 16)
return false;

RUN_CHILDREN(SetPedFightingStyle(**iter, ucStyle))
if (IS_PED(&Entity) && Entity.IsLocalEntity())
{
CClientPed& Ped = static_cast<CClientPed&>(Entity);
if (Ped.GetFightingStyle() != ucStyle)
{
// Is valid style
if (ucStyle >= 4 && ucStyle <= 16)
{
Ped.SetFightingStyle(static_cast<eFightingStyle>(ucStyle));
return true;
}
Ped.SetFightingStyle(static_cast<eFightingStyle>(ucStyle));
return true;
}
}
return false;
Expand Down Expand Up @@ -2507,17 +2507,6 @@ bool CStaticFunctionDefinitions::SetPedOnFire(CClientEntity& Entity, bool bOnFir
return false;
}

bool CStaticFunctionDefinitions::SetPedArmor(CClientPed& Ped, float fArmor)
{
if (Ped.IsLocalEntity())
{
Ped.SetArmor(fArmor);
return true;
}

return false;
}

bool CStaticFunctionDefinitions::SetPedOxygenLevel(CClientEntity& Entity, float fOxygen)
{
if (IS_PED(&Entity))
Expand Down
1 change: 0 additions & 1 deletion Client/mods/deathmatch/logic/CStaticFunctionDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ class CStaticFunctionDefinitions
static bool RemovePedFromVehicle(CClientPed* pPed);
static bool WarpPedIntoVehicle(CClientPed* pPed, CClientVehicle* pVehicle, unsigned int uiSeat);
static bool SetPedOxygenLevel(CClientEntity& Entity, float fOxygen);
static bool SetPedArmor(CClientPed& Ped, float fArmor);

// Extra Clothes functions
static bool GetBodyPartName(unsigned char ucID, SString& strOutName);
Expand Down
40 changes: 14 additions & 26 deletions Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
*****************************************************************************/

#include "StdInc.h"
#include "lua/CLuaFunctionParser.h"

#define MIN_CLIENT_REQ_REMOVEPEDFROMVEHICLE_CLIENTSIDE "1.3.0-9.04482"
#define MIN_CLIENT_REQ_WARPPEDINTOVEHICLE_CLIENTSIDE "1.3.0-9.04482"

Expand Down Expand Up @@ -75,7 +77,7 @@ void CLuaPedDefs::LoadFunctions()
{"setPedControlState", SetPedControlState},
{"setPedAnalogControlState", SetPedAnalogControlState},
{"setPedDoingGangDriveby", SetPedDoingGangDriveby},
{"setPedFightingStyle", SetPedFightingStyle},
{"setPedFightingStyle", ArgumentParser<SetPedFightingStyle>},
{"setPedLookAt", SetPedLookAt},
{"setPedHeadless", SetPedHeadless},
{"setPedFrozen", SetPedFrozen},
Expand All @@ -86,7 +88,7 @@ void CLuaPedDefs::LoadFunctions()
{"warpPedIntoVehicle", WarpPedIntoVehicle},
{"removePedFromVehicle", RemovePedFromVehicle},
{"setPedOxygenLevel", SetPedOxygenLevel},
{"setPedArmor", SetPedArmor},
{"setPedArmor", ArgumentParser<SetPedArmor>},
{"givePedWeapon", GivePedWeapon},
{"isPedReloadingWeapon", IsPedReloadingWeapon},
};
Expand Down Expand Up @@ -1762,19 +1764,13 @@ int CLuaPedDefs::SetPedDoingGangDriveby(lua_State* luaVM)
return 1;
}

int CLuaPedDefs::SetPedFightingStyle(lua_State* luaVM)
bool CLuaPedDefs::SetPedFightingStyle(CClientEntity* const entity, const unsigned int style)
{
CClientEntity* pEntity;
unsigned char ucStyle;
CScriptArgReader argStream(luaVM);
argStream.ReadUserData(pEntity);
argStream.ReadNumber(ucStyle);

if (argStream.HasErrors())
return luaL_error(luaVM, argStream.GetFullErrorMessage());
// Is valid style?
if (style < 4 || style > 16)
throw std::invalid_argument("Style can only be between 4 and 16");

lua_pushboolean(luaVM, CStaticFunctionDefinitions::SetPedFightingStyle(*pEntity, ucStyle));
return 1;
return CStaticFunctionDefinitions::SetPedFightingStyle(*entity, style);
}

int CLuaPedDefs::SetPedLookAt(lua_State* luaVM)
Expand Down Expand Up @@ -2198,21 +2194,13 @@ int CLuaPedDefs::SetPedMoveAnim(lua_State* luaVM)
return 1;
}

int CLuaPedDefs::SetPedArmor(lua_State* luaVM)
bool CLuaPedDefs::SetPedArmor(CClientPed* const ped, const float armor)
{
CClientPed* pPed;
float fArmor;
CScriptArgReader argStream(luaVM);
argStream.ReadUserData(pPed);
argStream.ReadNumber(fArmor);

if (argStream.HasErrors())
{
return luaL_error(luaVM, argStream.GetFullErrorMessage());
}
if (!ped->IsLocalEntity())
return false;

lua_pushboolean(luaVM, CStaticFunctionDefinitions::SetPedArmor(*pPed, fArmor));
return 1;
ped->SetArmor(armor);
return true;
}

int CLuaPedDefs::SetPedOxygenLevel(lua_State* luaVM)
Expand Down
4 changes: 2 additions & 2 deletions Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CLuaPedDefs : public CLuaDefs
LUA_DECLARE(SetPedAnimationProgress);
LUA_DECLARE(SetPedAnimationSpeed);
LUA_DECLARE(SetPedMoveAnim);
LUA_DECLARE(SetPedArmor);
static bool SetPedArmor(CClientPed* const ped, const float armor);
LUA_DECLARE(SetPedWeaponSlot);
LUA_DECLARE(GivePedWeapon);
LUA_DECLARE(IsPedReloadingWeapon);
Expand All @@ -80,7 +80,7 @@ class CLuaPedDefs : public CLuaDefs
LUA_DECLARE(SetPedControlState);
LUA_DECLARE(SetPedAnalogControlState);
LUA_DECLARE(SetPedDoingGangDriveby);
LUA_DECLARE(SetPedFightingStyle);
static bool SetPedFightingStyle(CClientEntity* const entity, const unsigned int style);
LUA_DECLARE(SetPedLookAt);
LUA_DECLARE(SetPedHeadless);
LUA_DECLARE(SetPedFrozen);
Expand Down