Skip to content
Permalink
Browse files

Add setPedArmor function for clientside peds (#811)

* Add setPedArmor function for clientside peds

* Refactor

* Use CClientPed instead of CClientEntity

* Hard error
  • Loading branch information...
StrixG authored and patrikjuvonen committed Sep 2, 2019
1 parent a914a58 commit e1ac7e2f356df288f1c6cce23976d7b9d1a8bb36
@@ -2450,6 +2450,17 @@ 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))
@@ -189,6 +189,7 @@ 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);
@@ -87,6 +87,7 @@ void CLuaPedDefs::LoadFunctions()
{"warpPedIntoVehicle", WarpPedIntoVehicle},
{"removePedFromVehicle", RemovePedFromVehicle},
{"setPedOxygenLevel", SetPedOxygenLevel},
{"setPedArmor", SetPedArmor},
{"givePedWeapon", GivePedWeapon},
{"isPedReloadingWeapon", IsPedReloadingWeapon},
};
@@ -167,6 +168,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "setControlState", "setPedControlState");
lua_classfunction(luaVM, "warpIntoVehicle", "warpPedIntoVehicle");
lua_classfunction(luaVM, "setOxygenLevel", "setPedOxygenLevel");
lua_classfunction(luaVM, "setArmor", "setPedArmor");
lua_classfunction(luaVM, "setWeaponSlot", "setPedWeaponSlot");
lua_classfunction(luaVM, "setDoingGangDriveby", "setPedDoingGangDriveby");
lua_classfunction(luaVM, "setFightingStyle", "setPedFightingStyle");
@@ -187,7 +189,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classvariable(luaVM, "canBeKnockedOffBike", "setPedCanBeKnockedOffBike", "canPedBeKnockedOffBike");
lua_classvariable(luaVM, "hasJetPack", NULL, "doesPedHaveJetPack");
lua_classvariable(luaVM, "jetpack", NULL, "isPedWearingJetpack"); // introduced in 1.5.5-9.13846
lua_classvariable(luaVM, "armor", NULL, "getPedArmor");
lua_classvariable(luaVM, "armor", "setPedArmor", "getPedArmor");
lua_classvariable(luaVM, "fightingStyle", "setPedFightingStyle", "getPedFightingStyle");
lua_classvariable(luaVM, "cameraRotation", "setPedCameraRotation", "getPedCameraRotation");
lua_classvariable(luaVM, "contactElement", NULL, "getPedContactElement");
@@ -2138,6 +2140,23 @@ int CLuaPedDefs::SetPedMoveAnim(lua_State* luaVM)
return 1;
}

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

if (argStream.HasErrors())
{
return luaL_error(luaVM, argStream.GetFullErrorMessage());
}

lua_pushboolean(luaVM, CStaticFunctionDefinitions::SetPedArmor(*pPed, fArmor));
return 1;
}

int CLuaPedDefs::SetPedOxygenLevel(lua_State* luaVM)
{
// Verify the argument
@@ -72,6 +72,7 @@ class CLuaPedDefs : public CLuaDefs
LUA_DECLARE(SetPedAnimationProgress);
LUA_DECLARE(SetPedAnimationSpeed);
LUA_DECLARE(SetPedMoveAnim);
LUA_DECLARE(SetPedArmor);
LUA_DECLARE(SetPedWeaponSlot);
LUA_DECLARE(GivePedWeapon);
LUA_DECLARE(IsPedReloadingWeapon);

0 comments on commit e1ac7e2

Please sign in to comment.
You can’t perform that action at this time.