Skip to content

Commit c4c12fc

Browse files
committed
Add setPedJetPack
1 parent 49e0ce4 commit c4c12fc

File tree

8 files changed

+72
-2
lines changed

8 files changed

+72
-2
lines changed

Client/mods/deathmatch/logic/rpc/CPedRPCs.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ void CPedRPCs::LoadFunctions(void)
2121
AddHandler(SET_PED_ROTATION, SetPedRotation, "SetPedRotation");
2222
AddHandler(GIVE_PED_JETPACK, GivePedJetPack, "GivePedJetPack");
2323
AddHandler(REMOVE_PED_JETPACK, RemovePedJetPack, "RemovePedJetPack");
24+
AddHandler(SET_PED_JETPACK, SetPedJetPack, "SetPedJetPack");
2425
AddHandler(REMOVE_PED_CLOTHES, RemovePedClothes, "RemovePedClothes");
2526
AddHandler(SET_PED_GRAVITY, SetPedGravity, "SetPedGravity");
2627
AddHandler(SET_PED_CHOKING, SetPedChoking, "SetPedChoking");
@@ -100,6 +101,19 @@ void CPedRPCs::RemovePedJetPack(CClientEntity* pSource, NetBitStreamInterface& b
100101
}
101102
}
102103

104+
void CPedRPCs::SetPedJetPack(CClientEntity* pSource, NetBitStreamInterface& bitStream)
105+
{
106+
bool bJetPack;
107+
if (bitStream.ReadBit(bJetPack))
108+
{
109+
CClientPed* pPed = m_pPedManager->Get(pSource->GetID(), true);
110+
if (pPed)
111+
{
112+
pPed->SetHasJetPack(bJetPack);
113+
}
114+
}
115+
}
116+
103117
void CPedRPCs::RemovePedClothes(CClientEntity* pSource, NetBitStreamInterface& bitStream)
104118
{
105119
unsigned char ucType;

Client/mods/deathmatch/logic/rpc/CPedRPCs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CPedRPCs : public CRPCFunctions
2323
DECLARE_ELEMENT_RPC(SetPedRotation);
2424
DECLARE_ELEMENT_RPC(GivePedJetPack);
2525
DECLARE_ELEMENT_RPC(RemovePedJetPack);
26+
DECLARE_ELEMENT_RPC(SetPedJetPack);
2627
DECLARE_ELEMENT_RPC(RemovePedClothes);
2728
DECLARE_ELEMENT_RPC(SetPedGravity);
2829
DECLARE_ELEMENT_RPC(SetPedChoking);
@@ -39,4 +40,4 @@ class CPedRPCs : public CRPCFunctions
3940
DECLARE_ELEMENT_RPC(ReloadPedWeapon);
4041
};
4142

42-
#endif
43+
#endif

Server/mods/deathmatch/logic/CPerfStat.RPCPacketUsage.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ ADD_ENUM1(SET_PED_ARMOR)
4242
ADD_ENUM1(SET_PED_ROTATION)
4343
ADD_ENUM1(GIVE_PED_JETPACK)
4444
ADD_ENUM1(REMOVE_PED_JETPACK)
45+
ADD_ENUM1(SET_PED_JETPACK)
4546
ADD_ENUM1(REMOVE_PED_CLOTHES)
4647
ADD_ENUM1(SET_PED_GRAVITY)
4748
ADD_ENUM1(SET_PED_CHOKING)

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3898,6 +3898,29 @@ bool CStaticFunctionDefinitions::RemovePedJetPack(CElement* pElement)
38983898
return false;
38993899
}
39003900

3901+
bool CStaticFunctionDefinitions::SetPedJetPack(CElement* pElement, bool bJetPack)
3902+
{
3903+
assert(pElement);
3904+
RUN_CHILDREN(SetPedJetPack(*iter, bJetPack))
3905+
3906+
if (IS_PED(pElement))
3907+
{
3908+
CPed* pPed = static_cast<CPed*>(pElement);
3909+
if (pPed->IsSpawned() && bJetPack != pPed->HasJetPack())
3910+
{
3911+
pPed->SetHasJetPack(bJetPack);
3912+
3913+
CBitStream BitStream;
3914+
BitStream.pBitStream->WriteBit(bJetPack);
3915+
m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(pPed, SET_PED_JETPACK, *BitStream.pBitStream));
3916+
3917+
return true;
3918+
}
3919+
}
3920+
3921+
return false;
3922+
}
3923+
39013924
bool CStaticFunctionDefinitions::SetPedFightingStyle(CElement* pElement, unsigned char ucStyle)
39023925
{
39033926
assert(pElement);

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ class CStaticFunctionDefinitions
186186
static bool RemovePedClothes(CElement* pElement, unsigned char ucType, const char* szTexture = NULL, const char* szModel = NULL);
187187
static bool GivePedJetPack(CElement* pElement);
188188
static bool RemovePedJetPack(CElement* pElement);
189+
static bool SetPedJetPack(CElement* pElement, bool bJetPack);
189190
static bool SetPedFightingStyle(CElement* pElement, unsigned char ucStyle);
190191
static bool SetPedMoveAnim(CElement* pElement, unsigned int iMoveAnim);
191192
static bool SetPedGravity(CElement* pElement, float fGravity);

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ void CLuaPedDefs::LoadFunctions(void)
5454
CLuaCFunctions::AddFunction("removePedClothes", RemovePedClothes);
5555
CLuaCFunctions::AddFunction("givePedJetPack", GivePedJetPack);
5656
CLuaCFunctions::AddFunction("removePedJetPack", RemovePedJetPack);
57+
CLuaCFunctions::AddFunction("setPedJetPack", SetPedJetPack);
5758
CLuaCFunctions::AddFunction("setPedFightingStyle", SetPedFightingStyle);
5859
CLuaCFunctions::AddFunction("setPedWalkingStyle", SetPedMoveAnim);
5960
CLuaCFunctions::AddFunction("setPedGravity", SetPedGravity);
@@ -96,6 +97,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
9697
lua_classfunction(luaVM, "removeFromVehicle", "removePedFromVehicle");
9798
lua_classfunction(luaVM, "removeJetPack", "removePedJetPack");
9899
lua_classfunction(luaVM, "doesHaveJetpack", "doesPedHaveJetPack");
100+
lua_classfunction(luaVM, "setJetPack", "setPedJetPack");
99101

100102
lua_classfunction(luaVM, "isDead", "isPedDead");
101103
lua_classfunction(luaVM, "isDucked", "isPedDucked");
@@ -1238,6 +1240,32 @@ int CLuaPedDefs::RemovePedJetPack(lua_State* luaVM)
12381240
return 1;
12391241
}
12401242

1243+
int CLuaPedDefs::SetPedJetPack(lua_State* luaVM)
1244+
{
1245+
CElement* pElement;
1246+
bool bJetPack;
1247+
1248+
CScriptArgReader argStream(luaVM);
1249+
argStream.ReadUserData(pElement);
1250+
argStream.ReadBool(bJetPack);
1251+
1252+
if (!argStream.HasErrors())
1253+
{
1254+
LogWarningIfPlayerHasNotJoinedYet(luaVM, pElement);
1255+
1256+
if (CStaticFunctionDefinitions::SetPedJetPack(pElement, bJetPack))
1257+
{
1258+
lua_pushboolean(luaVM, true);
1259+
return 1;
1260+
}
1261+
}
1262+
else
1263+
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
1264+
1265+
lua_pushboolean(luaVM, false);
1266+
return 1;
1267+
}
1268+
12411269
int CLuaPedDefs::SetPedFightingStyle(lua_State* luaVM)
12421270
{
12431271
CElement* pElement;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class CLuaPedDefs : public CLuaDefs
6363
LUA_DECLARE(RemovePedClothes);
6464
LUA_DECLARE(GivePedJetPack);
6565
LUA_DECLARE(RemovePedJetPack);
66+
LUA_DECLARE(SetPedJetPack);
6667
LUA_DECLARE(SetPedFightingStyle);
6768
LUA_DECLARE(SetPedMoveAnim);
6869
LUA_DECLARE(SetPedGravity);
@@ -77,4 +78,4 @@ class CLuaPedDefs : public CLuaDefs
7778
LUA_DECLARE(SetPedHeadless);
7879
LUA_DECLARE(SetPedFrozen);
7980
LUA_DECLARE(reloadPedWeapon);
80-
};
81+
};

Shared/sdk/net/rpc_enums.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ enum eElementRPCFunctions
4545
SET_PED_ROTATION,
4646
GIVE_PED_JETPACK,
4747
REMOVE_PED_JETPACK,
48+
SET_PED_JETPACK,
4849
REMOVE_PED_CLOTHES,
4950
SET_PED_GRAVITY,
5051
SET_PED_CHOKING,

0 commit comments

Comments
 (0)